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;
#pragma comment(linker, "/STACK:200000000")
const double EPS = 1E-9;
const int INF = 1000000000;
const long long INF64 = (long long)1E18;
const double PI = 3.1415926535897932384626433832795;
const int MOD = INF + 7;
int gcd(int a, int b) { return a == 0 ? b : gcd(b % a, a); }
int main() {
  int w, h;
  cin >> w >> h;
  long long ans = 0;
  for (int lx = 0; lx <= w; lx++)
    for (int ly = 0; ly <= h; ly++) {
      int len = gcd(lx, ly) + 1;
      if (len < 3) continue;
      long long onseg = (len - 2) * 6 % MOD;
      long long onfield = (w - lx + 1) * (h - ly + 1) % MOD;
      if (lx && ly) onseg *= 2;
      onseg %= MOD;
      ans += onseg * onfield;
      ans %= MOD;
    }
  long long a = 0;
  vector<vector<long long> > cnt(2, vector<long long>(2));
  for (int x = 0; x <= w; x++)
    for (int y = 0; y <= h; y++) cnt[x % 2][y % 2]++;
  for (int x1 = 0; x1 < (int)(2); x1++)
    for (int y1 = 0; y1 < (int)(2); y1++)
      for (int x2 = 0; x2 < (int)(2); x2++)
        for (int y2 = 0; y2 < (int)(2); y2++)
          for (int x3 = 0; x3 < (int)(2); x3++)
            for (int y3 = 0; y3 < (int)(2); y3++) {
              long long s = (x3 - x1) * (y2 - y1) - (x2 - x1) * (y3 - y1);
              if (s % 2 == 0) {
                vector<vector<long long> > loc = cnt;
                long long cur = 1;
                cur *= loc[x1][y1];
                loc[x1][y1]--;
                cur *= loc[x2][y2];
                cur %= MOD;
                loc[x2][y2]--;
                cur *= loc[x3][y3];
                cur %= MOD;
                loc[x3][y3]--;
                a += cur;
                a %= MOD;
              }
            }
  long long res = ((a - ans) % MOD + MOD) % MOD;
  cout << res << endl;
  return 0;
}