n, m, t = [int(x) for x in input().split()]
for i in range(m):
    pos, speed, direct, length = input().split()
    pos, speed, length = map(int, [pos,speed,length])
    if direct == "R":
        vysl = [pos+t*speed,pos+t*speed+length-1]
    else:
        vysl = [pos - t * speed, pos - t * speed + length - 1]
    string = ""
    for x in range(n):
        if x == vysl[0] and direct == "L" or x == vysl[1] and direct == "R":
            print("!", end="")
        elif vysl[0] <= x <= vysl[1]:
            print("#", end="")
        else:
            print("=", end="")
    print()