input: Write a function to implement an object-oriented structure that solves a maze using Python. The maze is represented as a grid where 1 indicates a passable path and 0 indicates an obstacle. The function should return the shortest path from the top-left corner to the bottom-right corner of the maze if a path exists, otherwise return an empty list. If the maze is empty, return an empty list.
  
  
  class Maze:
      def __init__(self, n, m, grid):
          self._n, self._m = n, m
          self._grid = grid
  
      def solve_maze(self):
          result, found = [], False
          start, end = (0, 0), (self._n-1, self._m-1)
  
          if self._grid[start[0]][start[1]] == 0 or self._grid[end[0]][end[1]] == 0:
              return []
  
          self._find_omega(start[0], start[1], 0, result, start, end, found)
          return result if found else []
  
      def _find_omega(self, i, j, value, result, start, end, found):
          rowNbr, colNbr = [-1, 0, 0, 1], [0, -1, 1, 0]
  
          if (i, j) == end:
              found = True
              result.append(value)
              return
  
          if found == True:
              return
          
          self._grid[i][j] = 0
          for k in range(4):
              new_i, new_j = i + rowNbr[k], j + colNbr[k]
              if self._on_board(new_i, new_j):
                  self._find_omega(new_i, new_j, value + 1, result, start, end, found)
  
      def _on_board(self, i, j):
          return 0 <= i < self._n and 0 <= j < self._m and self._grid[i][j] == 1
  
  # Test cases
  maze1 = Maze(3, 3, [
      [1, 1, 0],
      [0, 1, 1],
      [0, 1, 1]
  ])
  assert maze1.solve_maze() == [4]
  
  maze2 = Maze(3, 3, [
      [1, 0, 1],
      [0, 0, 1],
      [1, 1, 1]
  ])
  assert maze2.solve_maze() == []
  
  maze3 = Maze(2, 2, [
      [1, 1],
      [1, 1]
  ])
  assert maze3.solve_maze() == [2]
  
  maze4 = Maze(0, 0, [])
  assert maze4.solve_maze() == []
  
output: 
  def solve_maze(self):
      if not self._grid or self._grid[0][0] == 0 or self._grid[-1][-1] == 0:
          return []
  
      from collections import deque
      queue = deque([(0, 0, 0)])
      directions = [(-1, 0), (1, 0), (0, -1), (0, 1)]
      visited = set((0, 0))
  
      while queue:
          x, y, dist = queue.popleft()
  
          if (x, y) == (self._n - 1, self._m - 1):
              return [dist]
  
          for dx, dy in directions:
              nx, ny = x + dx, y + dy
              if 0 <= nx < self._n and 0 <= ny < self._m and (nx, ny) not in visited and self._grid[nx][ny] == 1:
                  visited.add((nx, ny))
                  queue.append((nx, ny, dist + 1))
  
      return []
  