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(-1.0);
const int intmax = 0x3f3f3f3f;
const long long lldmax = 0x3f3f3f3f3f3f3f3fll;
double eps = 1e-6;
template <class T>
inline void checkmin(T &a, T b) {
  if (b < a) a = b;
}
template <class T>
inline void checkmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline T sqr(T x) {
  return x * x;
}
template <class T>
inline T lowbit(T n) {
  return (n ^ (n - 1)) & n;
}
template <class T>
inline int countbit(T n) {
  return (n == 0) ? 0 : (1 + countbit(n & (n - 1)));
}
template <class T>
inline T checkmod(T n, T m) {
  return (n % m + m) % m;
}
inline int rand(int a, int b) {
  if (a >= b) return a;
  return rand() % (b - a) + a;
}
template <class T>
inline T lcm(T a, T b) {
  if (a < 0) return lcm(-a, b);
  if (b < 0) return lcm(a, -b);
  return a * (b / gcd(a, b));
}
template <class T>
inline T euclid(T a, T b, T &x, T &y) {
  if (a < 0) {
    T d = euclid(-a, b, x, y);
    x = -x;
    return d;
  }
  if (b < 0) {
    T d = euclid(a, -b, x, y);
    y = -y;
    return d;
  }
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  } else {
    T d = euclid(b, a % b, x, y);
    T t = x;
    x = y;
    y = t - (a / b) * y;
    return d;
  }
}
template <class T>
inline vector<pair<T, int> > factorize(T n) {
  vector<pair<T, int> > R;
  for (T i = 2; n > 1;) {
    if (n % i == 0) {
      int C = 0;
      for (; n % i == 0; C++, n /= i)
        ;
      R.push_back(make_pair(i, C));
    }
    i++;
    if (i > n / i) i = n;
  }
  if (n > 1) R.push_back(make_pair(n, 1));
  return R;
}
template <class T>
inline bool isPrimeNumber(T n) {
  if (n <= 1) return false;
  for (T i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
template <class T>
inline T eularFunction(T n) {
  vector<pair<T, int> > R = factorize(n);
  T r = n;
  for (int i = 0; i < R.size(); i++) r = r / R[i].first * (R[i].first - 1);
  return r;
}
template <class T>
inline int dblcmp(T a, const T b) {
  a -= b;
  return a > eps ? 1 : (a < -eps ? -1 : 0);
}
template <class T>
inline int sgn(T a) {
  return a > eps ? 1 : (a < -eps ? -1 : 0);
}
struct vec2 {
  double x, y;
  vec2(double x = 0.0, double y = 0.0) : x(x), y(y) {}
  vec2 operator+(const vec2 &b) const { return vec2(x + b.x, y + b.y); }
  vec2 operator-(const vec2 &b) const { return vec2(x - b.x, y - b.y); }
  vec2 operator*(const double &b) const { return vec2(x * b, y * b); }
  vec2 operator/(const double &b) const { return vec2(x / b, y / b); }
  double operator*(const vec2 &b) const { return x * b.x + y * b.y; }
  double operator^(const vec2 &b) const { return x * b.y - y * b.x; }
  double len() { return sqrt(x * x + y * y); }
  vec2 unit() { return *this / len(); }
  vec2 rotate(double r) {
    vec2 t(sin(r), cos(r));
    return vec2(*this ^ t, *this * t);
  }
  bool operator<(const vec2 &b) const {
    if (dblcmp(x, b.x) != 0)
      return dblcmp(x, b.x) < 0;
    else
      return dblcmp(y, b.y) < 0;
  }
};
const int N = 5000;
const long long P = 1000000007;
long long cnt[2][2];
int gcd[N][N];
int main() {
  int h, w;
  scanf("%d%d", &h, &w);
  long long ans = 0;
  for (int i = (0); i < (2); ++i)
    for (int j = (0); j < (2); ++j)
      cnt[i][j] = (h / 2 + 1 - (h + 1) * i % 2) * (w / 2 + 1 - (w + 1) * j % 2);
  for (int a = (0); a < (2); ++a)
    for (int b = (0); b < (2); ++b)
      for (int c = (0); c < (2); ++c)
        for (int d = (0); d < (2); ++d)
          for (int e = (0); e < (2); ++e)
            for (int f = (0); f < (2); ++f) {
              if (checkmod((a - c) * (b - f) - (b - d) * (a - e), 2) == 0) {
                ans += cnt[a][b] * cnt[c][d] % P * cnt[e][f] % P;
                ans %= P;
              }
            }
  long long zero = 0;
  long long tot = (h + 1) * (w + 1);
  for (int i = 0; i <= h; ++i)
    for (int j = 0; j <= w; ++j) {
      if (i == 0) {
        gcd[i][j] = j;
      } else if (j == 0) {
        gcd[i][j] = i;
      } else if (i <= j) {
        gcd[i][j] = gcd[i][j - i];
      } else {
        gcd[i][j] = gcd[i - j][j];
      }
    }
  zero += tot;
  zero += tot * (tot - 1) * 3 % P;
  zero += tot * (h * (h - 1) + w * (w - 1)) % P;
  for (int i = 2; i <= h; ++i)
    for (int j = 2; j <= w; ++j) {
      if (gcd[i][j] == 1) continue;
      zero +=
          ((long long)h + 1 - i) * (w + 1 - j) % P * (gcd[i][j] - 1) * 12 % P;
      zero %= P;
    }
  cout << checkmod(ans - zero, P) << endl;
  return 0;
}