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 long long int MOD = 1000000007;
int pgcd(int a, int b) {
  if (b == 0) return a;
  return pgcd(b, a % b);
}
int main() {
  int x[3], y[3];
  int r, a, b, c, p;
  int w, h;
  long long int combien, total = 0;
  cin >> w >> h;
  for (x[0] = 0; x[0] < 2; x[0]++) {
    for (x[1] = 0; x[1] < 2; x[1]++) {
      for (x[2] = 0; x[2] < 2; x[2]++) {
        for (y[0] = 0; y[0] < 2; y[0]++) {
          for (y[1] = 0; y[1] < 2; y[1]++) {
            for (y[2] = 0; y[2] < 2; y[2]++) {
              r = (x[2] - x[1]) * (y[1] + y[2]) +
                  (x[0] - x[1]) * (y[1] + y[0]) + (x[2] - x[0]) * (y[2] + y[0]);
              if (r % 2 == 0) {
                combien = 1;
                if (x[0] == 0)
                  combien = (combien * (w / 2 + 1)) % MOD;
                else
                  combien = (combien * ((w + 1) / 2)) % MOD;
                if (x[1] == 0)
                  combien = (combien * (w / 2 + 1)) % MOD;
                else
                  combien = (combien * ((w + 1) / 2)) % MOD;
                if (x[2] == 0)
                  combien = (combien * (w / 2 + 1)) % MOD;
                else
                  combien = (combien * ((w + 1) / 2)) % MOD;
                if (y[0] == 0)
                  combien = (combien * (h / 2 + 1)) % MOD;
                else
                  combien = (combien * ((h + 1) / 2)) % MOD;
                if (y[1] == 0)
                  combien = (combien * (h / 2 + 1)) % MOD;
                else
                  combien = (combien * ((h + 1) / 2)) % MOD;
                if (y[2] == 0)
                  combien = (combien * (h / 2 + 1)) % MOD;
                else
                  combien = (combien * ((h + 1) / 2)) % MOD;
                total = (total + combien) % MOD;
              }
            }
          }
        }
      }
    }
  }
  for (x[0] = 0; x[0] < 2; x[0]++) {
    for (y[0] = 0; y[0] < 2; y[0]++) {
      x[2] = x[0];
      y[2] = y[0];
      x[1] = x[0];
      y[1] = y[0];
      r = (x[2] - x[1]) * (y[1] + y[2]) + (x[0] - x[1]) * (y[1] + y[0]) +
          (x[2] - x[0]) * (y[2] + y[0]);
      if (r % 2 == 0) {
        combien = 1;
        if (x[0] == 0)
          combien = (combien * (w / 2 + 1)) % MOD;
        else
          combien = (combien * ((w + 1) / 2)) % MOD;
        if (y[0] == 0)
          combien = (combien * (h / 2 + 1)) % MOD;
        else
          combien = (combien * ((h + 1) / 2)) % MOD;
        total = (total + 2 * combien) % MOD;
      }
    }
  }
  for (x[0] = 0; x[0] < 2; x[0]++) {
    for (x[1] = 0; x[1] < 2; x[1]++) {
      for (y[0] = 0; y[0] < 2; y[0]++) {
        for (y[1] = 0; y[1] < 2; y[1]++) {
          x[2] = x[0];
          y[2] = y[0];
          r = (x[2] - x[1]) * (y[1] + y[2]) + (x[0] - x[1]) * (y[1] + y[0]) +
              (x[2] - x[0]) * (y[2] + y[0]);
          if (r % 2 == 0) {
            combien = 1;
            if (x[0] == 0)
              combien = (combien * (w / 2 + 1)) % MOD;
            else
              combien = (combien * ((w + 1) / 2)) % MOD;
            if (x[1] == 0)
              combien = (combien * (w / 2 + 1)) % MOD;
            else
              combien = (combien * ((w + 1) / 2)) % MOD;
            if (y[0] == 0)
              combien = (combien * (h / 2 + 1)) % MOD;
            else
              combien = (combien * ((h + 1) / 2)) % MOD;
            if (y[1] == 0)
              combien = (combien * (h / 2 + 1)) % MOD;
            else
              combien = (combien * ((h + 1) / 2)) % MOD;
            total = (total - 3 * combien) % MOD;
          }
        }
      }
    }
  }
  for (a = 0; a <= w; a++) {
    for (b = 0; b <= h; b++) {
      if (a || b) {
        if (a > b)
          p = pgcd(a, b) - 1;
        else
          p = pgcd(b, a) - 1;
        combien = p;
        combien = (combien * (w - a + 1)) % MOD;
        combien = (combien * (h - b + 1)) % MOD;
        if (a && b)
          total = (total - 12 * combien) % MOD;
        else
          total = (total - 6 * combien) % MOD;
      }
    }
  }
  if (total < 0) total += MOD;
  cout << total << endl;
  return 0;
}