#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007LL;
int g[4020][4020];
long long modMinus(long long a, long long b) {
  long long ret = a - b;
  if (ret < 0) ret += mod;
  return ret;
}
long long modAdd(long long a, long long b) {
  long long ret = a + b;
  if (ret >= mod) ret -= mod;
  return ret;
}
int main() {
  long long w, h;
  long long ans = 0, x[2], y[2];
  ios::sync_with_stdio(0);
  cin >> w >> h;
  x[0] = (w >> 1) + 1;
  x[1] = w + 1 - x[0];
  y[0] = (h >> 1) + 1;
  y[1] = h + 1 - y[0];
  for (int i = 0; i <= w; i++)
    for (int j = 0; j <= h; j++) {
      if (i && j)
        g[i][j] = i > j ? g[i - j][j] : g[i][j - i];
      else
        g[i][j] = i + j;
    }
  for (int i = 0; i <= 1; i++)
    for (int j = 0; j <= 1; j++)
      for (int k = 0; k < 16; k++) {
        int x1 = ((k >> 3) & 1);
        int y1 = ((k >> 2) & 1);
        int x2 = ((k >> 1) & 1);
        int y2 = (k & 1);
        if (abs((i - x1) * (j - y2) + (x2 - i) * (j - y1)) % 2 == 0) {
          long long tmp =
              x[i] * y[j] * x[x1] % mod * x[x2] * y[y1] * y[y2] % mod;
          ans = modAdd(ans, tmp);
        }
      }
  ans = modMinus(ans, (w + 1) * (h + 1));
  for (int dx = 0; dx <= w; dx++)
    for (int dy = 0; dy <= h; dy++)
      if (dx + dy != 0) {
        int num = g[dx][dy] + 1;
        if (num == 2) {
          if (dx == 0 || dy == 0)
            ans = modMinus(ans, 6 * (w - dx + 1) * (h - dy + 1));
          else
            ans = modMinus(ans, 12 * (w - dx + 1) * (h - dy + 1));
        } else {
          if (dx == 0 || dy == 0)
            ans = modMinus(ans,
                           6 * (w - dx + 1) * (h - dy + 1) * (num - 1) % mod);
          else
            ans = modMinus(ans,
                           12 * (w - dx + 1) * (h - dy + 1) * (num - 1) % mod);
        }
      }
  printf("%d\n", (int)ans);
  return 0;
}
