I passed CET-4
Time Limit: 1000 ms Memory Limit: 65536 KiB
There are many trees forming a m * n grid, the grid starts from (1,1). Farmer is standing at (0,0) point. He wonders how many trees he can see.
If two trees and Farmer are in one line, Farmer can only see the tree nearest to him.
The first line contains one integer t, represents the number of test cases. Then there are multiple test cases. For each test case there is one line containing two integers m and n(1 ≤ m, n ≤ 100000)
For each test case output one line represents the number of trees Farmer Sherlock can see.
2 1 1 2 3