Mark loves watching the Zamboni clean the ice at his local rink. In particular, he's intrigued by the spiral path the Zamboni takes. The Zamboni starts in the top-left corner of the rectangular rink and follows the longer edge of the rink. Just before it reaches a wall or a previously-cleaned square, it turns 90 degrees clockwise and repeats the process until the rink is entirely clean. Mark wants your help to figure out how many times the Zamboni turns during its path.
Input Specification
The first line of input provides the number of test cases, . test cases follow. Each test case consists of one line containing two integers and , the height and width of the ring. The Zamboni is one unit wide.
Output Specification
For each test case, your program should output one integer, the amount of turns the Zamboni makes.
Sample Input
2
3 5
4 4
Sample Output
4
6
Explanation for Sample Input
In the first test case, the Zamboni takes the following path:
Comments