#include #include using namespace std; typedef long long ll; const int MAX = 1000010; ll mod = 1000000007; vector gcd_trans(vector &v){ int i,j,n = v.size(); vector used(n,true); for(i=2;i=1;j--){ used[j*i] = false; (v[j] += v[j*i]) %= mod; } } return v; } vector inv_gcd_trans(vector &v){ int i,j,n = v.size(); vector used(n,true); for(i=2;i> h >> w; vector a(max(h,w) + 10),b(max(h,w) + 10); for(i=1;i<=h;i++){ a[i] = h - i; } for(i=1;i<=w;i++){ b[i] = w - i; } a = gcd_trans(a); b = gcd_trans(b); for(i=0;i<=max(h,w);i++){ (a[i] *= b[i]) %= mod; } b = inv_gcd_trans(a); ll ans = 2*b[1]%mod + 2*h*w%mod - h - w; while(ans<0) ans += mod; cout << ans%mod << endl; }