#P3636. 曲面
曲面
Description
We know that the graph of the inverse proportional function is a hyperbola.

xht then wondered: what would it look like if we extend it to three dimensions?
Define the surface as the surface determined by the equation .
Define the aesthetic value of the surface as the sum of the squares of the Manhattan distances to the origin of all lattice points (points whose , , and coordinates are all integers) on .
(The Manhattan distance from to the origin is .)
Now, xht arranges the surfaces in a row. You are required to compute the sum of their aesthetic values, that is , modulo .
Input Format
One line containing two positive integers , .
Output Format
One line containing a single integer.

3 3
300
64 19260817
9932
Hint
Explanation of Sample 1:
On the surface , there are lattice points: , , , , , , , , , , , . The sum of the squares of their Manhattan distances to the origin is .
Constraints:
- For of the testdata, .
- For another of the testdata, .
- For of the testdata, .
Translated by ChatGPT 5
京公网安备 11011102002149号