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 int mod = 1000000007;
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int w, h;
long long cx[4][4], cy[4][4];
long long f[4];
long long ans = 0;
int main() {
  f[0] = 1;
  f[1] = 2;
  f[2] = 2;
  f[3] = 6;
  int i, j, k, s, l;
  int mix, mxx;
  int smix, smxx;
  memset(cx, 0, sizeof(cx));
  memset(cy, 0, sizeof(cy));
  scanf("%d %d", &w, &h);
  for (i = -w; i <= w; i++) {
    smix = 0;
    smxx = w;
    if (-i > smix) smix = -i;
    if (w - i < smxx) smxx = w - i;
    for (j = -w; j <= w; j++) {
      mix = smix;
      mxx = smxx;
      k = 0;
      if (i == 0) k++;
      if (j == 0) k++;
      if (i == j) k++;
      if (-j > mix) mix = -j;
      if (w - j < mxx) mxx = w - j;
      if (mix <= mxx) {
        s = ((i + 10000) & 1);
        l = ((j + 10000) & 1);
        cx[s][l] += (mxx - mix + 1);
        if (cx[s][l] >= mod) cx[s][l] %= mod;
      }
    }
  }
  ans = 0;
  for (i = -h; i <= h; i++) {
    smix = 0;
    smxx = h;
    if (-i > smix) smix = -i;
    if (h - i < smxx) smxx = h - i;
    for (j = -h; j <= h; j++) {
      mix = smix;
      mxx = smxx;
      k = 0;
      if (i == 0) k++;
      if (j == 0) k++;
      if (i == j) k++;
      if (-j > mix) mix = -j;
      if (h - j < mxx) mxx = h - j;
      if (mix <= mxx) {
        s = ((i + 10000) & 1);
        l = ((j + 10000) & 1);
        cy[s][l] += (mxx - mix + 1);
        if (cy[s][l] >= mod) cy[s][l] %= mod;
      }
    }
  }
  ans = 0;
  for (i = 0; i < 2; i++) {
    for (j = 0; j < 2; j++) {
      for (s = 0; s < 2; s++) {
        for (l = 0; l < 2; l++) {
          if ((i * s + j * l) % 2 == 0) {
            ans += cx[i][j] * cy[s][l];
            if (ans >= mod) ans = ans % mod;
          }
        }
      }
    }
  }
  long long all = (w + 1) * (h + 1);
  all = all * (all - 1);
  if (all >= mod) all = all % mod;
  ans = ans - (3LL * all) % mod + mod;
  if (ans >= mod) ans = ans % mod;
  for (i = 0; i <= w; i++) {
    k = w - i + 1;
    for (j = 0; j <= h; j++) {
      l = h - j + 1;
      s = 0;
      if ((i != 0) || (j != 0)) s = gcd(i, j);
      s++;
      if (i + j == 0) {
        ans = ans - (k * l) % mod + mod;
        if (ans >= mod) ans = ans % mod;
        continue;
      }
      if (ans >= mod) ans = ans % mod;
      if (s > 2) {
        if (i == 0 || j == 0)
          ans = ans - (6LL * (((s - 2) * k) % mod) * l) % mod + mod;
        else {
          ans = ans - (12LL * (((s - 2) * k) % mod) * l) % mod + mod;
        }
      }
      if (ans >= mod) ans = ans % mod;
    }
  }
  printf("%d\n", (int)ans);
  return 0;
}