#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int dp[1005][1005][2],n,k,m=1000000007;
int solve(int i,int curr,int d){
    if(curr == 0)return 0;
    if(i == 0)return 1;
    if(i == n+1)return 1;
    if(dp[i][curr][d]!=-1)return dp[i][curr][d];
    if(d)return dp[i][curr][d]=(solve(i+1,curr,d)+solve(i-1,curr-1,1-d))%m;
    return dp[i][curr][d]=(solve(i+1,curr-1,1-d)+solve(i-1,curr,d))%m;
}
int main()
{
//   freopen("measurement.in", "r", stdin);
//  freopen("measurement.out","w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int t;
    cin>>t;
    while(t--){
        cin>>n>>k;
        memset(dp,-1,sizeof dp);
        cout<<solve(1,k,1)<<endl;
    }
        return 0;

}
