Mathematical Curiosity

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given two integers nn and mm. Among the integer pairs (a,b)(a, b) with 0<a<b<n0 < a < b < n, count the pairs for which a2+b2+mab\frac{a^2 + b^2 + m}{ab} is an integer.

Input

The first line holds the number of test cases TT. Each of the next TT lines holds one test case, with nn and mm separated by a space. Both numbers are greater than 00 and at most 100100.

Output

For each test case, print the number of pairs (a,b)(a, b) that satisfy the condition, one per line.