
n, m, t = [int(x) for x in input().split(" ")]

for _ in range(m):

    p0l, s, d, l = [(int(x) if x not in {"R", "L"} else x) for x in input().split(" ")]

    v = -s if d == "L" else s
    ptl = p0l + v * t
    ptr = ptl + l - 1
    prmax = n - 1
    plmin = 0

    train = ("!" + (l - 1) * "#") if d == "L" else ((l - 1) * "#" + "!")
    if ptr > prmax:
        train = train[: - (ptr - prmax)]
    if ptl < plmin:
        train = train[(plmin - ptl) :]

    ret = (
        "=" * max(0, min(ptl, n)) +
        train +
        "=" * (n - min(n, max(ptr + 1, 0)))
    )

    # ret = ""
    # ret += ptl * "="
    # ret += ("!" + (l - 1) * "#") if d == "L" else ((l - 1) * "#" + "!")
    # ret += (n - l - ptl) * "="

    print(ret)
