#include using namespace std; #define fs first #define sc second #define pb push_back #define mp make_pair #define eb emplace_back #define ALL(A) A.begin(),A.end() #define RALL(A) A.rbegin(),A.rend() typedef long long LL; typedef pair P; const LL mod=1000000007; const LL LINF=1LL<<60; const int INF=1<<30; template void multiple_transform(::std::vector &a) { int n = a.size(); ::std::vector sieve(n, true); for (int p = 2; p < n; ++p) { if (sieve[p]) { for (int k = (n - 1) / p; k != 0; --k) { sieve[k * p] = false; a[k] = (a[k] + a[k * p])%mod; } } } for (int i = 0; ++i != n;) { a[i] = (a[i] + a[0])%mod; } } template void inverse_multiple_transform(::std::vector &a) { int n = a.size(); ::std::vector sieve(n, true); for (int i = 0; ++i != n;) { a[i] = (a[i] - a[0] + mod)%mod; } for (int p = 2; p < n; ++p) { if (sieve[p]) { for (int k = 1; k * p < n; ++k) { sieve[k * p] = false; a[k] = (a[k] - a[k * p] + mod)%mod; } } } } int main(){ LL h,w;cin >> h >> w; vector a(h+1),b(w+1); for (int i = 1; i <= h; i++) { a[i] = h - i; } multiple_transform(a); for (int i = 1; i <= w; i++) { b[i] = w - i; } multiple_transform(b); vector c(max(h,w)+1,0); for (int i = 1; i <= min(h,w); i++) { c[i] = (a[i] * b[i])%mod; } inverse_multiple_transform(c); cout << ((h*(w-1)%mod) + (w*(h-1) %mod) + 2 * c[1])%mod << endl; return 0; }