Python Dijkstra solution
```\nclass Solution:\n    def minPushBox(self, m: List[List[str]]) -> int:\n        de = ((1,0),(0,1),(-1,0),(0,-1))\n        rl,cl = len(m),len(m[0])\n        
```\nclass Solution:\n    def minPushBox(self, m: List[List[str]]) -> int:\n        de = ((1,0),(0,1),(-1,0),(0,-1))\n        rl,cl = len(m),len(m[0])\n        memo, q = set(), []\n        for i in range(rl):\n            for j in range(cl):\n                if m[i][j] == "T":\n                    tx,ty = i,j\n                elif m[i][j] == "S":\n                    a,b = i,j\n                elif m[i][j] == "B":\n                    c,d = i,j\n        memo.add((a, b, c, d))\n        q += (0,a,b,c,d),\n        while q:\n            t, x, y, bx, by = heapq.heappop(q)\n            for d in de:\n                nx, ny = x + d[0], y + d[1]\n                if 0 <= nx < rl and 0 <= ny < cl:\n                    nbx, nby = bx + d[0], by + d[1]\n                    if nx == bx and ny == by and 0 <= nbx < rl and 0 <= nby < cl and m[nbx][nby] != "#" and (nx, ny, nbx, nby) not in memo:\n                        if nbx == tx and nby == ty:\n                            return t + 1\n                        memo.add((nx, ny, nbx, nby))\n                        heapq.heappush(q, (t + 1, nx, ny, nbx, nby))\n                    elif m[nx][ny] != "#" and (nx, ny, bx, by) not in memo:\n                        memo.add((nx, ny, bx, by))\n                        heapq.heappush(q, (t, nx, ny, bx, by))\n        return -1
[]