#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const ll mod = 1e9+7;

int t,n,k;
ll dp[1010][1010];

ll dfs(int sum,int age)
{
    //printf("%d %d\n",sum,age);
    if(dp[sum][age] != -1) return dp[sum][age];

    if(age == 1) return 1;
    if(sum < 1) return 1;

    return dp[sum][age] = ( dfs(sum-1,age)+dfs(n-sum,age-1)) % mod;
}

int main()
{
    scanf("%d",&t);
    while(t--){
        scanf("%d%d",&n,&k);
        memset(dp,-1,sizeof dp);
        printf("%lld\n",dfs(n,k));
    }
    return 0;
}
