N, M = map(int, input().split()) ss = input() ans = [[1] * (N + 1) for _ in range(N + 1)] x, y = N, 0 ans[x][y] = 0 for s in ss: if s == "U": x -= 1 elif s == "D": x += 1 elif s == "L": y -= 1 else: y += 1 ans[x][y] = 0 for a in ans: print(*a)