input: from typing import List
  
  def solve_maze(n: int, m: int, grid: List[List[int]]) -> List[int]:
      """ Solves a maze represented by an n x m grid where '1' represents a walkable path and '0' represents an obstacle.
      The function aims to find the optimal path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1).
      It returns a list of integers representing the minimum number of steps required to reach the end from the start,
      traversing only through '1' cells.
      
      >>> solve_maze(3, 3, [[1, 1, 1], [1, 0, 1], [1, 1, 1]])
      [6]
      >>> solve_maze(3, 3, [[1, 0, 1], [1, 1, 1], [1, 1, 1]])
      [4]
      """
output:     from collections import deque
  
      directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
      queue = deque([(0, 0, 0)])
      visited = set((0, 0))
  
      while queue:
          x, y, steps = queue.popleft()
  
          if x == n - 1 and y == m - 1:
              return [steps + 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 grid[nx][ny] == 1:
                  visited.add((nx, ny))
                  queue.append((nx, ny, steps + 1))
  
      return []