Counting Triangles

Triangles are polygons with three sides and strictly positive area. Lattice triangles are the triangles all whose vertexes have integer coordinates. In this problem you have to find the number of lattice triangles in an M × N grid. For example in a (1 × 2) grid there are 18 different lattice triangles as shown in the picture below: Input The input file contains at most 21 sets of inputs. Each set of input consists of two integers M and N (0 < M, N ≤ 1000). These two integers denote that you have to count triangles in an (M × N ) grid. Input is terminated by a case where the value of M and N are zero. This case should not be processed. Output For each set of input produce one line of output. This output contains the serial of output followed by the number lattice triangles in the (M × N ) grid. You can assume that number of triangles will fit in a 64-bit signed integer. Sample Input 11 12 00 Sample Output Case 1: 4 Case 2: 18