#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <deque>
#include <climits>

using namespace std;

#define int long long
#define ll long long 
const int mod = 1e9 + 7;
const long double epsilon = -1e6;
const int INF = 1e16;

vector <vector <vector <int> >> dp;

int n;

int dfs(int plane , int k , int dir){
	if (plane == n ) return 1;
	if (plane == -1) return 1;

	if (dp[plane][k][dir] != -1) return dp[plane][k][dir];

	int ans = 0;
	if (dir == 0){
		if (k == 1){
			ans += dfs(plane + 1 , k , dir);
			ans %= mod;
		}
		else {
			ans += dfs(plane - 1 , k - 1 , 1 - dir);
			ans %= mod;
			ans += dfs(plane + 1 , k , dir);
			ans %= mod;

		}
	}

	else {
		if (k == 1){
			ans += dfs(plane - 1, k , dir);
			ans %= mod;
		}
		else {
			ans += dfs(plane + 1 , k - 1 , 1 - dir);
			ans %= mod;
			ans += dfs(plane - 1, k , dir);
			ans %= mod;
		}
	}

	return dp[plane][k][dir] = ans;
}

void solve(){
	int k;
	cin >> n >> k;

	dp = vector <vector <vector <int> > >  (n + 1 , vector <vector <int>> (k + 1 , vector <int> (2 , -1)));

	int ans = dfs(0 , k , 0);
	cout << ans << endl;
}

signed main(){

	int t;
	cin >> t;


	while (t--){
		solve();
	}

	return 0;
}

