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>
const long long bigp = 1000000007;
int g[4001][4001];
int gcd(int a, int b) {
  if (!a) return g[a][b] = b;
  if (!b) return g[a][b] = a;
  if (!g[a][b]) return g[a][b] = gcd(b, a % b);
  return g[a][b];
}
int main() {
  int w, h, i, j;
  long long ans = 0;
  scanf("%d%d", &w, &h);
  for (i = 0; i < 64; ++i) {
    int x[6] = {0};
    for (j = 0; j < 6; ++j) x[j] = !!(i & (1 << j));
    if (!((x[2] - x[0]) * (x[5] - x[1]) - (x[4] - x[0]) * (x[3] - x[1]))) {
      long long now = 1;
      for (j = 0; j < 6; j += 2) now *= (w + 1 + !(i & (1 << j))) / 2;
      now %= bigp;
      for (j = 1; j < 6; j += 2) now *= (h + 1 + !(i & (1 << j))) / 2;
      ans = (ans + now) % bigp;
    }
  }
  for (i = 0; i <= w; ++i)
    for (j = 0; j <= h; ++j) {
      if (!i && !j) continue;
      long long now = gcd(i, j) * 6;
      if (i && j) now *= 2;
      ans = (ans - now * (w - i + 1) * (h - j + 1)) % bigp;
    }
  ans = (ans - (h + 1) * (w + 1)) % bigp;
  if (ans < 0) ans += bigp;
  printf("%I64d\n", ans);
  return 0;
}