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;
constexpr int N = 4001;
constexpr int64_t M = 1000000007;
int64_t w, h;
int g[N][N];
int64_t pw(int64_t a, int64_t b, int64_t c = M) {
  int64_t ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % c;
    a = a * a % c;
    b >>= 1;
  }
  return ans;
}
int64_t iv(int64_t x) { return pw(x, M - 2); }
void dfs(int a, int b) {
  if (g[a][b]) return;
  if (!b)
    g[a][b] = a;
  else if (!a)
    g[a][b] = b;
  else {
    int c = a % b;
    dfs(b, c);
    g[a][b] = g[b][c];
  }
}
void work() {
  cin >> w >> h;
  ++w;
  ++h;
  int m = max(w, h);
  for (int i = 1; i < m; ++i) g[0][i] = i;
  for (int i = 1; i < m; ++i) {
    g[i][0] = i;
    for (int j = 1, jmi = j % i; j < m; ++j, jmi = jmi == i - 1 ? 0 : jmi + 1)
      g[i][j] = g[jmi][i];
  }
  int64_t y1 = (w / 2) * (h / 2), y4 = ((w + 1) / 2) * ((h + 1) / 2);
  int64_t y2 = ((w + 1) / 2) * (h / 2), y3 = (w / 2) * ((h + 1) / 2);
  int64_t n = w * h, ans = n * n % M * n % M;
  ans -= y1 * y2 % M * y3 % M * 6;
  ans -= y1 * y2 % M * y4 % M * 6;
  ans -= y1 * y3 % M * y4 % M * 6;
  ans -= y2 * y3 % M * y4 % M * 6;
  ans = (ans % M + M) % M;
  for (int64_t dx = 0; dx < w; ++dx)
    for (int64_t dy = dx ? 1 - h : 1; dy < h; ++dy) {
      int64_t d = g[dx][abs(dy)] + 1;
      int64_t c = (w - dx) * (h - abs(dy));
      ans = (ans - (d - 2) * c * 6) % M;
      ans = (ans - c * 6) % M;
    }
  ans = (ans % M + M - n) % M;
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  srand(time(0));
  int tc = 1;
  while (tc--) work();
  return 0;
}