#include using namespace std; const int MOD = 1e9 + 7; int main() { int H, W; cin >> H >> W; vector f(H); for (int i = 1; i < H; ++i) f[i] = H - i; vector g(W); for (int i = 1; i < W; ++i) g[i] = W - i; int n = max(H, W) + 1; f.resize(n); g.resize(n); auto convolve = [](vector a) { vector b = a; vector np(a.size()); for (int i = 2; i < a.size(); ++i) { if (np[i]) continue; for (int j = (a.size() - 1) / i; j; --j) { np[j * i] = 1; (b[j] += b[j * i]) %= MOD; } } return b; }; auto inv_convolve = [](vector a) { vector b = a; vector np(a.size()); for (int i = 2; i < a.size(); ++i) { if (np[i]) continue; for (int j = 1; j * i < a.size(); ++j) { np[j * i] = 1; (b[j] -= b[j * i]) %= MOD; } } return b; }; vector cf = convolve(f); vector cg = convolve(g); vector cfg(n); for (int i = 1; i < n; ++i) { cfg[i] = 1LL * cf[i] * cg[i] % MOD; } vector fg = inv_convolve(cfg); int ans = 2 * fg[1] % MOD; (ans += 1LL * W * (H - 1) % MOD) %= MOD; (ans += 1LL * H * (W - 1) % MOD) %= MOD; if (ans < 0) ans += MOD; cout << ans << endl; return 0; }