Consider all lattice points in an grid, where and .
A lattice point is black if , and white if .
Choose three distinct points . If the three points are collinear, they do not form a triangle and are not counted.
Let be the area of the parallelogram formed by the vector from to and the vector from to .
If the three points all have the same color and is prime, then these three points are called a good triangle.
For given , find the number of good triangles. A triangle is considered as a set of three points, so choices that differ only by the order of the same three points are counted once.
Print the answer modulo .
Input
The input is given in the following format.
is the number of test cases.
Output
For each test case, print the number of good triangles modulo on a separate line.
Constraints
- .
- ().
- ().
- .
Subtasks
Samples
In a grid, it is impossible to choose three points of the same color.
There are good triangles in a grid, and good triangles in a grid.