input: def Maze_Solution(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """Solves a given maze represented by a grid of size n x m. The maze contains 
      obstacles represented by 0s and open paths represented by 1s. The goal is to find 
      a path from the start position (0, 0) to the end position (n-1, m-1). If a path is 
      found, the function returns a list of integers representing the path length.
      If no path is found, it returns an empty list.
      
      >>> Maze_Solution(3, 3, [[1, 1, 1], [0, 1, 0], [1, 1, 1]])
      [4]
      >>> Maze_Solution(3, 3, [[1, 0, 0], [1, 0, 0], [1, 1, 1]])
      [4]
      """
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, dist = queue.popleft()
          if (x, y) == (n-1, m-1):
              return [dist + 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, dist + 1))
  
      return []