#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
int r = 0, w, h;
int ans[2][2], x[2], y[2];
int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int sub(int a, int b) {
  a -= b;
  if (a < 0) a += mod;
  return a;
}
int mul(int a, int b) { return (a * 1LL * b) % mod; }
int go1() {
  int r = 0;
  for (int i = 0; i <= w; i++)
    for (int j = 0; j <= h; j++)
      for (int i1 = 0; i1 <= w; i1++)
        for (int j1 = 0; j1 <= h; j1++)
          for (int i2 = 0; i2 <= w; i2++)
            for (int j2 = 0; j2 <= h; j2++) {
              if (i == i1 && j == j1) continue;
              if (i == i2 && j == j2) continue;
              if (i2 == i1 && j2 == j1) continue;
              int s = ((i1 - i) * (j2 - j) - (j1 - j) * (i2 - i));
              if (s < 0) s = -s;
              if (s == 0 || s % 2) continue;
              r++;
            }
  return r;
}
int gcd(int a, int b) {
  while (a) {
    b %= a;
    swap(a, b);
  }
  return b;
}
int main(void) {
  scanf("%d %d", &w, &h);
  for (int i = 0; i <= w; i++) x[i % 2]++;
  for (int i = 0; i <= h; i++) y[i % 2]++;
  for (int dx = 0; dx <= w; dx++)
    for (int dy = 0; dy <= h; dy++) {
      if (dx == 0 && dy == 0) continue;
      int q1 = (w - dx + 1), q2 = (h - dy + 1), q = mul(q1, q2);
      q = mul(q, 6);
      if (dx && dy) q = mul(q, 2);
      r = sub(r, q);
      int in = gcd(dx, dy) - 1;
      if (in < 0) in = 0;
      in = mul(in, q);
      r = sub(r, in);
    }
  for (int i = 0; i < 2; i++)
    for (int j = 0; j < 2; j++) {
      for (int i1 = 0; i1 < 2; i1++)
        for (int j1 = 0; j1 < 2; j1++)
          for (int i2 = 0; i2 < 2; i2++)
            for (int j2 = 0; j2 < 2; j2++) {
              if (((i1 - i) * (j2 - j) - (j1 - j) * (i2 - i)) % 2) continue;
              int q1 = mul(x[i1], y[j1]), q2 = mul(x[i2], y[j2]),
                  q = mul(q1, q2);
              ans[i][j] = add(ans[i][j], q);
            }
      ans[i][j] = sub(ans[i][j], 1);
    }
  int t = 0;
  for (int i = 0; i <= w; i++)
    for (int j = 0; j <= h; j++) {
      r = add(r, ans[i % 2][j % 2]);
    }
  printf("%d\n", r);
  return 0;
}
