220_D. Little Elephant and Triangle_21674
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
import java.util.Scanner;

public class G {
	static final long mod = 1000000007;
	static Integer[][] memo = new Integer[4005][4005];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		long add = 0, sub =0;
		
		long combs = (X+1L)*(Y+1L);
		long oo = ((X+1)>>1) * ((Y+1)>>1);
		long oe = ((X+1)>>1) * ((Y+2)>>1);
		long eo = ((X+2)>>1) * ((Y+1)>>1);
		long ee = ((X+2)>>1) * ((Y+2)>>1);
		
		//two
		add+=trip(ee,ee-1,combs-ee);
		add+=trip(eo,eo-1,combs-eo);
		add+=trip(oe,oe-1,combs-oe);
		add+=trip(oo,oo-1,combs-oo);
		add*=3;
		
		//three
		add+=trip(ee,ee-1,ee-2);
		add+=trip(eo,eo-1,eo-2);
		add+=trip(oe,oe-1,oe-2);
		add+=trip(oo,oo-1,oo-2);
		
		
		for (int x = -X; x <= X; x++) {
			for (int y = 0; y <= Y; y++) {
				if(x<=0 && y == 0) continue;
				long ways = GCD(Math.abs(y), Math.abs(x)) + 1;
				long pick = (X - Math.abs(x) + 1) * (Y - y + 1);
				long temp = (pick * (6*(ways-2))) % mod;
				if(temp>0){
					sub+=temp;
				}
			}

		}
		sub%=mod;
		add%=mod;

	//	System.out.println(add+" "+sub);
		System.out.println((((add-sub) % mod)+mod)%mod);
	}

	private static long trip(long A, long B, long C) {
		return (((A*B)%mod)*C)%mod;
	}

	private static Integer GCD(int a, int b) {
		if(memo[a][b]!=null)return memo[a][b];
		if (b == 0)	return memo[a][b]=a;
		return memo[a][b]=GCD(b, a % b);
	}
}
