How many ways are there to place a black and a white knight on an N * M chessboard such that they do not attack each other? The knights have to be placed on different squares. A knight can move two squares horizontally and one square vertically (L shaped), or two squares vertically and one square horizontally (L shaped). The knights attack each other if one can reach the other in one move.
The first line contains the number of test cases T. Each of the next T lines contains two integers N and M which is size of matrix.
For each testcase, print the required answer, i.e, number of possible ways to place knights.
1 <= T <= 100
1 <= N, M <= 105
Testcase 1: We can place a black and a white knight in 12 possible ways such that none of them attracts each other.
If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.