input: from typing import List
  
  def solve_maze(grid: List[List[int]]) -> List[int]:
      """ Given a 2D grid representing a maze, find the shortest path from the top-left corner
      to the bottom-right corner. The grid contains 0s for walls and 1s for paths. The path must
      only go through cells that contain 1. If no path is found, return an empty list.
      
      >>> solve_maze([[1, 0, 1], [1, 1, 1], [1, 0, 1]])
      [4, 3, 2, 1]
      >>> solve_maze([[1, 0, 1], [1, 0, 1], [1, 0, 1]])
      []
      """
      n, m = len(grid), len(grid[0])
      start, end = (0, 0), (n-1, m-1)
      result, found = [], False
      
      def _find_omega(i, j, value, result, start, end, found):
          rowNbr, colNbr = [-1, 0, 0, 1], [0, -1, 1, 0]
          
          if (i, j) == end:
              found = True
              result.append(value)
              return
          
          if found == True:
              return
          
          grid[i][j] = 0
          for k in range(4):
              if _on_board(i + rowNbr[k], j + colNbr[k]):
                  _find_omega(i + rowNbr[k], j + colNbr[k], value + 1, result, start, end, found)
      
      def _on_board(i, j):
          return 0 <= i < n and 0 <= j < m and grid[i][j] == 1
      
      for i in range(n):
          for j in range(m):
              if grid[i][j] == 1:
                  _find_omega(i, j, 0, result, start, end, found)
                  return result
      
      return []
output:     if not result:
          return []
      return result[::-1]