input: 
  def solve_maze(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """
      Solves a maze by finding a path from the top-left corner to the bottom-right corner using a recursive backtracking approach.
      The maze is represented by an n x m grid where 1s represent open paths and 0s represent blocked paths.
      The function returns a list of integers representing the path length from the start to the end if a solution exists,
      otherwise it returns an empty list.
      
      >>> solve_maze(3, 3, [[1, 1, 0], [0, 1, 1], [0, 0, 1]])
      [4]
      >>> solve_maze(2, 2, [[1, 0], [0, 1]])
      []
      """
  
output:     def is_valid(x, y):
          return 0 <= x < n and 0 <= y < m and grid[x][y] == 1
  
      def backtrack(x, y, path_length):
          if x == n - 1 and y == m - 1:
              return [path_length]
          grid[x][y] = -1  # Mark the cell as visited
          directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
          for dx, dy in directions:
              nx, ny = x + dx, y + dy
              if is_valid(nx, ny):
                  result = backtrack(nx, ny, path_length + 1)
                  if result:
                      return result
          grid[x][y] = 1  # Unmark the cell
          return []
  
      return backtrack(0, 0, 0)