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;
int w, h;
const int mod = 1000000007;
long long sum = 0;
long long choose3[4005];
long long num(int m, int n) {
  long long s00 = ((m + 1) / 2) * ((n + 1) / 2) - 1;
  long long s01 = (m / 2) * ((n + 1) / 2);
  long long s10 = ((m + 1) / 2) * (n / 2);
  long long s11 = (m / 2) * (n / 2);
  long long s = m * n - 1;
  long long tot =
      s00 * s + s01 * (s00 + s01) + s10 * (s00 + s10) + s11 * (s00 + s11);
  tot -= s;
  tot /= 2;
  return tot % mod;
}
long long right(int m, int n) {
  long long modd = (m / 2) * ((m + 1) / 2);
  long long nodd = (n / 2) * ((n + 1) / 2);
  long long meven = m * (m + 1) / 2 - modd;
  long long neven = n * (n + 1) / 2 - nodd;
  long long tot = (neven + nodd) * (meven + modd) - nodd * modd;
  tot %= mod;
  tot *= 4;
  return tot % mod;
}
long long parallel(int m, int n) {
  long long modd = (m / 2) * ((m + 1) / 2);
  long long nodd = (n / 2) * ((n + 1) / 2);
  long long meven = m * (m - 1) / 2 - modd;
  long long neven = n * (n - 1) / 2 - nodd;
  long long tot1 = nodd * meven + neven * (modd + meven);
  tot1 %= mod;
  tot1 *= m * 2;
  tot1 %= mod;
  long long tot2 = modd * neven + meven * (nodd + neven);
  tot2 %= mod;
  tot2 *= n * 2;
  tot2 %= mod;
  return (tot1 + tot2) % mod;
}
int gcd(int a, int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a > b) return gcd(a % b, b);
  if (b >= a) return gcd(b % a, a);
}
int main() {
  scanf("%d %d", &w, &h);
  int start = clock();
  for (int i = 1; i <= w + 1; i++) {
    for (int j = 1; j <= h + 1; j++) {
      sum += num(i, j);
    }
  }
  sum *= 4;
  sum -= parallel(w + 1, h + 1);
  for (int i = 0; i <= w; i++) {
    for (int j = 0; j <= h; j++) {
      int k;
      if ((k = gcd(i, j) - 1) > 0) {
        long long p = 4 * (w - i + 1) * (h - j + 1);
        p *= k;
        sum -= p;
      }
      if (k < 0 || i < 2 || j < 2) continue;
      long long m = i - 1;
      long long n = j - 1;
      if (i % 2 == 0 && j % 2 == 0) {
        sum -= (2 * m * n - 2 * k) * (w - i + 1) * (h - j + 1);
      }
      if (i % 2 == 1 && j % 2 == 0) {
        sum -= (2 * m * (n / 2) - 2 * k) * (w - i + 1) * (h - j + 1);
      }
      if (i % 2 == 0 && j % 2 == 1) {
        sum -= (2 * (m / 2) * n - 2 * k) * (w - i + 1) * (h - j + 1);
      }
      if (i % 2 == 1 && j % 2 == 1) {
        sum -= (2 * (m / 2) * (n / 2) + 2 * ((m + 1) / 2) * ((n + 1) / 2) -
                2 * k) *
               (w - i + 1) * (h - j + 1);
      }
      sum %= mod;
      sum += mod;
      sum %= mod;
    }
  }
  printf("%d\n", (6 * (sum % mod + mod)) % mod);
  fflush(stdin);
  getchar();
}