Triangles

Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

How many triple of points \(A(x_A, y_A), B(x_B, y_B), C(x_C, y_C)\) which:

  • \(x_A, y_A, x_B, y_B, x_C, y_C \in \mathbb{Z}\)

  • \(0 \leq x_A, x_B, x_C < n, 0 \leq y_A, y_B, y_C < m\)

  • \(S_{\triangle ABC} \not\in \mathbb{Z}\)? (\(S_\triangle\) denotes the area of triangle)

Input

Two integers \(n\) and \(m\).

(\(1 \leq n, m \leq 10^9\))

Output

The only integer denotes the number possible triples, modulo \(10^9 + 7\).

Sample Input

2 2

Sample Output

24

Hint

There are \(4\) triangles. Each of them is counted \(6\) times.

Source

ftiasch

Manager

Information
Solved Number33
Submit Number81
Problem Tags
combinatorics
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel