SP5464 CT - Counting triangles

Description

Consider a 2D integer grid with lower left corner at (0, 0) and upper right corner at (X, Y). We are interested in isosceles right triangles which all the 3 corners at the grid node (integer coordinates). Your task is to count the number of those triangles.

Input Format

The input begins with C – number of test cases. Each test case consists of X, Y.

Output Format

For each test case, output the result in a line.