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

const int N = 1e3 + 10;
const int mod = 1e9 + 7;
int f[N], g[N];

int main() {
    int t;
    scanf("%d", &t);
    while (t--) {
        memset(g, 0, sizeof(g));
        int n, k;
        scanf("%d%d", &n, &k);
        if (k == 1) puts("1");
        else if (n == 1) puts("2");
        else {
            int res = 1, cnt = 0;
            while (k--) {
                ++cnt;
                if (cnt == 1) {for (int i = 2; i <= n; ++i) f[i] = 1; res += 1;}
                else if (!(cnt & 1)) {
                    for (int i = n - 1; i >= 1; --i) {
                        res = (res + f[i + 1]) % mod;
                        g[i] = (f[i + 1] + g[i + 1]) % mod;
                    }
                } else {
                    for (int i = 2; i <= n; ++i) {
                        res = (res + g[i - 1]) % mod;
                        f[i] = (f[i - 1] + g[i - 1]) % mod;
                    }
                }
            }
            printf("%d\n", res);
        }
    }
    return 0;
}