#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define ll __int64 #define mod 1000000007 int scan() { int res = 0 , ch ; while( !( ( ch = getchar() ) >= '0' && ch <= '9' ) ) { if( ch == EOF ) return 1 << 30 ; } res = ch - '0' ; while( ( ch = getchar() ) >= '0' && ch <= '9' ) res = res * 10 + ( ch - '0' ) ; return res ; } int main() { ll x,y,z,i,t; scanf("%I64d",&x); while(x--) { scanf("%I64d%I64d",&y,&z); ll hehe=z*(z+1)/2; if(y0;i--) { if(yu) ans*=(mid+i+1),yu--; else ans*=(mid+i); ans%=mod; } } else { for(i=z/2;i>0;i--) { if(yu) ans*=(mid+i+1),yu--; else ans*=(mid+i); ans%=mod; } if(yu) ans*=(mid+1),yu--; else ans*=mid; ans%=mod; for(i=1;i<=z/2;i++) { if(yu) ans*=(mid-i+1),yu--; else ans*=(mid-i); ans%=mod; } } printf("%I64d\n",ans); } return 0; }