def main(): n, m = map(int, input().split()) s = input() board = [[1 for _ in range(n+1)] for _ in range(n+1)] board[0][0] = 0 current = [0, 0] for move in s: match move: case "R": current = [current[0], current[1]+1] case "L": current = [current[0], current[1]-1] case "U": current = [current[0]+1, current[1]] case "D": current = [current[0]-1, current[1]] board[current[0]][current[1]] = 0 for row in reversed(board): print(*row) if __name__ == "__main__": main()