/*
ID: c4ts0up
LANG: C++
TASK: 
URL: 
*/

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

typedef long long ll;
typedef long double ld;
#define pb push_back
#define ff first
#define ss second
#define endl "\n"

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MOD = 1e9+7, NMAX = 1005;
ll t, n, k;

ll dp[NMAX][NMAX][2];
bool vis[NMAX][NMAX][2];

// devuelve la cantidad de particulas generadas por esta
ll Generadas(ll tam, ll pla, bool dir) {
    // Caso base
    if (tam == 1) return 1LL;
    else if (pla < 0 || pla >= n) return 1LL;
    // Caso dp
    else if (vis[tam][pla][dir]) return dp[tam][pla][dir];
    // Caso recursivo
    else {
        if (dir) dp[tam][pla][dir] = (Generadas(tam-1, pla-1, !dir) + Generadas(tam, pla+1, dir))%MOD;
        else dp[tam][pla][dir] = (Generadas(tam-1, pla+1, !dir) + Generadas(tam, pla-1, dir))%MOD;

        vis[tam][pla][dir] = true;
        return dp[tam][pla][dir];
    }
}

int main() {
    /*//
    freopen("entrada.in", "r", stdin);
    freopen("salida.out", "w", stdout);
    //*/

    cin >> t;
    while (t--) {
        cin >> n >> k;
        for (int i=0; i<=n; i++) {
            for (int j=0; j<=k; j++) vis[j][i][0] = vis[j][i][1] = false; 
        }
        cout << Generadas(k, 0, 1) << endl;
    }
    //system("pause");
    return 0;
}