#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
using namespace std;
const int maxn = 80001;
const int mod = 1000000007;
bool is0(int x1, int y1, int x2, int y2, int x3, int y3) {
  return ~(~x1 | ~(y2 ^ y3)) ^ ~(~x2 | ~(y1 ^ y3)) ^ ~(~x3 | ~(y2 ^ y1)) == 0;
}
unsigned long long gcd(int a, int b) {
  while (a && b)
    if (a > b)
      a %= b;
    else
      b %= a;
  return a + b;
}
int main() {
  unsigned long long w, h;
  cin >> w >> h;
  unsigned long long cnt[2][2];
  unsigned long long result = 0;
  cnt[0][0] = ((w / 2 + 1ll) * (h / 2 + 1ll) % mod);
  cnt[0][1] = (w / 2 + 1ll) * (h / 2 + (h & 1ll)) % mod;
  cnt[1][0] = (w / 2 + (w & 1ll)) * (h / 2 + 1ll) % mod;
  cnt[1][1] = (w / 2 + (w & 1ll)) * (h / 2 + (h & 1ll)) % mod;
  for (int p1 = (0); p1 < (4); p1++)
    for (int p2 = (p1); p2 < (4); p2++)
      for (int p3 = (p2); p3 < (4); p3++) {
        if (p1 == p2 && p2 == p3) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p1 >> 1][p1 & 1] * (cnt[p1 >> 1][p1 & 1] - 1ll)) % mod) *
                 (cnt[p1 >> 1][p1 & 1] - 2)) %
                mod,
                result %= mod;
        } else if (p1 == p2) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p1 >> 1][p1 & 1] * (cnt[p1 >> 1][p1 & 1] - 1ll)) % mod) *
                 cnt[p3 >> 1][p3 & 1] * 3) %
                mod,
                result %= mod;
        } else if (p1 == p3) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p1 >> 1][p1 & 1] * (cnt[p1 >> 1][p1 & 1] - 1ll)) % mod) *
                 cnt[p2 >> 1][p2 & 1] * 3) %
                mod,
                result %= mod;
        } else if (p2 == p3) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p2 >> 1][p2 & 1] * (cnt[p2 >> 1][p2 & 1] - 1ll)) % mod) *
                 cnt[p1 >> 1][p1 & 1] * 3) %
                mod,
                result %= mod;
        } else {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result += (((cnt[p2 >> 1][p2 & 1] * cnt[p1 >> 1][p1 & 1]) % mod) *
                       cnt[p3 >> 1][p3 & 1]) %
                      mod,
                result %= mod;
        }
      }
  unsigned long long imp = 0;
  for (int i = (0); i < (w + 1); i++)
    for (int j = (0); j < (h + 1); j++) {
      if (i == j && i == 0) continue;
      unsigned long long count = ((w + 1 - i) * (h + 1 - j)) % mod;
      if (i != 0 && j != 0) count *= 2, count %= mod;
      imp += (count * (gcd(i, j) - 1) * 6) % mod;
      imp %= mod;
    }
  cout << (result + mod - imp) % mod << endl;
}

### Prompt

Construct a CPP code solution to the problem outlined:

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>
#pragma comment(linker, "/stack:200000000")
using namespace std;
const int maxn = 80001;
const int mod = 1000000007;
bool is0(int x1, int y1, int x2, int y2, int x3, int y3) {
  return ~(~x1 | ~(y2 ^ y3)) ^ ~(~x2 | ~(y1 ^ y3)) ^ ~(~x3 | ~(y2 ^ y1)) == 0;
}
unsigned long long gcd(int a, int b) {
  while (a && b)
    if (a > b)
      a %= b;
    else
      b %= a;
  return a + b;
}
int main() {
  unsigned long long w, h;
  cin >> w >> h;
  unsigned long long cnt[2][2];
  unsigned long long result = 0;
  cnt[0][0] = ((w / 2 + 1ll) * (h / 2 + 1ll) % mod);
  cnt[0][1] = (w / 2 + 1ll) * (h / 2 + (h & 1ll)) % mod;
  cnt[1][0] = (w / 2 + (w & 1ll)) * (h / 2 + 1ll) % mod;
  cnt[1][1] = (w / 2 + (w & 1ll)) * (h / 2 + (h & 1ll)) % mod;
  for (int p1 = (0); p1 < (4); p1++)
    for (int p2 = (p1); p2 < (4); p2++)
      for (int p3 = (p2); p3 < (4); p3++) {
        if (p1 == p2 && p2 == p3) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p1 >> 1][p1 & 1] * (cnt[p1 >> 1][p1 & 1] - 1ll)) % mod) *
                 (cnt[p1 >> 1][p1 & 1] - 2)) %
                mod,
                result %= mod;
        } else if (p1 == p2) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p1 >> 1][p1 & 1] * (cnt[p1 >> 1][p1 & 1] - 1ll)) % mod) *
                 cnt[p3 >> 1][p3 & 1] * 3) %
                mod,
                result %= mod;
        } else if (p1 == p3) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p1 >> 1][p1 & 1] * (cnt[p1 >> 1][p1 & 1] - 1ll)) % mod) *
                 cnt[p2 >> 1][p2 & 1] * 3) %
                mod,
                result %= mod;
        } else if (p2 == p3) {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result +=
                (((cnt[p2 >> 1][p2 & 1] * (cnt[p2 >> 1][p2 & 1] - 1ll)) % mod) *
                 cnt[p1 >> 1][p1 & 1] * 3) %
                mod,
                result %= mod;
        } else {
          if (is0(p1 >> 1, p1 & 1, p2 >> 1, p2 & 1, p3 >> 1, p3 & 1))
            result += (((cnt[p2 >> 1][p2 & 1] * cnt[p1 >> 1][p1 & 1]) % mod) *
                       cnt[p3 >> 1][p3 & 1]) %
                      mod,
                result %= mod;
        }
      }
  unsigned long long imp = 0;
  for (int i = (0); i < (w + 1); i++)
    for (int j = (0); j < (h + 1); j++) {
      if (i == j && i == 0) continue;
      unsigned long long count = ((w + 1 - i) * (h + 1 - j)) % mod;
      if (i != 0 && j != 0) count *= 2, count %= mod;
      imp += (count * (gcd(i, j) - 1) * 6) % mod;
      imp %= mod;
    }
  cout << (result + mod - imp) % mod << endl;
}

```