#include <bits/stdc++.h>
using namespace std;
#define ll                  long long int
#define ull                 unsigned long long int
#define vll                 vector<ll>
#define vvl                 vector<vector<ll>>
#define vpii                vector<pair<ll, ll>> 
#define pii                 pair<ll, ll>
#define fr(i,j,n)           for(int i=j;i<n;++i)
#define frr(i,n,j)          for(int i=n-1;i>=j;--i)
#define inp(n)              ll n;cin>>n
#define inp2(n,m)           ll n,m;cin>>n>>m
#define inp3(n,a,b)         ll n,a,b;cin>>n>>a>>b
#define inps(s)             string s;cin>>s;
#define vin(v, n)           vector<ll>v; for(ll i=0;i<n;i++){inp(temp);v.push_back(temp);}
#define vpin(v, n)          vpii v;fr(i,0,n){inp2(x,y);v.pb(mp(x,y));}
#define vout(v)             fr(i,0,v.size()){cout<<v[i]<<" ";}cout<<'\n'
#define range(v)            v.begin(),v.end()
#define print(x)            cout<<x<<'\n'
#define print2(x,y)         cout<<x<<" "<<y<<'\n'
#define print3(x,y,z)       cout<<x<<" "<<y<<" "<<z<<'\n'
#define pyes                print("YES")
#define pno                 print("NO")
#define sv(v)               sort(range(v))
#define max3(a,b,c)         (a>b)?((a>c)?a:c):((b>c)?b:c)
#define maxv(v)             *max_element(v.begin(),v.end())
#define minv(v)             *min_element(v.begin(),v.end())
#define pb(e)               push_back(e)
#define mp(e1,e2)           make_pair(e1,e2)
#define ff                  first
#define ss                  second
#define up(v, x)            (upper_bound(range(v), x) - v.begin())
#define low(v, x)           (lower_bound(range(v), x) - v.begin())
#define fastio()            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll gcd(ll a, ll b)          {return b ? gcd (b, a % b) : a;}
ll sqr(ll n)                {return n*n;}
vector<bool> SieveOfEratosthenes(ll num) {vector<bool>soe;soe.assign(num+1, true);soe[0]=false;soe[1]=false;
    for (ll i=2;i*i<=num;i++){if(soe[i]==true){for(ll j=i*2;j<=num;j+=i)soe[j]=false;}}return soe;}
ll bs(vll &v,ll l,ll r,ll key){while(l+1<r){ll mid=(l+r)/2;if(v[mid]>key)r=mid;else l=mid;}return l;}
ll mod = 1e9+7;
int main()
{
    fastio();
    inp(t);
    while(t--)
    {
        inp2(n, k);
        ll ans = 0;
        if(k != 1)
            ans = 1;
        if(n == 1)
        {
            if(k == 1)
                print(1);
            else
                print(2);
            continue;
        }
        vll v(n-1, 0);
        v[0] = 1;
        ll flag = 0;
        while(k != 0)
        {
            ll s=0;
            if(flag==0)
            {   
                s = 0;
                fr(i, 0, n-1)
                {
                    v[i] += s;
                    v[i]%=mod;
                    s = v[i];
                }
                s%=mod;
                ans += s;
                ans%=mod;
                flag = 1;
            }
            else
            {
                s = 0;
                frr(i, n-1, 0)
                {
                    v[i] +=s;
                    v[i]%=mod;
                    s = v[i];
                }
                s%=mod;
                ans+=s;
                ans%=mod;
                flag = 0;
            }
            //vout(v);
            k--;
        }
        print(ans);
        cout.flush();
    }

}