input: 
  from typing import List
  
  
  def solve_maze(grid: List[List[int]], n: int, m: int) -> List[int]:
      """ Solves a maze represented as a 2D grid of size n x m. The maze contains cells with values:
      1 represents a valid path cell, and 0 represents a wall. The function finds and returns the 
      shortest path from the top-left corner (0, 0) to the bottom-right corner (n-1, m-1).
      The path is represented as a list of integers, where each integer is the distance 
      from the starting point to each step on the path.
      The function uses Depth-First Search (DFS) to explore the maze.
  
      >>> solve_maze([[1, 0, 0], [1, 1, 0], [0, 1, 1]], 3, 3)
      [1, 2, 3, 4]
      >>> solve_maze([[1, 1, 1], [1, 0, 1], [1, 1, 1]], 3, 3)
      [1, 2, 3, 2, 1]
      """
      def _find_path(i, j, value, result, end):
          rowNbr, colNbr = [-1, 0, 0, 1], [0, -1, 1, 0]
  
          if (i, j) == end:
              result.append(value)
              return True
  
          grid[i][j] = 0
          for k in range(4):
              next_i, next_j = i + rowNbr[k], j + colNbr[k]
              if 0 <= next_i < n and 0 <= next_j < m and grid[next_i][next_j] == 1:
                  if _find_path(next_i, next_j, value + 1, result, end):
                      result.append(value)
                      return True
          return False
  
      result = []
      _find_path(0, 0, 0, result, (n-1, m-1))
      return result[::-1]
  
output:     if not result:
          return []
      return result[1:]