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 long long Mod = 1000000007;
int main() {
  const int MaxW = 4000;
  const int MaxH = 4000;
  long long w, h;
  cin >> w >> h;
  long long nAll = (w + 1) * (h + 1);
  long long n00 = ((w + 2) >> 1) * ((h + 2) >> 1);
  long long n01 = ((w + 2) >> 1) * ((h + 1) >> 1);
  long long n10 = ((w + 1) >> 1) * ((h + 2) >> 1);
  long long n11 = ((w + 1) >> 1) * ((h + 1) >> 1);
  long long res = 0;
  res = (res + n00 * (n00 - 1) % Mod * (nAll - 2)) % Mod;
  res = (res + n00 * n01 % Mod * (n00 + n01 - 2) * 2) % Mod;
  res = (res + n00 * n10 % Mod * (n00 + n10 - 2) * 2) % Mod;
  res = (res + n00 * n11 % Mod * (n00 + n11 - 2) * 2) % Mod;
  res = (res + n01 * (n01 - 1) % Mod * (nAll - 2)) % Mod;
  res = (res + n01 * n10 % Mod * (n01 + n10 - 2) * 2) % Mod;
  res = (res + n01 * n11 % Mod * (n01 + n11 - 2) * 2) % Mod;
  res = (res + n10 * (n10 - 1) % Mod * (nAll - 2)) % Mod;
  res = (res + n10 * n11 % Mod * (n10 + n11 - 2) * 2) % Mod;
  res = (res + n11 * (n11 - 1) % Mod * (nAll - 2)) % Mod;
  static int g[MaxW + 1][MaxH + 1];
  for (int i = 0; i <= max(w, h); i++)
    for (int j = 0; j <= max(w, h); j++) {
      if (i == 0)
        g[i][j] = j;
      else if (j == 0)
        g[i][j] = i;
      else if (i > j)
        g[i][j] = g[j][i - j];
      else
        g[i][j] = g[i][j - i];
    }
  if (w >= 2) {
    res -= (w + 1) * w % Mod * (w - 1) % Mod * (h + 1) % Mod;
    if (res < 0) res += Mod;
  }
  if (h >= 2) {
    res -= (h + 1) * h % Mod * (h - 1) % Mod * (w + 1) % Mod;
    if (res < 0) res += Mod;
  }
  for (int i = 1; i <= w; i++)
    for (int j = 1; j <= h; j++) {
      res -= ((g[i][j] - 1) * (w - i + 1) * (h - j + 1) * 12) % Mod;
      if (res < 0) res += Mod;
    }
  cout << res << endl;
  return 0;
}