input: 
  def solve_maze(n: int, m: int, maze: List[List[int]]) -> List[int]:
      """Solve the maze problem given the dimensions of the maze (n by m) and the maze itself.
      The maze is represented by a 2D list where 1s represent open paths and 0s represent walls.
      The maze should be solved from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1).
  
      >>> solve_maze(3, 3, [[1, 0, 0], [1, 1, 0], [0, 1, 1]])
      [4]
      >>> solve_maze(4, 4, [[1, 1, 1, 0], [0, 1, 0, 1], [0, 1, 0, 0], [1, 1, 1, 1]])
      [6]
      """
  
output:     from collections import deque
  
      def is_valid(x, y):
          return 0 <= x < n and 0 <= y < m and maze[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, dist = queue.popleft()
          if (x, y) == (n - 1, m - 1):
              return [dist]
          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, dist + 1))
  
      return []