Python Concise BFS
\n    def minimumMoves(self, grid: List[List[int]]) -> int:\n        cur,cnt, n, seen = [(0,0,0)], 0 , len(grid),set([(0,0,0)])      #(tail_row,tail_col,horizon
```\n    def minimumMoves(self, grid: List[List[int]]) -> int:\n        cur,cnt, n, seen = [(0,0,0)], 0 , len(grid),set([(0,0,0)])      #(tail_row,tail_col,horizontal_or_verticle)\n        while cur and (n-1,n-2,0) not in cur:\n            cnt,tmp = cnt+1, []\n            for x,y,dx in cur:\n                if dx==0:\n                    if y+2 < n and grid[x][y+2] == 0: tmp += [(x,y+1,dx)]\n                    if x+1 < n and (grid[x+1][y] + grid[x+1][y+1]) == 0: tmp += [(x,y,1),(x+1,y,0)]\n                else:\n                    if x+2 < n and grid[x+2][y] == 0: tmp += [(x+1,y,dx)]\n                    if y+1 < n and (grid[x][y+1] + grid[x+1][y+1]) == 0: tmp += [(x,y,0),(x,y+1,1)]\n            cur = set(tmp) - seen\n            seen |= cur\n        return cnt if cur else -1\n```
[]