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;
const int mod = 1000000007;
int gcd(int x, int y) {
  if (y == 0) return x;
  return gcd(y, x % y);
}
int main() {
  long long w, h, ww, hh, i, j, k, kk, t, tot;
  long long ans;
  cin >> w >> h;
  tot = (w + 1) * (h + 1);
  ans = tot * (tot - 1) % mod * (tot - 2) % mod;
  if (w >= 2) {
    ww = (w + 1) * w * (w - 1);
    ans = ((ans - ww * (h + 1)) % mod + mod) % mod;
  }
  if (h >= 2) {
    hh = (h + 1) * h * (h - 1);
    ans = ((ans - hh * (w + 1)) % mod + mod) % mod;
  }
  for (i = 1; i <= h; i++)
    for (j = 1; j <= w; j++) {
      k = gcd(i, j);
      t = (h - i + 1) * (w - j + 1);
      if (k >= 2) {
        kk = 6 * (k - 1);
        ans = ((ans - 2 * kk * t) % mod + mod) % mod;
      }
      t = 0;
      k = (h - i + 1) * (w - j + 1);
      if (i * j % 2 == 0)
        t += (i / 2) * (j / 2) * 4;
      else
        t += ((i - 1) * (j - 1) - (i / 2) * (j / 2)) * 4;
      if (i % 2 == 1 && j % 2 == 1) {
        t += 2 * (j - 1) + 2 * (i - 1);
        t += 2 * (((i + 1) / 2) * ((j + 1) / 2) +
                  (i + 1 - (i + 1) / 2) * (j + 1 - (j + 1) / 2));
      }
      if (i % 2 == 0 && j % 2 == 1) {
        t += 2 * (((i + 1) / 2) * (j + 1));
      }
      if (i % 2 == 1 && j % 2 == 0) {
        t += 2 * (((j + 1) / 2) * (i + 1));
      }
      ans = ((ans - (6 * k * t % mod)) % mod + mod) % mod;
    }
  cout << ans << endl;
  return 0;
}