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 long mod = 1000000007LL;
int g[4020][4020];
long long modMinus(long long a, long long b) {
  long long ret = a - b;
  if (ret < 0) ret += mod;
  return ret;
}
long long modAdd(long long a, long long b) {
  long long ret = a + b;
  if (ret >= mod) ret -= mod;
  return ret;
}
int main() {
  long long w, h;
  long long ans = 0, x[2], y[2];
  ios::sync_with_stdio(0);
  cin >> w >> h;
  x[0] = (w >> 1) + 1;
  x[1] = w + 1 - x[0];
  y[0] = (h >> 1) + 1;
  y[1] = h + 1 - y[0];
  for (int i = 0; i <= w; i++)
    for (int j = 0; j <= h; j++) {
      if (i && j)
        g[i][j] = i > j ? g[i - j][j] : g[i][j - i];
      else
        g[i][j] = i + j;
    }
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k < 16; k++) {
        int x1 = ((k >> 3) & 1);
        int y1 = ((k >> 2) & 1);
        int x2 = ((k >> 1) & 1);
        int y2 = (k & 1);
        if (abs((i - x1) * (j - y2) + (x2 - i) * (j - y1)) % 2 == 0) {
          long long tmp =
              x[i] * y[j] * x[x1] % mod * x[x2] * y[y1] * y[y2] % mod;
          ans = modAdd(ans, tmp);
        }
      }
  ans = modMinus(ans, (w + 1) * (h + 1));
  for (int dx = 0; dx <= w; dx++)
    for (int dy = 0; dy <= h; dy++)
      if (dx + dy != 0) {
        int num = g[dx][dy] + 1;
        if (num == 2) {
          if (dx == 0 || dy == 0)
            ans = modMinus(ans, 6 * (w - dx + 1) * (h - dy + 1));
          else
            ans = modMinus(ans, 12 * (w - dx + 1) * (h - dy + 1));
        } else {
          if (dx == 0 || dy == 0)
            ans = modMinus(ans,
                           6 * (w - dx + 1) * (h - dy + 1) * (num - 1) % mod);
          else
            ans = modMinus(ans,
                           12 * (w - dx + 1) * (h - dy + 1) * (num - 1) % mod);
        }
      }
  printf("%d\n", (int)ans);
  return 0;
}