#include <bits/stdc++.h>
using namespace std;

void solve()
{
    long long k, n;
    cin >> n >> k;
    vector<pair<long long, long long>> dp[2];
    dp[0].resize(n+2);
    dp[1].resize(n+2);
    fill(dp[0].begin(), dp[0].end(), make_pair(0LL, 0LL));
    fill(dp[1].begin(), dp[1].end(), make_pair(1LL, 1LL));

    for (int i = 2; i <= k; i++)
    {
        dp[i % 2][0]= {1LL,1LL};
        dp[i % 2][n + 1] = {1LL,1LL};
        for (int e = 1; e <= n; e++)
        {
            dp[i % 2][e].second = (dp[i % 2][e - 1].second + dp[(i - 1) % 2][e+1].first) % 1000000007;
        }
        for (int e = n; e >= 1; e--)
        {
            dp[i % 2][e].first = (dp[i % 2][e + 1].first + dp[(i - 1) % 2][e-1].second) % 1000000007;
        }
    }
    cout<<dp[k%2][1].first<<"\n";
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}