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 double pi = acos(0) * 2;
template <class T>
inline T abs1(T a) {
  return a < 0 ? -a : a;
}
template <class T>
inline T max1(T a, T b) {
  return a > b ? a : b;
}
template <class T>
inline T min1(T a, T b) {
  return a < b ? a : b;
}
template <class T>
inline T gcd1(T a, T b) {
  if (a < b) swap(a, b);
  if (a % b == 0) return b;
  return gcd1(b, a % b);
}
const long long mod = 1000000007;
int w, h;
long long ans = 1;
int main() {
  scanf("%d%d", &w, &h);
  if (min1(w, h) < 1) {
    printf("0\n");
    return 0;
  }
  for (int i = 0; i < 3; i++) {
    ans *= (w + 1) * (h + 1);
    ans %= mod;
  }
  w++;
  h++;
  long long oddandeven[2], doubleodd[2][2];
  oddandeven[0] = (w * h) / 2;
  oddandeven[1] = w * h - oddandeven[0];
  doubleodd[0][0] = (w / 2) * (h / 2);
  doubleodd[0][1] = (w / 2) * (h - h / 2);
  doubleodd[1][0] = (w - w / 2) * (h / 2);
  doubleodd[1][1] = (w - w / 2) * (h - h / 2);
  for (int i = 0; i < w; i++)
    for (int j = 0; j < h; j++) {
      ans -= (((oddandeven[(i + j) % 2] * doubleodd[i % 2][j % 2]) % mod) * 3) %
             mod;
      while (ans < 0) ans += mod;
    }
  long long k = 1;
  k *= w * (w - 1) / 2;
  k *= (w - 2);
  k /= 3;
  k *= h;
  k %= mod;
  ans -= (k * 6) % mod;
  while (ans < 0) ans += mod;
  k = 1;
  k *= h * (h - 1) / 2;
  k *= (h - 2);
  k /= 3;
  k *= w;
  k %= mod;
  ans -= (k * 6) % mod;
  while (ans < 0) ans += mod;
  w--;
  h--;
  for (int i = 1; i <= w; i++)
    for (int j = 1; j <= h; j++) {
      long long k = gcd1(i, j) - 1;
      k *= (w - i + 1) * (h - j + 1);
      k %= mod;
      k *= 12;
      k %= mod;
      ans -= k;
      while (ans < 0) ans += mod;
    }
  ans -= (w + 1) * (h + 1);
  while (ans < 0) ans += mod;
  k = 1;
  k *= (w + 1) * (h + 1);
  k *= (w + 1) * (h + 1) - 1;
  k *= 3;
  k %= mod;
  ans -= k;
  while (ans < 0) ans += mod;
  printf("%I64d\n", ans);
  return 0;
}