#include <bits/stdc++.h>
const long long Mod = 1000000007LL;
long long a[2][2];
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long C2(long long n) {
  long long res = n * (n - 1) / 2;
  return res % Mod;
}
long long C3(long long n) {
  long long a = n, b = n - 1, c = n - 2;
  if (a % 2 == 0)
    a /= 2;
  else
    b /= 2;
  if (a % 3 == 0)
    a /= 3;
  else if (b % 3 == 0)
    b /= 3;
  else
    c /= 3;
  long long res = (a * b) % Mod;
  res = (res * c) % Mod;
  return res;
}
int main() {
  int w, h;
  long long zero = 0;
  scanf("%d%d", &w, &h);
  for (int i = 0; i <= w; ++i) {
    for (int j = 0; j <= h; ++j) {
      a[i % 2][j % 2]++;
      long long t = gcd(i, j);
      if (t > 1) {
        zero += (long long)(w - i + 1) * (h - j + 1) * (t - 1) *
                (i > 0 && j > 0 ? 2 : 1);
        zero %= Mod;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) ans += C3(a[i][j]);
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      for (int ii = 0; ii < 2; ++ii)
        for (int jj = 0; jj < 2; ++jj) {
          if (i != ii || j != jj) {
            long long t = a[i][j] * C2(a[ii][jj]);
            ans += t % Mod;
          }
        }
  ans %= Mod;
  ans = (ans - zero + Mod) % Mod;
  ans = (6 * ans) % Mod;
  std::cout << ans << std::endl;
  return 0;
}

### Prompt

Please formulate a cpp solution to the following 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

### Response

```cpp
#include <bits/stdc++.h>
const long long Mod = 1000000007LL;
long long a[2][2];
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
long long C2(long long n) {
  long long res = n * (n - 1) / 2;
  return res % Mod;
}
long long C3(long long n) {
  long long a = n, b = n - 1, c = n - 2;
  if (a % 2 == 0)
    a /= 2;
  else
    b /= 2;
  if (a % 3 == 0)
    a /= 3;
  else if (b % 3 == 0)
    b /= 3;
  else
    c /= 3;
  long long res = (a * b) % Mod;
  res = (res * c) % Mod;
  return res;
}
int main() {
  int w, h;
  long long zero = 0;
  scanf("%d%d", &w, &h);
  for (int i = 0; i <= w; ++i) {
    for (int j = 0; j <= h; ++j) {
      a[i % 2][j % 2]++;
      long long t = gcd(i, j);
      if (t > 1) {
        zero += (long long)(w - i + 1) * (h - j + 1) * (t - 1) *
                (i > 0 && j > 0 ? 2 : 1);
        zero %= Mod;
      }
    }
  }
  long long ans = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j) ans += C3(a[i][j]);
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      for (int ii = 0; ii < 2; ++ii)
        for (int jj = 0; jj < 2; ++jj) {
          if (i != ii || j != jj) {
            long long t = a[i][j] * C2(a[ii][jj]);
            ans += t % Mod;
          }
        }
  ans %= Mod;
  ans = (ans - zero + Mod) % Mod;
  ans = (6 * ans) % Mod;
  std::cout << ans << std::endl;
  return 0;
}

```