input: def solve_maze(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """Given dimensions n and m of a maze and a grid of integers, find a path from the top-left
      corner (start) to the bottom-right corner (end). The maze is represented as a 2D list where
      1 represents a walkable path and 0 represents a blocked path. Return the list of steps
      taken to reach the end, if a path exists. If no path exists, return an empty list.
  
      >>> solve_maze(3, 3, [[1, 0, 0], [1, 1, 0], [0, 1, 1]])
      [5]
      >>> solve_maze(3, 3, [[1, 0, 0], [0, 1, 0], [0, 0, 1]])
      []
      """
output:     
      def is_valid(x, y):
          return 0 <= x < n and 0 <= y < m and grid[x][y] == 1
  
      def dfs(x, y, path):
          if x == n - 1 and y == m - 1:
              return path
          for dx, dy, step in [(-1, 0, 'U'), (1, 0, 'D'), (0, -1, 'L'), (0, 1, 'R')]:
              nx, ny = x + dx, y + dy
              if is_valid(nx, ny):
                  grid[nx][ny] = 0
                  result = dfs(nx, ny, path + [step])
                  if result:
                      return result
                  grid[nx][ny] = 1
          return []
  
      return dfs(0, 0, [])
  