#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const int N = 4100;
int gcd[N][N], x, y;
long long parity[2][2];
int main() {
  scanf("%d %d", &x, &y);
  ++x;
  ++y;
  long long ans = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      parity[i][j] = (i ? x / 2 : x - x / 2) * (j ? y / 2 : y - y / 2);
  for (int a = 0; a < 2; ++a)
    for (int b = 0; b < 2; ++b)
      for (int c = 0; c < 2; ++c)
        for (int d = 0; d < 2; ++d)
          for (int e = 0; e < 2; ++e)
            for (int f = 0; f < 2; ++f) {
              int x1 = c - a, y1 = d - b;
              int x2 = e - a, y2 = f - b;
              int area = x1 * y2 - x2 * y1;
              if (area < 0) area = -area;
              if (area % 2 == 0)
                ans = (ans +
                       parity[a][b] * parity[c][d] % MOD * parity[e][f] % MOD) %
                      MOD;
            }
  long long zero = 0;
  long long sum = x * y;
  zero = (zero + sum) % MOD;
  zero = (zero + sum * (sum - 1) * 3) % MOD;
  zero = (zero + x * y % MOD * (y - 1) % MOD * (y - 2) % MOD) % MOD;
  zero = (zero + y * x % MOD * (x - 1) % MOD * (x - 2) % MOD) % MOD;
  for (int i = 0; i < x; ++i)
    for (int j = 0; j < y; ++j)
      if (i == 0) {
        gcd[i][j] = j;
      } else if (j == 0) {
        gcd[i][j] = i;
      } else if (i < j) {
        gcd[i][j] = gcd[i][j % i];
      } else {
        gcd[i][j] = gcd[i % j][j];
      }
  for (int i = 1; i < x; ++i)
    for (int j = 1; j < y; ++j)
      if (gcd[i][j] >= 2) {
        long long tmp =
            (x - i) * (y - j) * (long long)(gcd[i][j] - 1) * 12 % MOD;
        zero = (zero + tmp) % MOD;
      }
  ans = (ans - zero + MOD) % MOD;
  cout << ans << endl;
}
