#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
int pgcd(int a, int b) {
  if (b == 0) return a;
  return pgcd(b, a % b);
}
int main() {
  int x[3], y[3];
  int r, a, b, c, p;
  int w, h;
  long long int combien, total = 0;
  cin >> w >> h;
  for (x[0] = 0; x[0] < 2; x[0]++) {
    for (x[1] = 0; x[1] < 2; x[1]++) {
      for (x[2] = 0; x[2] < 2; x[2]++) {
        for (y[0] = 0; y[0] < 2; y[0]++) {
          for (y[1] = 0; y[1] < 2; y[1]++) {
            for (y[2] = 0; y[2] < 2; y[2]++) {
              r = (x[2] - x[1]) * (y[1] + y[2]) +
                  (x[0] - x[1]) * (y[1] + y[0]) + (x[2] - x[0]) * (y[2] + y[0]);
              if (r % 2 == 0) {
                combien = 1;
                if (x[0] == 0)
                  combien = (combien * (w / 2 + 1)) % MOD;
                else
                  combien = (combien * ((w + 1) / 2)) % MOD;
                if (x[1] == 0)
                  combien = (combien * (w / 2 + 1)) % MOD;
                else
                  combien = (combien * ((w + 1) / 2)) % MOD;
                if (x[2] == 0)
                  combien = (combien * (w / 2 + 1)) % MOD;
                else
                  combien = (combien * ((w + 1) / 2)) % MOD;
                if (y[0] == 0)
                  combien = (combien * (h / 2 + 1)) % MOD;
                else
                  combien = (combien * ((h + 1) / 2)) % MOD;
                if (y[1] == 0)
                  combien = (combien * (h / 2 + 1)) % MOD;
                else
                  combien = (combien * ((h + 1) / 2)) % MOD;
                if (y[2] == 0)
                  combien = (combien * (h / 2 + 1)) % MOD;
                else
                  combien = (combien * ((h + 1) / 2)) % MOD;
                total = (total + combien) % MOD;
              }
            }
          }
        }
      }
    }
  }
  for (x[0] = 0; x[0] < 2; x[0]++) {
    for (y[0] = 0; y[0] < 2; y[0]++) {
      x[2] = x[0];
      y[2] = y[0];
      x[1] = x[0];
      y[1] = y[0];
      r = (x[2] - x[1]) * (y[1] + y[2]) + (x[0] - x[1]) * (y[1] + y[0]) +
          (x[2] - x[0]) * (y[2] + y[0]);
      if (r % 2 == 0) {
        combien = 1;
        if (x[0] == 0)
          combien = (combien * (w / 2 + 1)) % MOD;
        else
          combien = (combien * ((w + 1) / 2)) % MOD;
        if (y[0] == 0)
          combien = (combien * (h / 2 + 1)) % MOD;
        else
          combien = (combien * ((h + 1) / 2)) % MOD;
        total = (total + 2 * combien) % MOD;
      }
    }
  }
  for (x[0] = 0; x[0] < 2; x[0]++) {
    for (x[1] = 0; x[1] < 2; x[1]++) {
      for (y[0] = 0; y[0] < 2; y[0]++) {
        for (y[1] = 0; y[1] < 2; y[1]++) {
          x[2] = x[0];
          y[2] = y[0];
          r = (x[2] - x[1]) * (y[1] + y[2]) + (x[0] - x[1]) * (y[1] + y[0]) +
              (x[2] - x[0]) * (y[2] + y[0]);
          if (r % 2 == 0) {
            combien = 1;
            if (x[0] == 0)
              combien = (combien * (w / 2 + 1)) % MOD;
            else
              combien = (combien * ((w + 1) / 2)) % MOD;
            if (x[1] == 0)
              combien = (combien * (w / 2 + 1)) % MOD;
            else
              combien = (combien * ((w + 1) / 2)) % MOD;
            if (y[0] == 0)
              combien = (combien * (h / 2 + 1)) % MOD;
            else
              combien = (combien * ((h + 1) / 2)) % MOD;
            if (y[1] == 0)
              combien = (combien * (h / 2 + 1)) % MOD;
            else
              combien = (combien * ((h + 1) / 2)) % MOD;
            total = (total - 3 * combien) % MOD;
          }
        }
      }
    }
  }
  for (a = 0; a <= w; a++) {
    for (b = 0; b <= h; b++) {
      if (a || b) {
        if (a > b)
          p = pgcd(a, b) - 1;
        else
          p = pgcd(b, a) - 1;
        combien = p;
        combien = (combien * (w - a + 1)) % MOD;
        combien = (combien * (h - b + 1)) % MOD;
        if (a && b)
          total = (total - 12 * combien) % MOD;
        else
          total = (total - 6 * combien) % MOD;
      }
    }
  }
  if (total < 0) total += MOD;
  cout << total << endl;
  return 0;
}
