n, m = map(int, input().split()) s = input().strip() # Initialize grid with all 1s except (0,0) grid = [[1] * (n + 1) for _ in range(n + 1)] grid[0][0] = 0 x, y = 0, 0 # Starting position for move in s: # Update position based on the move if move == 'U': y += 1 elif move == 'D': y -= 1 elif move == 'R': x += 1 elif move == 'L': x -= 1 # Check and consume the Kimwipe at the new position if grid[y][x] == 1: grid[y][x] = 0 # Output the grid from top (y=n) to bottom (y=0) for y_coord in range(n, -1, -1): print(' '.join(map(str, grid[y_coord])))