#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int w, h, rez, nx[2], ny[2], x1, x2, x3, y11, y2, y3;
int gcd(int a, int b) {
  if (!a || !b) return a + b;
  while (b) {
    int t = b;
    b = a % b;
    a = t;
  }
  return a;
}
int main() {
  int i, j;
  cin >> w >> h;
  nx[0] = w / 2 + 1;
  nx[1] = (w + 1) / 2;
  ny[0] = h / 2 + 1;
  ny[1] = (h + 1) / 2;
  for (i = 0; i != 64; ++i) {
    x1 = ((i & 1) == 1);
    x2 = ((i & 2) == 2);
    x3 = ((i & 4) == 4);
    y11 = ((i & 8) == 8);
    y2 = ((i & 16) == 16);
    y3 = ((i & 32) == 32);
    if ((x1 * y2 + y11 * x2 + x1 * y3 - y11 * x3 + x2 * y3 - y2 * x3) % 2 == 0)
      rez = ((long long)rez + (long long)nx[x1] * nx[x2] % MOD * nx[x3] % MOD *
                                  ny[y11] % MOD * ny[y2] % MOD * ny[y3]) %
            MOD;
  }
  rez = (rez - (w + 1) * (h + 1)) % MOD;
  if (rez < 0) rez += MOD;
  for (i = 0; i <= w; ++i)
    for (j = 0; j <= h; ++j)
      if (j || i) {
        int t = ((1 + (i != 0)) * (1 + (j != 0)));
        rez = (rez - (long long)(w - i + 1) * (h - j + 1) * 3 * t * gcd(i, j)) %
              MOD;
        if (rez < 0) rez += MOD;
      }
  cout << rez;
  return 0;
}
