#include <bits/stdc++.h>

#define x first
#define y second

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<double, double> PDD;

const int N = 1010, mod = 1e9 + 7;

int n, sum_k;
int f[N][N];

int main()
{
	int _;
	cin >> _;
	while (_ -- )
	{
		memset(f, 0, sizeof f);
		
		cin >> n >> sum_k;
		
		for (int i = 1; i <= sum_k; i ++ ) f[i][0] = 1;
		
		for (int k = 1; k <= sum_k; k ++ )
			for (int i = 1; i <= n; i ++ )
				f[k][i] = (f[k][i - 1] + f[k - 1][n - i]) % mod;
		
		cout << f[sum_k][n] << endl;
	}
	return 0;
}
