#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
const int MOD = INF + 7;
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
int main() {
  int w, h;
  cin >> w >> h;
  long long ans = 0;
  for (int lx = 0; lx <= w; lx++)
    for (int ly = 0; ly <= h; ly++) {
      int len = gcd(lx, ly) + 1;
      if (len < 3) continue;
      long long onseg = (len - 2) * 6 % MOD;
      long long onfield = (w - lx + 1) * (h - ly + 1) % MOD;
      if (lx && ly) onseg *= 2;
      onseg %= MOD;
      ans += onseg * onfield;
      ans %= MOD;
    }
  long long a = 0;
  vector<vector<long long> > cnt(2, vector<long long>(2));
  for (int x = 0; x <= w; x++)
    for (int y = 0; y <= h; y++) cnt[x % 2][y % 2]++;
  for (int x1 = 0; x1 < (int)(2); x1++)
    for (int y1 = 0; y1 < (int)(2); y1++)
      for (int x2 = 0; x2 < (int)(2); x2++)
        for (int y2 = 0; y2 < (int)(2); y2++)
          for (int x3 = 0; x3 < (int)(2); x3++)
            for (int y3 = 0; y3 < (int)(2); y3++) {
              long long s = (x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1);
              if (s % 2 == 0) {
                vector<vector<long long> > loc = cnt;
                long long cur = 1;
                cur *= loc[x1][y1];
                loc[x1][y1]--;
                cur *= loc[x2][y2];
                cur %= MOD;
                loc[x2][y2]--;
                cur *= loc[x3][y3];
                cur %= MOD;
                loc[x3][y3]--;
                a += cur;
                a %= MOD;
              }
            }
  long long res = ((a - ans) % MOD + MOD) % MOD;
  cout << res << endl;
  return 0;
}
