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 JAVA):

Solution:
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.util.ArrayList;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Writer;
import java.math.BigInteger;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Crash
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		OutputWriter out = new OutputWriter(outputStream);
		TaskD solver = new TaskD();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskD {
	private static final int modulo = 1000000007;
	private int[] calc(int a, int b) {
		return new int[] {1 + a / 2 + b / 2, (a + 1) / 2 + (b + 1) / 2};
	}
	public void solve(int testNumber, InputReader in, OutputWriter out) {
		int w = in.readInt();
		int h = in.readInt();
		long ans = 0;
		for (int i = 0; i < 2; i ++)
			for (int j = 0; j < 2; j ++) {
				int[] cx = calc(i, w - i);
				int[] cy = calc(j, h - j);
				long tmp = 0;
				tmp = (tmp + (long)cx[0] * cy[0] * (w + 1) * (h + 1)) % modulo;
				tmp = (tmp + (long)cx[0] * cy[1] * cx[0] * (h + 1)) % modulo;
				tmp = (tmp + (long)cx[1] * cy[0] * (w + 1) * cy[0]) % modulo;
				tmp = (tmp + (long)cx[1] * cy[1] * cx[0] * cy[0]) % modulo;
				tmp = (tmp + (long)cx[1] * cy[1] * cx[1] * cy[1]) % modulo;
				ans = (ans + tmp * ((w - i) / 2 + 1) * ((h - j) / 2 + 1)) % modulo;
			}
		ans = (ans - (w + 1) * (h + 1)) % modulo;
		ans = (ans - (long)(w + 1) * (h + 1) * ((w + 1) * (h + 1) - 1) * 3) % modulo;
		ans = (ans - (long)(w + 1) * (h + 1) * h * (h - 1)) % modulo;
		ans = (ans - (long)(h + 1) * (w + 1) * w * (w - 1)) % modulo;
		for (int i = 1; i <= w; i ++)
			for (int j = 1; j <= h; j ++) {
				int t = NumberTheory.gcd(i, j) - 1;
				ans = (ans - (long)(w - i + 1) * (h - j + 1) % modulo * t * 12) % modulo;
			}
		ans = (ans + modulo) % modulo;
		out.printLine(ans);
	}
}

class InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1000];
	private int curChar;
	private int numChars;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	private int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	private boolean isSpaceChar(int c) {
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
}

class OutputWriter {
	private final PrintWriter writer;

	public OutputWriter(OutputStream outputStream) {
		writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
	}

	public OutputWriter(Writer writer) {
		this.writer = new PrintWriter(writer);
	}

	public void print(Object...objects) {
		for (int i = 0; i < objects.length; i++) {
			if (i != 0)
				writer.print(' ');
			writer.print(objects[i]);
		}
	}

	public void printLine(Object...objects) {
		print(objects);
		writer.println();
	}

	public void close() {
		writer.close();
	}
}

class NumberTheory {
	private NumberTheory() {
	}

	public static int gcd(int m, int n) {
		if (m == 0) return n;
		while (n > 0) {
			int r = m % n;
			m = n;
			n = r;
		}
		return m;
	}

	}