#include <bits/stdc++.h>
using namespace std;
int gcd(int x, int y) { return !y ? x : gcd(y, x % y); }
int main() {
  int W, H, w, h, r, t;
  for (scanf("%d%d", &W, &H), r = 0, w = 1; w <= W; w++)
    for (h = 1; h <= H;
         r = (r + (long long)t * (W - w + 1) * (H - h + 1)) % 1000000007, h++) {
      if (w % 2 && h % 2)
        t = (w / 2 + 1) * (h / 2 + 1) + ((w + 1) / 2) * ((h + 1) / 2);
      else if (w % 2)
        t = (h / 2 + 1) * (w + 1);
      else if (h % 2)
        t = (w / 2 + 1) * (h + 1);
      else
        t = (w + 1) * (h + 1);
      t -= gcd(w, h) + 1;
      t *= 2;
      if (w * h % 2 == 0)
        t += (w + h - 2) * 2 + (w - 1) * (h - 1) * 4 - (h / 2) * (w / 2) * 4;
      else
        t += (w / 2) * (h / 2) * 4;
    }
  printf("%I64d\n", (long long)r * 6 % 1000000007);
  return 0;
}
