


1. There are multiple possible orders in which a knight can visit each cell of the chessboard exactly once. You can find any valid order.
2. It may be possible that there is no possible order to visit each cell exactly once. In that case, return a matrix having all the values equal to -1.
Consider an 8*8 chessboard, one possible order for visiting each cell exactly once is shown in the image below. Numbers in cells indicate the move number of the Knight.

The first line of input contains an integer ‘T’ denoting the number of test cases.
The next T lines represent the ‘T’ test cases.
The first line of each test case contains two space-separated integers ‘N’ and ‘M’ representing the number of rows and columns in the chessboard respectively.
For each test case, In a separate line print ‘Possible’ If knight tour exist otherwise print ’Impossible’
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N, M <= 8
Where ‘T’ is the total number of test cases, ‘N’, ‘M’ is the number of rows and columns respectively.
Time limit: 1 sec
There are N*M cells in the chessboard thus, we can assign a unique integer between 0 to N*M-1 to each cell in (N*M)! Ways. For each of these ways, we will check whether it represents a possible knight tour or not. We can one by one generate all the permutations using the nextPermuation method as described below.
In this approach, we incrementally build the solution. In each step we check if moving to this cell violates the problem constraint, if it does then we remove that move and try other alternatives. If none of the alternatives works out then we go to the previous stage and remove the moves in the previous stages. If we reach the initial stage back then we say that no solution exists.
Pair Product Div by K
Pair Product Div by K
Merge Two Sorted Arrays Without Extra Space
Merge Two Sorted Arrays Without Extra Space
Co-Prime
First Digit One
Special Digit Numbers