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 N(4010), MOD(1000000007);
int h, w, ans;
int t[N];
int g[N][N];
int mul(long long a, long long b) { return a * b % MOD; }
int c2(int x) { return x * (x - 1) / 2; }
int gcd(int i, int j) {
  if (g[i][j]) return g[i][j];
  return gcd(j, i % j);
}
int main() {
  scanf("%d%d", &h, &w);
  for (int i = int(2); i < int(w + 1); ++i) t[i] = (t[i - 1] + i / 2) % MOD;
  for (int i = int(1); i < int(w + 1); ++i) g[0][i] = i;
  for (int i = int(1); i < int(h + 1); ++i) g[i][0] = i;
  for (int i = int(1); i < int(h + 1); ++i)
    for (int j = int(1); j < int(w + 1); ++j) g[i][j] = gcd(i, j);
  for (int i = int(0); i < int(h + 1); ++i)
    for (int j = int(0); j < int(w + 1); ++j)
      if (i + j) g[i][j] = c2(g[i][j]) - c2(g[i][j] - 1);
  for (int i = int(1); i < int(w + 1); ++i)
    g[0][i] = (g[0][i] + g[0][i - 1]) % MOD;
  for (int i = int(1); i < int(h + 1); ++i)
    g[i][0] = (g[i][0] + g[i - 1][0]) % MOD;
  for (int i = int(1); i < int(h + 1); ++i)
    for (int j = int(1); j < int(w + 1); ++j)
      g[i][j] = ((g[i][j] + g[i - 1][j]) % MOD +
                 (g[i][j - 1] - g[i - 1][j - 1]) % MOD) %
                MOD;
  int ans = 0;
  for (int i = int(1); i < int(h + 1); ++i) {
    for (int j = int(0); j < int(w + 1); ++j) {
      int oddh = (i + 1) / 2;
      int oddw = w / 2 + 1;
      if (j % 2 == 0) oddw = w + 1 - oddw;
      int odd = mul(oddh, oddw);
      int even = i * (w + 1) - odd;
      int tmp = mul(odd, odd) + mul(even, even);
      tmp = (tmp - i * (w + 1) -
             2 * (g[i][j] + g[i][w - j] - g[i][0] - g[0][j] - g[0][w - j])) %
            MOD;
      ans = (ans + mul(tmp, 3)) % MOD;
    }
    int tmp = (mul(i, t[w]) + mul(i / 2, c2(w + 1) - t[w])) % MOD;
    tmp = mul(tmp, mul(w + 1, 6));
    ans = (ans + tmp) % MOD;
  }
  printf("%d\n", ans);
  return 0;
}