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 has(int mask, int bit) { return (mask & (1 << bit)) > 0; }
int n, m;
long long ans, cnt[2][2];
int gcd(int a, int b) {
  if (a < b) swap(a, b);
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i <= n; ++i) cnt[0][i % 2]++;
  for (int i = 0; i <= m; ++i) cnt[1][i % 2]++;
  ans = 0;
  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      for (int mask = 0; mask < 16; ++mask) {
        int x = (has(mask, 0) - i);
        int x2 = (has(mask, 2) - i);
        int y = (has(mask, 1) - j);
        int y2 = (has(mask, 3) - j);
        int s = (x2 * y - y2 * x);
        if (s < 0) s = -s;
        if (s % 2 == 0) {
          long long p = 1;
          for (int k = 0; k < 4; ++k)
            p = (p * cnt[k % 2][has(mask, k)]) % ((int)1e9 + 7);
          p = p * cnt[0][i] * cnt[1][j] % ((int)1e9 + 7);
          ans = (ans + p) % ((int)1e9 + 7);
        }
      }
  long long nm = (n + 1) * (m + 1) % ((int)1e9 + 7);
  ans = (ans - nm + ((int)1e9 + 7)) % ((int)1e9 + 7);
  ans = (ans - nm * (nm - 1) * 3 % ((int)1e9 + 7) + ((int)1e9 + 7)) %
        ((int)1e9 + 7);
  for (int dx = 0; dx <= n; ++dx)
    for (int dy = 0; dy <= m; ++dy)
      if (dx || dy) {
        long long cur = 6ll * (n - dx + 1) * (m - dy + 1) * (gcd(dx, dy) - 1) %
                        ((int)1e9 + 7);
        if (dx > 0 && dy > 0) cur = cur * 2 % ((int)1e9 + 7);
        ans = (ans - cur + ((int)1e9 + 7)) % ((int)1e9 + 7);
      }
  cout << ans;
}