#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 50;
using ll = long long;
ll fac[N];
ll mod = 1e9 + 7;
ll qpow(ll a, ll b)
{
    ll ans = 1;
    for (; b; b >>= 1, a = a * a % mod)
        if (b & 1)
            ans = ans * a % mod;
    return ans;
}
ll inv(ll x) { return qpow(x, mod - 2); }
ll C(ll n, ll m)
{
    if (m > n || m < 0) return 0;
    return fac[n] * inv(fac[n - m] * fac[m] % mod) % mod;
}
int main()
{
    fac[0] = 1;
    for (int i = 1; i < N; i++) fac[i] = fac[i - 1] * i % mod;
    int T;
    cin >> T;
    while (T--)
    {
        long long m, n;
        cin >> m >> n;
        cout << ((C(n + m, m) - (C(n + m - 1, m - 1) * 2) % mod + mod) % mod) << endl;
    }
    return 0;
}
