N, M, T = map(int, input().split())

def solve():
    position_s, speed_s, direction, length_s = input().split()

    position, speed, length = map(int, [position_s, speed_s, length_s])

    if direction == "L":
        p = position
        v = -speed
        l = length

        start = (p + v * T)
        end = (start + length) #inclusive

        start_overflow = False
        if start < 0:
            start = 0
            start_overflow = True

        if start >= N:
            start = N

        if end < 0:
            end = 0

        if end > N:
            end = N

        if start_overflow:
            s = "#" * (end)
        else:
            s = "=" * (start) + "!" + "#" * (end - 1 - start)

        print(
            s + (N - len(s)) * "="
        )


    if direction == "R":
        p = position
        v = speed
        l = length

        start = (p + v * T)
        end = (start + length)  # inclusive

        start_overflow = False
        if start < 0:
            start = 0

        if start >= N:
            start = N

        if end < 0:
            end = 0

        if end > N:
            start_overflow = True
            end = N

        if start_overflow:
            s =  "=" * (start) + "#" * (end - start)
        else:
            s = "=" * (start) + "#" * (end - 1 - start) + "!"

        print(
            s + (N - len(s)) * "="
        )

for _ in range(M):
    solve()