#include <iostream>
using namespace std;
int k = 1000000007;
long long f(long long a)
{
if(a<2)
return 1;
else
return (a*f(a-1))%k;
}
long long modpow(long long base, long long exp, long long modulus)
{
base %= modulus;
long long result = 1;
while(exp > 0)
{
if(exp & 1)
result = (result * base) % modulus;
base = (base * base) % modulus;
exp >>= 1;
}
return result;
}
int main()
{
int t,m,n;
cin >> t;
while(t--)
{
cin >> m >> n;
long long temp = (f(n-1)%k*f(m-1)%k)%k;
temp = modpow(temp,k-2,k); //(f(n)*f(m-1))^(10000000007-2)
long long result = (f(n+m-2)%k*temp%k)%k;
cout << result << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IGsgPSAxMDAwMDAwMDA3OwoKbG9uZyBsb25nIGYobG9uZyBsb25nIGEpCnsKICAgIGlmKGE8MikKICAgICAgICByZXR1cm4gMTsKICAgIGVsc2UKICAgICAgICByZXR1cm4gKGEqZihhLTEpKSVrOwp9Cgpsb25nIGxvbmcgbW9kcG93KGxvbmcgbG9uZyBiYXNlLCBsb25nIGxvbmcgZXhwLCBsb25nIGxvbmcgbW9kdWx1cykKewogICAgYmFzZSAlPSBtb2R1bHVzOwogICAgbG9uZyBsb25nIHJlc3VsdCA9IDE7CgogICAgd2hpbGUoZXhwID4gMCkKICAgIHsKICAgICAgICBpZihleHAgJiAxKQogICAgICAgICAgICByZXN1bHQgPSAocmVzdWx0ICogYmFzZSkgJSBtb2R1bHVzOwoKICAgICAgICBiYXNlID0gKGJhc2UgKiBiYXNlKSAlIG1vZHVsdXM7CiAgICAgICAgZXhwID4+PSAxOwogICAgfQoKICAgIHJldHVybiByZXN1bHQ7Cn0KCgppbnQgbWFpbigpCnsKICAgIGludCB0LG0sbjsKICAgIGNpbiA+PiB0OwoKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICBjaW4gPj4gbSA+PiBuOwoKCiAgICAgICAgbG9uZyBsb25nIHRlbXAgPSAoZihuLTEpJWsqZihtLTEpJWspJWs7CiAgICAgICAgdGVtcCA9IG1vZHBvdyh0ZW1wLGstMixrKTsgLy8oZihuKSpmKG0tMSkpXigxMDAwMDAwMDAwNy0yKQoKICAgICAgICBsb25nIGxvbmcgcmVzdWx0ID0gKGYobittLTIpJWsqdGVtcCVrKSVrOwoKICAgICAgICBjb3V0IDw8IHJlc3VsdCA8PCBlbmRsOwogICAgfQoKICAgIHJldHVybiAwOwp9
OQo1MjQ2NDUgMzc5MDE4CjkzNDEyNiA4ODg3NzEKODc3MjU1IDE4NzAwMgo3OTQzNzYgNzA0MzIwCjUxNTQyOSA5MjU3MDYKNzQ0NjQxIDU0NDcwMQo1MDA4MzEgMTQ3NDQzCjEzNDI0MSA1NDQxNjcKNDY2NzU1IDI2MzE4Ng==
9
524645 379018
934126 888771
877255 187002
794376 704320
515429 925706
744641 544701
500831 147443
134241 544167
466755 263186