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.
The first line of input provides the number of test cases, \(T\ (1 \le T \le 100)\). \(T\) test cases follow. Each test case consists of one line containing two integers \(H\) and \(W\ (1 \le H,W \le 100)\), the height and width of the ring. The Zamboni is one unit wide.
For each test case, your program should output one integer, the amount of turns the Zamboni makes.
2 3 5 4 4
Explanation for Sample Input
In the first test case, the Zamboni takes the following path: