#include <bits/stdc++.h>
const int MAX_N = 4010;
const long long int M = 1000 * 1000 * 1000 + 7;
int gcd[MAX_N][MAX_N];
long long int d[16];
void precalc(long long int X, long long int Y) {
  for (int a = 0; a < MAX_N; ++a) {
    gcd[0][a] = gcd[a][0] = a;
  }
  for (int a = 1; a < MAX_N; ++a) {
    gcd[a][a] = a;
    for (int b = a + 1; b < MAX_N; ++b) {
      gcd[a][b] = gcd[b][a] = gcd[b % a][a];
    }
  }
  for (int mask = 0; mask < 16; ++mask) {
    int rx0 = (mask >> 0) & 1;
    int ry0 = (mask >> 1) & 1;
    int rx1 = (mask >> 2) & 1;
    int ry1 = (mask >> 3) & 1;
    long long int cnt = ((X + 2 - rx0) / 2) * ((X + 2 - rx1) / 2) *
                        ((Y + 2 - ry0) / 2) * ((Y + 2 - ry1) / 2);
    d[mask] = cnt % M;
  }
}
int main() {
  int X, Y;
  scanf("%d %d", &X, &Y);
  precalc(X, Y);
  long long int ans = 0;
  for (int x = 0; x <= X; ++x)
    for (int y = 0; y <= Y; ++y) {
      for (int mask = 0; mask < 16; ++mask) {
        int rx0 = (mask >> 0) & 1;
        int ry0 = (mask >> 1) & 1;
        int rx1 = (mask >> 2) & 1;
        int ry1 = (mask >> 3) & 1;
        int s = ((x ^ rx0) & (y ^ ry1)) ^ ((x ^ rx1) & (y ^ ry0));
        if ((s & 1) == 0) {
          ans += d[mask];
        }
      }
      if (x == 0 && y == 0) {
        ans = (ans + M - (X + 1) * (Y + 1)) % M;
      } else {
        long long int sub = ((long long int)((X - x + 1) * (Y - y + 1))) *
                            ((gcd[x][y] + 1 - 2) * 6 + 6);
        if (x != 0 && y != 0) {
          sub <<= 1;
        }
        sub %= M;
        ans -= sub;
      }
    }
  ans = (ans % M + M) % M;
  printf("%d", (int)ans);
  return 0;
}

### Prompt

Please provide a CPP coded solution to the problem described below:

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

### Response

```cpp
#include <bits/stdc++.h>
const int MAX_N = 4010;
const long long int M = 1000 * 1000 * 1000 + 7;
int gcd[MAX_N][MAX_N];
long long int d[16];
void precalc(long long int X, long long int Y) {
  for (int a = 0; a < MAX_N; ++a) {
    gcd[0][a] = gcd[a][0] = a;
  }
  for (int a = 1; a < MAX_N; ++a) {
    gcd[a][a] = a;
    for (int b = a + 1; b < MAX_N; ++b) {
      gcd[a][b] = gcd[b][a] = gcd[b % a][a];
    }
  }
  for (int mask = 0; mask < 16; ++mask) {
    int rx0 = (mask >> 0) & 1;
    int ry0 = (mask >> 1) & 1;
    int rx1 = (mask >> 2) & 1;
    int ry1 = (mask >> 3) & 1;
    long long int cnt = ((X + 2 - rx0) / 2) * ((X + 2 - rx1) / 2) *
                        ((Y + 2 - ry0) / 2) * ((Y + 2 - ry1) / 2);
    d[mask] = cnt % M;
  }
}
int main() {
  int X, Y;
  scanf("%d %d", &X, &Y);
  precalc(X, Y);
  long long int ans = 0;
  for (int x = 0; x <= X; ++x)
    for (int y = 0; y <= Y; ++y) {
      for (int mask = 0; mask < 16; ++mask) {
        int rx0 = (mask >> 0) & 1;
        int ry0 = (mask >> 1) & 1;
        int rx1 = (mask >> 2) & 1;
        int ry1 = (mask >> 3) & 1;
        int s = ((x ^ rx0) & (y ^ ry1)) ^ ((x ^ rx1) & (y ^ ry0));
        if ((s & 1) == 0) {
          ans += d[mask];
        }
      }
      if (x == 0 && y == 0) {
        ans = (ans + M - (X + 1) * (Y + 1)) % M;
      } else {
        long long int sub = ((long long int)((X - x + 1) * (Y - y + 1))) *
                            ((gcd[x][y] + 1 - 2) * 6 + 6);
        if (x != 0 && y != 0) {
          sub <<= 1;
        }
        sub %= M;
        ans -= sub;
      }
    }
  ans = (ans % M + M) % M;
  printf("%d", (int)ans);
  return 0;
}

```