n, m, t = map(int, input().split())

moves = []
for i in range(m):
    p, s, d, l = map(str, input().split())
    moves.append([int(p), int(s), d, int(l)])

for i in range(len(moves)):
    lokomotive = moves[i]
    if lokomotive[2] == "R":
        lokomotive[0] += lokomotive[3] - 1
        lokomotive[0] += lokomotive[1] * t
        lokomotive[3] = lokomotive[0] - lokomotive[3] + 1
        string = ""
        for i in range(n):
            if i == lokomotive[0]:
                string += "!"
            elif i >= lokomotive[3] and i < lokomotive[0]:
                string += "#"
            else:
                string += "="
        print(string)
    else:
        lokomotive[0] -= lokomotive[1] * t
        lokomotive[3] = lokomotive[0] + lokomotive[3] - 1
        string = ""
        for i in range(n):
            if i == lokomotive[0]:
                string += "!"
            elif i <= lokomotive[3] and i > lokomotive[0]:
                string += "#"
            else:
                string += "="
        print(string)

    

    

