Server Time: Mon Apr 23, 2018 3:40 am
 Welcome ( logout )
1144 - Ray Gun
 PDF (English) Statistics Forum
 Time Limit: 2 second(s) Memory Limit: 32 MB

You are in an m x n grid. You are standing in position (0, 0) and in each of the other lattice points (points with integer co-ordinates) an enemy is waiting. Now you have a ray gun that can fire up to infinity and no obstacle can stop it. Your target is to kill all the enemies. You have to find the minimum number of times you have to fire to kill all of them. For a 4 x 4 grid you have to fire 13 times. See the picture below:

# Input

Input starts with an integer T (≤ 100), denoting the number of test cases.

Each case contains two integers m, n (0 ≤ m, n ≤ 109) and at least one of them will be less than or equal to 106.

# Output

For each case, print the case number and the minimum number of times you have to fire to kill all the enemies.

# Output for Sample Input

2

4 4

10 10

Case 1: 13

Case 2: 65

Problem Setter: Jane Alam Jan
 Developed and Maintained by JANE ALAM JAN Copyright © 2012 LightOJ, Jane Alam Jan