#include<bits/stdc++.h>
using namespace std;
#define i64 int64_t
#define i32 int32_t
#define ll long long int
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define pii pair<int,int>
#define sz(x) ((int)x.size())
template<typename T, typename U> inline void amin(T &a,U b) { a = (a > b ? b : a);}
template<typename T, typename U> inline void amax(T &a,U b) { a = (a > b ? a : b);}

const int mod = 1e9 + 7, N = 1006;
i64 dp[N][N][2], n, k;
i64 solve(int i, int age, int dir) {
    if(i < 1 or i > n) {
        return 0;
    }
    /* age = 1 particle produces 0 new particles */
    if(age == 1) {
        return dp[i][age][dir] = 0;
    }
    if(dp[i][age][dir] != -1) {
        return dp[i][age][dir];
    }
    if(dir == 0) {
        /* | ->| | =>    |<= | ->| (|: plane, -> D(age), <= D(age - 1))  */
        return (dp[i][age][dir] = 1 + (solve(i - 1, age - 1, dir^1)) + solve(i + 1, age, dir))% mod;
    } else {
        /* | |<- | =>    |<- | =>| (|: plane, -> D(age), <= D(age - 1))  */
        return (dp[i][age][dir] = 1 + (solve(i + 1, age - 1, dir^1)) + solve(i - 1, age, dir))% mod;
    }
}

void solve(){
    cin >> n >> k;
    memset(dp, -1, sizeof dp);
    cout << solve(1, k, 0) + 1 << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
    int tests = 1; 
    cin >> tests;
    while(tests--){
       solve(); 
    }
    #ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * DON'T GET STUCK ON ONE APPROACH
*/