#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#define me(x,y) memset(x,y,sizeof(x))
#define rep(i, a, b) for(ll i=a;i<=b;i++)
#define rev(i, a, b) for(ll i=b;i>=a;i--)
using namespace std;
typedef long long ll;
const ll N = 1e3 + 7, MOD = 1e9 + 7;
ll t, n, k;
ll dp[N][N];

int main() {
	cin >> t;
	while (t--) {
		cin >> n >> k;
		me(dp, 0);
		rep(i, 1, n) dp[1][i] = 1ll;
		rep(i, 1, k) dp[i][0] = 1ll;
		rep(i,1,k)
			rep(j, 1, n) 
			dp[i][j] = (dp[i - 1][n - j] + dp[i][j - 1]) % MOD;
		cout << dp[k][n] << endl;
	}
}