input: def solve_maze(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """
      Solves a maze represented by a grid of size n x m where 1 represents an open path and 0 represents a blocked path.
      The algorithm starts at the top-left corner (0,0) and attempts to find a path to the bottom-right corner (n-1, m-1).
      
      :param n: Number of rows in the maze.
      :param m: Number of columns in the maze.
      :param grid: The maze grid represented as a 2D list of integers.
      :return: A list of integers representing the path length from the start to the end of the maze.
      
      >>> solve_maze(3, 3, [[1, 0, 0], [1, 1, 1], [0, 0, 1]])
      [4]
      >>> solve_maze(2, 2, [[1, 1], [1, 1]])
      [2]
      """
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, 1)])
      visited = set((0, 0))
  
      while queue:
          x, y, dist = queue.popleft()
  
          if x == n - 1 and y == 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 []