
The character ‘P’ represents the player. The player can move only in four directions, up, down, left, and right only if the is a floor.
The character ‘T’ represents the target location.
The character ‘B’ represents the box. There is only one box in the grid. The player can not move through the box.
The character ‘.’ represents the floor which means a free cell to walk.
The character ‘|’ represents the wall which means an obstacle.
You are given grid = [["|","|","|","|","|","|"],
["|","T",".","B",".","|"],
["|",".","|","|",".","|"],
["|",".",".",".","S","|"],
["|","|","|","|","|","|"]]
The answer will be 2. The player has to push the box two times to move it to the target location.

The first line contains an integer 'C' which denotes the number of test cases.
The first line of each test case contains two space-separated integers, ‘M’ and ‘N’, representing the number of rows and columns, respectively.
The next ‘M’ line contains ‘N’ space-separated integers representing the ‘GRID’.
For each test case, print a single integer, denoting the minimum number of pushes required to move the box to the target location.
The output of each test case will be printed in a separate line.
1 <= C <= 10
1 <= M, N <= 20
GRID contains only characters ‘P’, ‘T’, ‘B’, ‘|’, or ‘.’.
There is only one character, ‘P’, ‘T’, and ‘B’ in the GRID.
Time limit: 1 sec
You do not need to input or print anything, as it has already been taken care of. Just implement the given function.
As we already know, the BFS can be used to find the shortest path from a source location to the target location. But that is not enough to solve this problem because we can move a box only if the player is in the opposite adjacent cell to the cell where we have to move the box. For example, if we have to move the box up the player should be below the box. So, to overcome this, we will initialize a queue that will store the state of the box and the player. Then for each state, we will check if the target location is reachable or not using another BFS.
Structure of graph created: Any vertice V denotes a game state and edge E denotes transition between states.
Algorithm: