CT - Counting triangles

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

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

Output

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

Constraints

C ≤ 20
0 ≤ X, Y ≤ 1000

Example

Input:
2
0 3
1 1

Output:
0
4

Added by:sieunhan
Date:2009-11-29
Time limit:0.300s-1.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64 NODEJS OBJC PERL6 SQLITE VB.NET
Resource:Le Don Khue - ACM Vietnam Practice

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.