import sys sys.setrecursionlimit(1500000) n, m = map(int, input().split()) s = input() mat = [[1] * (n + 1) for _ in range(n + 1)] mat[n][0] = 0 def loop(i, x, y): if i == m: return mat if s[i] == 'L': x -= 1 elif s[i] == 'R': x += 1 if s[i] == 'D': y += 1 elif s[i] == 'U': y -= 1 mat[y][x] = 0 return loop(i + 1, x, y) for row in loop(0, 0, n): print(' '.join(map(str, row)))