input: from typing import List
  
  def solve_maze(n: int, m: int) -> List[int]:
      """Solve the maze by finding the shortest path from the top-left corner to the bottom-right corner.
      The maze is represented by an n x m grid where 1 represents a path and 0 represents a wall.
      The function returns the length of the shortest path if one exists, otherwise returns an empty list.
      
      >>> solve_maze(3, 3)
      []
      >>> solve_maze(3, 3)
      [4]
      """
output:     from collections import deque
  
      maze = [[1] * m for _ in range(n)]
      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 == n - 1 and y == m - 1:
              return [dist + 1]
          for dx, dy in directions:
              nx, ny = x + dx, y + dy
              if 0 <= nx < n and 0 <= ny < m and (nx, ny) not in visited and maze[nx][ny] == 1:
                  visited.add((nx, ny))
                  queue.append((nx, ny, dist + 1))
  
      return []