#include <bits/stdc++.h>
const long long bigp = 1000000007;
int g[4001][4001];
int gcd(int a, int b) {
  if (!a) return g[a][b] = b;
  if (!b) return g[a][b] = a;
  if (!g[a][b]) return g[a][b] = gcd(b, a % b);
  return g[a][b];
}
int main() {
  int w, h, i, j;
  long long ans = 0;
  scanf("%d%d", &w, &h);
  for (i = 0; i < 64; ++i) {
    int x[6] = {0};
    for (j = 0; j < 6; ++j) x[j] = !!(i & (1 << j));
    if (!((x[2] - x[0]) * (x[5] - x[1]) - (x[4] - x[0]) * (x[3] - x[1]))) {
      long long now = 1;
      for (j = 0; j < 6; j += 2) now *= (w + 1 + !(i & (1 << j))) / 2;
      now %= bigp;
      for (j = 1; j < 6; j += 2) now *= (h + 1 + !(i & (1 << j))) / 2;
      ans = (ans + now) % bigp;
    }
  }
  for (i = 0; i <= w; ++i)
    for (j = 0; j <= h; ++j) {
      if (!i && !j) continue;
      long long now = gcd(i, j) * 6;
      if (i && j) now *= 2;
      ans = (ans - now * (w - i + 1) * (h - j + 1)) % bigp;
    }
  ans = (ans - (h + 1) * (w + 1)) % bigp;
  if (ans < 0) ans += bigp;
  printf("%I64d\n", ans);
  return 0;
}
