n, q = map(int, input().split())
s = input()
lr = {}
def move(x):
    return [-1, 1][x=='R']
g = [list('G')]*n
print(g)
for i in s:
    if i not in lr:
        lr[i] = []
for i in range(n):
    lr[s[i]].append(i)
print(lr)
for i in range(q):
    a, b = input().split()
    if a in s:
        for k in range(len(lr[a])):
            if k+move(b)<0 or n-1<k+move(b):
                g[k].clear()
            else:
                for f in range(len(g[k])):
                    g[k+move(b)].append(g[k].pop())
print(g)