#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int MAXN = 4100;
int gcf(int a, int b) { return ((b == 0) ? a : gcf(b, a % b)); }
int W, H;
int nw[2], nh[2];
long long ans;
int main() {
  ans = 0;
  cin >> W >> H;
  nw[0] = W / 2 + 1;
  nw[1] = W + 1 - nw[0];
  nh[0] = H / 2 + 1;
  nh[1] = H + 1 - nh[0];
  for (int i = 0; i < 64; i++) {
    int par[6];
    for (int j = 0; j < 6; j++) par[j] = ((i & (1 << j)) ? 1 : 0);
    int lsum = 0;
    for (int j = 0; j < 3; j++)
      for (int k = 3; k < 6; k++) {
        if (k == j + 3) continue;
        lsum += par[j] * par[k];
      }
    if (lsum % 2 == 0) {
      long long nval = 1;
      for (int j = 0; j < 3; j++) nval = (nval * nw[par[j]]) % MOD;
      for (int j = 3; j < 6; j++) nval = (nval * nh[par[j]]) % MOD;
      ans = (ans + nval) % MOD;
    }
  }
  for (int i = 0; i <= W; i++)
    for (int j = 0; j <= H; j++) {
      if (i + j == 0) continue;
      ans = (ans + MOD -
             ((6LL * ((i * j > 0) ? 2LL : 1LL) * ((long long)W - i + 1) *
               ((long long)H - j + 1) * ((long long)gcf(i, j))) %
              MOD)) %
            MOD;
    }
  ans = (ans + MOD - (W + 1) * (H + 1)) % MOD;
  cout << ans << "\n";
  return 0;
}
