#include<bits/stdc++.h>

using namespace std;
const int N = 1010;
const int mod = 1e9 + 7;

int t, n, k;
int f[N][N][2];

int solve(int cur, int k, int dir) {
    if (k == 1) return 1;
    if (f[cur][k][dir] != -1) return f[cur][k][dir];
    int ans = 2;   //自己和复制体
    if (dir == 1) {   //正向
        if (cur < n) ans += solve(cur + 1, k, dir) - 1;
        ans %= mod;
        if (cur > 1) ans += solve(cur - 1, k - 1, 1 - dir) - 1;
        ans %= mod;
        f[cur][k][dir] = ans;
    } else {  //反向
        if (cur > 1) ans += solve(cur - 1, k, dir) - 1;
        ans %= mod;
        if (cur < n) ans += solve(cur + 1, k - 1, 1 - dir) - 1;
        ans %= mod;
        f[cur][k][dir] = ans;
    }
    return ans;
}

int main() {

    cin >> t;
    while (t--) {
        memset(f, -1, sizeof f);
        cin >> n >> k;
        cout << solve(1, k, 1) << endl;
    }

    return 0;
}