#include <bits/stdc++.h>
#define ll long long
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
const int MOD = 1e9 + 7;

const int N=1001;
const int K=1001;
int dp[N][K][2];
int n,k;

int solve(int plane , int k, int dir )
{
    if(k==1)
    return 1;

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

    int ans=2;  // the intial particle and its copy

    if(dir==1)
    {
        if(plane<n)  //intital particle
        {
            ans+=solve(plane+1,k,dir)-1;
        }
        ans%=MOD;

        if(plane>1)  //reflected particle
        {
            ans+=solve(plane-1,k-1,1-dir)-1;
        }
        ans%=MOD;

        dp[plane][k][dir]=ans;
    }
    else
    {
        if(plane>1)
        {
            ans+=solve(plane-1,k,dir)-1;
        }
        ans%=MOD;
        if(plane<n)
        {
            ans+=solve(plane+1,k-1,1-dir)-1;
        }
        ans%=MOD;

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

int main()
{
    boost;
    int t;
    cin>>t;
    while(t--)
    {
        cin>>n>>k;
        memset(dp,-1,sizeof(dp));
        cout<<solve(1,k,1)<<'\n';
    }
    
    return 0;
}