//#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"

using namespace std;

#define pb push_back
#define F first
#define S second
typedef long long ll ;
typedef pair<int , int> pii;
typedef pair<ll, ll> pll;
typedef pair<pll , int> pip;
const ll N = 1e3 + 5 , inf = 1e15 , mod = 1e9 + 7 , base = 27;

ll dpl[N][N] , dpr[N][N];

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll t;
    cin >> t;
    while(t--){
        ll n , k;
        cin >> n >> k;
        for(int i = 1 ; i <= n ; i ++){
            dpl[i][1] = 1;
            dpr[i][1] = 1;
        }
        for(int i = 2 ; i <= k ; i ++){
            for(int j = 1 ; j <= n ;j ++){
                if(j == n)dpl[j][i] = 1 + dpl[j-1][i];
                else if(j == 1)dpl[j][i] = 1 + dpr[j+1][i-1];
                else dpl[j][i] = dpl[j-1][i] + dpr[j+1][i-1];
                dpl[j][i] %= mod;
            }
            for(int j = n ;j >= 1 ; j --){
                if(j == 1)dpr[j][i] = 1 + dpr[j+1][i];
                else if(j == n)dpr[j][i] = 1 + dpl[j-1][i-1];
                else dpr[j][i] = dpr[j+1][i] + dpl[j-1][i-1];
                dpr[j][i] %= mod;
            }
        }
        if(n == 1 && k > 1)cout << 2 << endl;
        else cout << dpr[1][k] << endl;
        for(int i = 1 ; i <= n ;i ++){
            for(int j = 1 ; j <= k ;j ++){
                dpl[i][j] = 0;
                dpr[i][j] = 0;
            }
        }
    }

    return 0;
}
