#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
#define ll long long
#define pb push_back
#define pii pair<int,int>
const int N = 3e5 + 10;
const int mod = 1e9 + 7;
using namespace std;

template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}

int n, k, dp[1010][1010], vis[1010][1010];

int dfs(int p, int k){
    if(~dp[p][k]) return dp[p][k];
    if(p == 0 || k == 1) return dp[p][k] = 1;
    int ans = dfs(p - 1, k) + dfs(n - p, k - 1);
    if(ans >= mod) ans -= mod;
    return dp[p][k] = ans;
}

void Solve(){
    memset(dp, -1, sizeof dp);
    scanf("%d%d", &n, &k);
    printf("%d\n",dfs(n, k));
}

signed main(){   
    // freopen("data.in", "r", stdin);
    int T=1; 
    scanf("%d",&T);
    while(T--)
        Solve();
    // system("pause");
    return 0;
}
