input: 
  def solve_maze(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """Solve a maze by finding the path from the top-left corner (0,0) to the bottom-right corner (n-1, m-1). The maze is represented by a 2D grid of integers where 1 represents a path and 0 represents a wall. Return the steps taken to reach the end or an empty list if no path exists.
      >>> solve_maze(3, 3, [[1, 0, 0], [1, 1, 0], [0, 1, 1]])
      [4]
      >>> solve_maze(2, 2, [[1, 0], [0, 1]])
      []
      """
  
output:     from collections import deque
  
      def is_valid(x, y):
          return 0 <= x < n and 0 <= y < m and grid[x][y] == 1
  
      directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
      queue = deque([(0, 0, 0)])
      visited = set((0, 0))
  
      while queue:
          x, y, steps = queue.popleft()
  
          if (x, y) == (n - 1, m - 1):
              return [steps + 1]
  
          for dx, dy in directions:
              nx, ny = x + dx, y + dy
              if is_valid(nx, ny) and (nx, ny) not in visited:
                  visited.add((nx, ny))
                  queue.append((nx, ny, steps + 1))
  
      return []