#include<bits/stdc++.h>
using namespace std;
#define ll long long
const long long mod = 1e9 + 7;
ll dp[1010][1010];
void solve(){
	int n,k;
	cin>>n>>k;
	memset(dp,0,sizeof(dp));
	for(int i=0;i<=n;i++) dp[i][1]=1;
	for(int j=1;j<=k;j++) dp[0][j]=1; 
	for(int j=1;j<=k;j++){
		for(int i=1;i<=n;i++){
			dp[i][j]=(dp[i-1][j]+dp[n-i][j-1])%mod;
		//	cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	//cout<<"---------------------------------"<<endl;
/*	for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++)
        cout<<dp[i][j]<<" ";
        cout<<endl;
	}*/
	cout<<dp[n][k]%mod<<endl;
}
int main(){
	int t;cin>>t;
	while(t--){
		solve();
	}
	return 0;
} 
