n, m = map(int, input().split()) s = input() ANS = [[1 for _ in range(n + 1)] for _ in range(n + 1)] ANS[n][0] = 0 cx, cy = n, 0 for i in range(m): if s[i] == 'U': dx, dy = -1, 0 elif s[i] == 'R': dx, dy = 0, 1 elif s[i] == 'D': dx, dy = 1, 0 elif s[i] == 'L': dx, dy = 0, -1 if 0 <= cx + dx <= n and 0 <= cy + dy <= n: cx += dx cy += dy ANS[cx][cy] = 0 for ans in ANS: print(*ans)