Problem: The Little Elephant is playing with the Cartesian coordinates' system. Most of all he likes playing with integer points. The Little Elephant defines an integer point as a pair of integers (x; y), such that 0 ≤ x ≤ w and 0 ≤ y ≤ h. Thus, the Little Elephant knows only (w + 1)·(h + 1) distinct integer points.

The Little Elephant wants to paint a triangle with vertexes at integer points, the triangle's area must be a positive integer. For that, he needs to find the number of groups of three points that form such triangle. At that, the order of points in a group matters, that is, the group of three points (0;0), (0;2), (2;2) isn't equal to the group (0;2), (0;0), (2;2).

Help the Little Elephant to find the number of groups of three integer points that form a nondegenerate triangle with integer area.

Input

A single line contains two integers w and h (1 ≤ w, h ≤ 4000).

Output

In a single output line print an integer — the remainder of dividing the answer to the problem by 1000000007 (109 + 7).

Examples

Input

2 1


Output

36


Input

2 2


Output

240

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
int nextint() {
  int t;
  if (scanf("%d", &t) != 1) exit(0);
  return t;
}
const int INF = 1000000000;
const int MOD = 1000000007;
int testbit(int n, int i) { return (n >> i) & 1; }
int cnt[2][2];
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int main() {
  int w = nextint();
  int h = nextint();
  for (int i = 0; i < (w + 1); i++)
    for (int j = 0; j < (h + 1); j++) {
      cnt[i & 1][j & 1]++;
    }
  long long res = 0;
  for (int i = 0; i < ((1 << 6)); i++) {
    int px1 = testbit(i, 0);
    int py1 = testbit(i, 1);
    int px2 = testbit(i, 2);
    int py2 = testbit(i, 3);
    int px3 = testbit(i, 4);
    int py3 = testbit(i, 5);
    int used[2][2] = {};
    if ((px2 - px1) * (py3 - py1) - (py2 - py1) * (px3 - px1) == 0) {
      long long tres = 1;
      tres = tres * (cnt[px1][py1] - used[px1][py1]) % MOD;
      used[px1][py1]++;
      tres = tres * (cnt[px2][py2] - used[px2][py2]) % MOD;
      used[px2][py2]++;
      tres = tres * (cnt[px3][py3] - used[px3][py3]) % MOD;
      used[px3][py3]++;
      res = (res + tres) % MOD;
    }
  }
  for (int i = 0; i < (w + 1); i++)
    for (int j = 0; j < (h + 1); j++) {
      if (i + j != 0) {
        int cnt = gcd(i, j) - 1;
        long long val = cnt;
        if (i != 0 && j != 0) val *= 2;
        val *= 6;
        res =
            ((res - (w - i + 1) * (h - j + 1) % MOD * val % MOD) % MOD + MOD) %
            MOD;
      }
    }
  cout << res << endl;
  return 0;
}