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 gcd(int x, int y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
int main() {
  int i, j, i1, i2, i3, j1, j2, j3, w, h;
  long long tmp, ans;
  scanf("%d%d", &w, &h);
  ans = 0;
  for (i1 = 0; i1 < 2; i1++)
    for (i2 = 0; i2 < 2; i2++)
      for (i3 = 0; i3 < 2; i3++)
        for (j1 = 0; j1 < 2; j1++)
          for (j2 = 0; j2 < 2; j2++)
            for (j3 = 0; j3 < 2; j3++) {
              tmp = 1;
              if (i1 == 0)
                tmp *= (w / 2 + 1);
              else
                tmp *= (w + 1) / 2;
              tmp %= 1000000007;
              if (i2 == 0)
                tmp *= (w / 2 + 1);
              else
                tmp *= (w + 1) / 2;
              tmp %= 1000000007;
              if (i3 == 0)
                tmp *= (w / 2 + 1);
              else
                tmp *= (w + 1) / 2;
              tmp %= 1000000007;
              if (j1 == 0)
                tmp *= (h / 2 + 1);
              else
                tmp *= (h + 1) / 2;
              tmp %= 1000000007;
              if (j2 == 0)
                tmp *= (h / 2 + 1);
              else
                tmp *= (h + 1) / 2;
              tmp %= 1000000007;
              if (j3 == 0)
                tmp *= (h / 2 + 1);
              else
                tmp *= (h + 1) / 2;
              tmp %= 1000000007;
              if (((i1 & j2) ^ (i3 & j1) ^ (i2 & j3) ^ (i1 & j3) ^ (i2 & j1) ^
                   (i3 & j2)) == 0) {
                ans += tmp;
                ans %= 1000000007;
              }
            }
  for (i = 0; i <= w; i++)
    for (j = 0; j <= h; j++) {
      if ((i == 0) && (j < 0)) continue;
      if ((i == 0) && (j == 0))
        tmp = 1;
      else {
        tmp = (gcd(i, j) - 1) * 6 + 2 * 3;
      }
      tmp %= 1000000007;
      tmp *= (w - i + 1);
      tmp %= 1000000007;
      tmp *= (h - j + 1);
      tmp %= 1000000007;
      if ((j != 0) && (i != 0)) {
        tmp *= 2;
        tmp %= 1000000007;
      }
      ans = (ans + 1000000007 - tmp) % 1000000007;
    }
  printf("%d\n", (int)ans);
}