visible, n_tracks, time = [int(x) for x in input().split()]
lines = []
for line in range(n_tracks):
    lines.append(input().split())

for track in range(n_tracks):
    line = [x for x in lines[track]]
    pos = int(line[0])

    speed = int(line[1])
    dir = line[2]
    dir_mul = 1 if dir == "R" else -1
    length = int(line[3])
    pos = pos + time * speed * dir_mul
    to_print = []
    if(pos>0):
        print_sym = pos if pos < visible else pos - visible
        to_print.append("=" * print_sym)

    start = pos if pos > 0 else 0
    end = pos + length if pos + length < visible else visible
    mozno = end -start
    length -= 1
    if(dir == "L" and pos + length >= 0):
        engine = ""
        if pos >= 0:
            engine = "!"
            mozno -= 1
        #engine = "!" if pos >= 0 else ""
        # if (pos < 0):
        #     length = pos
        to_print.append(engine + "#" * mozno)
    elif (pos < visible):
        engine = ""
        if pos + length < visible:
            engine = "!"
            mozno -= 1
        #engine = "!" if pos + length < visible else ""
        # if(pos + length > visible):
        #     length = visible - pos
        to_print.append("#" * mozno + engine)
    if (pos + length < visible):
        to_print.append("=" * (visible - pos - length - 1))

    print("".join(to_print))
    # for cell in range(visible):
    #     if(pos <= cell <= pos+length):
    #         if(dir == "L" and pos == cell):
    #             print("!", end="")
    #         elif (dir == "R" and cell == pos+length):
    #             print("!", end="")
    #         else:
    #             print("#", end="")
    #     else:print("=", end="")
    # print()

    """
5 3 3
10 0 R 3
1 1 R 1
-5 2 R 1
k
=====
====!
=!===
"""

"""
6 2 0
5 1 R 6
4 0 L 5


=====
====!#

6 2 0
0 1 L 6
4 0 L 5

!#####
====!#
"""

"""
6 2 0
-1 1 L 6
4 0 L 5
####=
====!#
"""

"""
6 2 0
-1 1 L 7
4 0 L 5
#####
====!#
"""