#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;
int mod = 1e9+7;
ll dp[maxn][maxn];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin >> t;
    while(t--)
    {
        int n, k;
        cin >> n >> k;
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<=k; ++i) dp[0][i] = 1;
        for(int j=1; j<=n; ++j) dp[j][1] = 1;
        for(int i=1; i<=k; ++i)
        {
            for(int j=1; j<=n; ++j)
            {
                dp[j][i] = dp[j-1][i] + dp[n-j][i-1];
                dp[j][i] %= mod;
            }
        }
        cout << dp[n][k] << endl;
    }
    return 0;
}