//codeforces template
#define MANY_SUBTASK
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
const int mod = 1e9+7;
using namespace std;

int dp[1010][1010];
void solve_subtask() {
    memset(dp, 0, sizeof dp);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) dp[i][1] = 1;
    for (int i = 1; i <= k ;i++) dp[0][i] = 1;
    for (int j = 1; j <= k; j++) {
        for (int i = 1; i <= n; i++) {
            dp[i][j] = (dp[i-1][j] + dp[n-i][j-1]) % mod;
        }
    }
    cout << dp[n][k] << "\n";
}
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int cnt = 1;
#ifdef MANY_SUBTASK
    cin >> cnt;
#endif
    while (cnt--) {
        solve_subtask();
    }
    return 0;
}