#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N = 1e5 + 10, mod = 1e9 + 7;
int heat[N], inheat[N];//分别储存i的阶乘和i的阶乘的逆元
int qmi(int a, int k, int p){//快速幂
int res = 1;
while(k){
if(k & 1) res = (ll)res * a % mod;
a = (ll)a * a % mod;
k >>= 1;
}
return res;
}
int main()
{
heat[0] = inheat[0] = 1;
for(int i = 1; i <= N; i ++ ){
heat[i] = (ll)heat[i - 1] * i % mod;
inheat[i] = (ll)inheat[i - 1] * qmi(i, mod - 2, mod) % mod;
}
int n;
cin>>n;
while(n -- ){
int a, b;
cin>>a>>b;
int t = (ll)heat[a] * inheat[a - b] % mod * inheat[b] % mod;//公式
cout<<t<<endl;
}
return 0;
}