#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:200000000")
using namespace std;
template <typename T>
inline T Abs(T x) {
  return (x >= 0) ? x : -x;
}
template <typename T>
inline T sqr(T x) {
  return x * x;
}
const int INF = (int)1E9;
const long long INF64 = (long long)1E18;
const long double EPS = 1E-9;
const long double PI = 3.1415926535897932384626433832795;
const int MAXN = 4050;
const long long MOD = INF + 7;
int n, m, g[MAXN][MAXN];
long long num[2][2];
int get(int mod, int n) {
  if (n % 2 == 0 || mod == 1) return n / 2;
  return n / 2 + 1;
}
int gcd(int a, int b) {
  if (min(a, b) == 0) return a + b;
  return gcd(b % a, a);
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < (int)(2); i++)
    for (int j = 0; j < (int)(2); j++)
      num[i][j] = get(i, n + 1) * get(j, m + 1);
  long long ans = 0;
  for (int x = 0; x < (int)(2); x++)
    for (int y = 0; y < (int)(2); y++)
      for (int x1 = 0; x1 < (int)(2); x1++)
        for (int YYYYYYYYYYYY1 = 0; YYYYYYYYYYYY1 < (int)(2); YYYYYYYYYYYY1++)
          for (int x2 = 0; x2 < (int)(2); x2++)
            for (int y2 = 0; y2 < (int)(2); y2++) {
              int value = (x2 - x) * (YYYYYYYYYYYY1 - y) - (x1 - x) * (y2 - y);
              if (value % 2 == 0) {
                long long cur = (num[x][y] * num[x1][YYYYYYYYYYYY1]) % MOD;
                cur = (cur * num[x2][y2]) % MOD;
                ans = (ans + cur) % MOD;
              }
            }
  long long ans2 = (n + 1) * (m + 1);
  for (int dx = 0; dx < (int)(n + 1); dx++)
    for (int dy = 0; dy < (int)(m + 1); dy++) {
      if (dx == 0 && dy == 0) continue;
      long long cur = (n - dx + 1) * (m - dy + 1);
      cur = (cur * (gcd(dx, dy) - 1) * 6) % MOD;
      if (dx > 0 && dy > 0) cur *= 2;
      ans2 = (ans2 + cur) % MOD;
    }
  ans2 += 1LL * ((n + 1) * (m + 1) - 1) * (n + 1) * (m + 1) * 3;
  ans %= MOD;
  ans2 %= MOD;
  cout << (ans + MOD - ans2) % MOD << endl;
  return 0;
}
