#include <bits/stdc++.h>
using namespace std;
const long mod = 1000000007;
long w, h;
long gcd[4005][4005] = {0};
long calc(long &i, long &j, long &x1, long &y1) {
  long p1, p2;
  if (((i + x1) & 1) == 0)
    p1 = (w + 2) >> 1;
  else
    p1 = (w + 1) >> 1;
  p2 = (h - j + y1) >> 1;
  return p1 * p2;
}
int main() {
  long i, j;
  long x1, y1, x2, y2;
  long long ans = 0;
  long tmp;
  scanf("%ld%ld", &w, &h);
  for (i = 0; i <= w; i++)
    for (j = 0; j <= h; j++) {
      ans += (long long)(w - i) / 2 * (h - j) * (w + 1);
      ans += (long long)(w - i + 1) / 2 * ((h - j) / 2) * (w + 1);
      for (x1 = 0; x1 <= 1; x1++)
        for (y1 = 0; y1 <= 1; y1++) {
          register long t1, t2;
          t1 = calc(i, j, x1, y1);
          ans += (long long)t1 * (t1 - 1) >> 1;
          for (x2 = x1; x2 <= 1; x2++)
            for (y2 = x1 == x2 ? y1 + 1 : 0; y2 <= 1; y2++)
              if (((x1 * y2 - x2 * y1) & 1) == 0) {
                t1 = calc(i, j, x1, y1);
                t2 = calc(i, j, x2, y2);
                ans += (long long)t1 * t2;
              }
        }
      ans %= mod;
    }
  for (i = 1; i <= 4000; i++) {
    gcd[i][0] = i;
    for (j = 1; j <= i; j++) gcd[i][j] = gcd[j][i % j];
  }
  for (i = 1; i <= 4000; i++)
    for (j = i + 1; j <= 4000; j++) gcd[i][j] = gcd[j][i];
  for (i = 1; i <= w; i++)
    for (j = 1; j <= h; j++) {
      ans -= (long long)(w + 1 - i) * (h + 1 - j) * (gcd[i][j] - 1) * 2 % mod;
      ans += mod;
      ans %= mod;
    }
  ans -= (long long)(w + 1) * h * (h + 1) * (h - 1) / 6 % mod;
  ans += mod;
  ans %= mod;
  printf("%I64d\n", ans * 6 % mod);
  return 0;
}
