#include <bits/stdc++.h>
using namespace std;
const int inf = ~0u >> 2;
int n, m, maxn;
int p[2][2];
long long ans, sub, S;
int gcd[4010][4010];
int main() {
  scanf("%d%d", &n, &m);
  ++n, ++m;
  maxn = max(n, m);
  for (int i = 0; i < maxn; ++i) gcd[i][0] = gcd[0][i] = i;
  for (int i = 0; i < maxn; ++i)
    for (int j = 0; j < maxn; ++j)
      if (i < j)
        gcd[i][j] = gcd[i][j - i];
      else
        gcd[i][j] = gcd[j][i - j];
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      p[i][j] = ((n + 1 - i) >> 1) * ((m + 1 - j) >> 1);
  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, x2 = e - a, y2 = f - b;
              if (!((x1 * y2 - x2 * y1) & 1))
                ans += (long long)p[a][b] * p[c][d] % 1000000007 * p[e][f] %
                       1000000007,
                    ans %= 1000000007;
            }
  S = n * m;
  sub += S, sub %= 1000000007;
  sub += S * (S - 1) % 1000000007 * 3 % 1000000007, sub %= 1000000007;
  sub += S % 1000000007 * (m - 1) % 1000000007 * (m - 2) % 1000000007,
      sub %= 1000000007;
  sub += S % 1000000007 * (n - 1) % 1000000007 * (n - 2) % 1000000007,
      sub %= 1000000007;
  for (int i = 1; i < n; ++i)
    for (int j = 1; j < m; ++j)
      if (gcd[i][j] >= 2) {
        long long tmp = (long long)(gcd[i][j] - 1) * (n - i) % 1000000007 *
                        (m - j) % 1000000007 * 12 % 1000000007;
        sub += tmp, sub %= 1000000007;
      }
  printf("%I64d\n", (ans - sub + 1000000007) % 1000000007);
  return 0;
}
