#include<iostream>
#include<vector>
#include<algorithm>
#include<random>
#include<ctime>
#include<cassert>
#include<map>

using namespace std;

const int MOD = 1e9 + 7;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t;
	cin >> t;
	while (t--) {
		int n, k;
		cin >> k >> n;
		vector<vector<int>> a(n, vector<int>(k + 1, 1));
		for (int i = 1; i < n; ++i)
			for (int j = 0; j <= k; ++j) {
				if (j != 0)
					a[i][j] = (1ll * a[i][j - 1] + a[i - 1][k - j]) % MOD;
			}
		cout << a[n - 1][k] << '\n';
	}
}