#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- ll mo=1000000007; ll H,W; ll A[3030303]; vector P[3030303]; void solve() { int i,j,k,l,r,x,y; string s; cin>>H>>W; ll ret=0; // 横と縦 ret=((W-1)*H+(H-1)*W)%mo; for(y=1;y<=H-1;y++) A[y]=H-y; for(y=1;y<=3000000;y++) { for(i=y*2;i<=3000000;i+=y) A[y]+=A[i]; A[y]%=mo; } for(y=2;y<=3010101;y++) if(P[y].empty()) { for(i=y;i<=3010101;i+=y) P[i].push_back(y); } ll v=0; for(x=1;x<=W-1;x++) { int mask; FOR(mask,1<