Counting Lattice Squares

A lattice square is a square whose vertices are all lattice points. A lattice-point is a point in Cartesian coordinate system whose abscissa and ordinate are integers. For ex- ample (1, 5) is a lattice point but (1, 1.5) is not. In a (n×m) grid there can be many lattice squares. In the figure on the left you can see some lattice squares in a (4×4) grid. Counting lattice squares with axis-parallel sides (Figure 1, Figure 2 and Figure 3) is trivial but there are lattice squares whose sides are not axis parallel (Figure 4, Figure 5 and Figure 6) and counting them is just a bit harder. Some of these squares can have even area (Figure 2, Figure 4, Figure 6) and some others can have odd area (Figure 1, Figure 3, Figure 5). Given an (m × n) grid your job is to write a program that counts how many different lattice squares with odd area can be drawn in that grid. Two lattice squares are different if they do not share all four vertices. Input The input file contains at most 50000 lines of inputs. Each line contains two integers m, n (1 ≤ m, n ≤ 100000). Input is terminated by a line containing two zeroes. Output For each line of input produce one line of output. This line contains an integer S, which denotes how many different lattice squares with odd area can be drawn in an (m × n) grid. You can assume that the value of S fits in a 64-bit signed integer. Sample Input 22 33 44 00 Sample Output 4 12 28