#ITRIXE. THE BLACK AND WHITE QUEENS
THE BLACK AND WHITE QUEENS
Subru and Shanmu are playing Chess. Shanmu wonder about queens. So he asked Subru the following question
“How many ways are there to place a black and a white Queen on an M × N chessboard such that they do not attack each other? The queen can be moved any number of unoccupied squares in a straight line vertically, horizontally, or diagonally.”
Subru gave the answer in seconds for a given chess board of size M × N (M ≤ N). Can you repeat the same with your code?
Input
The first line contains the integer “t” which indicates the number of test cases. Each of the following t lines contains two integers M and N separated by spaces (M ≤ N).
Output
Output for each case consists of one line: The number of ways of placing a black and a white queen on a M × N chess board such that they do not attack each other.
Constraints
T ≤ 10000, 2 ≤ M ≤ 1010, 2 ≤ N ≤ 1010. and M ≤ N.
Input: 3 5 5 3 4 2 2</p>Output: 280 40 0