Problem: 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 (109 + 7).

Examples

Input

2 1


Output

36


Input

2 2


Output

240

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const long mod = 1000000007;
long w, h;
long gcd[4005][4005] = {0};
long calc(long &i, long &j, long &x1, long &y1) {
  long p1, p2;
  if (((i + x1) & 1) == 0)
    p1 = (w + 2) >> 1;
  else
    p1 = (w + 1) >> 1;
  p2 = (h - j + y1) >> 1;
  return p1 * p2;
}
int main() {
  long i, j;
  long x1, y1, x2, y2;
  long long ans = 0;
  long tmp;
  scanf("%ld%ld", &w, &h);
  for (i = 0; i <= w; i++)
    for (j = 0; j <= h; j++) {
      ans += (long long)(w - i) / 2 * (h - j) * (w + 1);
      ans += (long long)(w - i + 1) / 2 * ((h - j) / 2) * (w + 1);
      for (x1 = 0; x1 <= 1; x1++)
        for (y1 = 0; y1 <= 1; y1++) {
          register long t1, t2;
          t1 = calc(i, j, x1, y1);
          ans += (long long)t1 * (t1 - 1) >> 1;
          for (x2 = x1; x2 <= 1; x2++)
            for (y2 = x1 == x2 ? y1 + 1 : 0; y2 <= 1; y2++)
              if (((x1 * y2 - x2 * y1) & 1) == 0) {
                t1 = calc(i, j, x1, y1);
                t2 = calc(i, j, x2, y2);
                ans += (long long)t1 * t2;
              }
        }
      ans %= mod;
    }
  for (i = 1; i <= 4000; i++) {
    gcd[i][0] = i;
    for (j = 1; j <= i; j++) gcd[i][j] = gcd[j][i % j];
  }
  for (i = 1; i <= 4000; i++)
    for (j = i + 1; j <= 4000; j++) gcd[i][j] = gcd[j][i];
  for (i = 1; i <= w; i++)
    for (j = 1; j <= h; j++) {
      ans -= (long long)(w + 1 - i) * (h + 1 - j) * (gcd[i][j] - 1) * 2 % mod;
      ans += mod;
      ans %= mod;
    }
  ans -= (long long)(w + 1) * h * (h + 1) * (h - 1) / 6 % mod;
  ans += mod;
  ans %= mod;
  printf("%I64d\n", ans * 6 % mod);
  return 0;
}