n, m = map(int, input().split()) S = input() L = [[1]*(n+1) for _ in range(n+1)] x = 0 y = 0 Lx = [0] Ly = [0] for s in S: if s == 'R': x += 1 elif s == 'L': x -= 1 elif s == 'U': y += 1 else: y -= 1 Lx += [x] Ly += [y] for i, j in zip(Lx, Ly): L[j][i] = 0 for i in L[::-1]: print(*i)