input: 
  def solve_maze(grid: List[List[int]]) -> List[int]:
      """Given a maze represented as a 2D grid where 1 represents a walkable path 
      and 0 represents a blocked path, find a path from the top-left corner (0, 0) to 
      the bottom-right corner (n-1, m-1) using depth-first search. Return the path 
      as a list of integers representing the steps taken. If no path exists, return an empty list.
      >>> solve_maze([[1, 1, 0], [0, 1, 0], [0, 1, 1]])
      [0, 1, 4]
      >>> solve_maze([[1, 0, 0], [1, 0, 0], [1, 1, 1]])
      [0, 3, 6]
      >>> solve_maze([[1, 0, 0], [1, 0, 0], [0, 1, 1]])
      []
      """
  
output:     def dfs(x, y, path):
          if x < 0 or x >= len(grid) or y < 0 or y >= len(grid[0]) or grid[x][y] == 0:
              return False
          if x == len(grid) - 1 and y == len(grid[0]) - 1:
              path.append(x * len(grid[0]) + y)
              return True
          grid[x][y] = 0
          path.append(x * len(grid[0]) + y)
          if dfs(x + 1, y, path) or dfs(x, y + 1, path) or dfs(x - 1, y, path) or dfs(x, y - 1, path):
              return True
          path.pop()
          return False
  
      path = []
      if dfs(0, 0, path):
          return path
      return []