N, M = map(int, input().split()) S = input() x, y = 0, 0 K = [[1] * (N + 1) for i in range(N + 1)] K[0][0] = 0 dx = {"U": 0, "R": 1, "L": -1, "D": 0} dy = {"U": 1, "R": 0, "L": 0, "D": -1} for i in range(M): x += dx[S[i]] y += dy[S[i]] K[x][y] = 0 for y in range(N, -1, -1): for x in range(N + 1): print(K[x][y], end = " ") print("")