Pair of Touching Circle

Given a rectangular grid of height H and width W. A problem setter wants to draw a pair of circles inside the rectangle so that they touch each other but do not share common area and both the circles are completely inside the rectangle. As the problem setter does not like precision he also wants their centers on integer coordinates and their radii to be positive integers as well. How many different ways can he draw such pair of circles? Two drawings are different from each other if any of the circles has different center location or radius. Input The first line of input contains the number of test cases T (T ≤ 500). Each of the next T lines will contain two integers H and W (0 < H, W ≤ 1000). Output For each line of input output the case number and the number of ways of drawing such pairs of circles maintaining the mentioned constraints. See sample output for exact formatting. The output will fit into 64-bit signed integer. Illustration of case 3: Sample Input 5 42 43 44 46 10 10

2/2 Sample Output Case 1: 1 Case 2: 2 Case 3: 6 Case 4: 16 Case 5: 496