visible, n_tracks, time = [int(x) for x in input().split()]
for track in range(n_tracks):
    line = [x for x in input().split()]
    pos = int(line[0])

    speed = int(line[1])
    dir = line[2]
    dir_mul = 1 if dir == "R" else -1
    length = int(line[3]) -1 #not sure
    pos = pos + time * speed * dir_mul
    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()