Codeforces Round 136 (Div. 1)
D
Little Elephant and Triangle
Codeforces
2500
原题
← CE →
翻译中…

The Little Elephant is playing with the Cartesian coordinates' system. Most of all he likes playing with integer points. The Little Elephant defines an integer point as a pair of integers $(*x*; *y*)$, such that $0 ≤ *x* ≤ *w*$ and $0 ≤ *y* ≤ *h*$. Thus, the Little Elephant knows only $(*w* + 1)·(*h* + 1)$ distinct integer points.

翻译中…

The Little Elephant wants to paint a triangle with vertexes at integer points, the triangle's area must be a positive integer. For that, he needs to find the number of groups of three points that form such triangle. At that, the order of points in a group matters, that is, the group of three points $(0;0)$, $(0;2)$, $(2;2)$ isn't equal to the group $(0;2)$, $(0;0)$, $(2;2)$.

翻译中…

Help the Little Elephant to find the number of groups of three integer points that form a nondegenerate triangle with integer area.

翻译中…

Input

翻译中…

A single line contains two integers $*w*$ and $*h*$ $(1 ≤ *w*, *h* ≤ 4000)$.

翻译中…

Output

翻译中…

In a single output line print an integer — the remainder of dividing the answer to the problem by $1000000007$ $(10^{9} + 7)$.

翻译中…

样例

Input #1
2 1
Output #1
36
InputCopy OutputCopy
Input #2
2 2
Output #2
240
InputCopy OutputCopy
题目信息
题号
220D
时间限制
3 s
内存限制
256 MB
标签
计算几何
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。