#include "bits/stdc++.h"
using namespace std; 
#define all(c) c.begin(),c.end()
#define sz(x) int(x.size())
#define ar array
typedef long long ll ; 
typedef vector<int> vi;
#define mod 1000000007
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll exp(ll x,ll y){
  x%=mod;
  ll res=1;
  while(y){
    if(y&1)
    res=res*x%mod;
    x=x*x%mod;
    y>>=1;
  }
  return res;
}
ll fact(ll n){
  ll res=1;
  for(ll i=2;i<=n;++i)
  (res*=i)%=mod;
  return res;
}
bool isprime(ll n){
  if(n<=1) return 0;
  for(ll i=2;i*i<=n;++i)
  if(n%i==0) return 0;
  return 1;
}
ll dp[1002][1002][2];
int n,k;
ll cal(int i,int dec,int d){
  if(dec==1) return dp[i][dec][d]=1;
  if(dp[i][dec][d]!=-1) return dp[i][dec][d];
  ll sum=2;
  if(d==0){
    if(i+1<=n)  sum+=(cal(i+1,dec,d)+mod-1)%mod;
    if(i-1>0) (sum+=(cal(i-1,dec-1,1-d)+mod-1)%mod)%=mod;
  }
  else {
    if(i-1>0) sum+=(cal(i-1,dec,d)+mod-1)%mod;
    if(i+1<=n) (sum+=(cal(i+1,dec-1,1-d)+mod-1)%mod)%=mod;
  }
  return dp[i][dec][d]=sum;
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin>>t;
while(t--){
  cin>>n>>k;
  memset(dp,-1,sizeof(dp));
  cout<<cal(1,k,0)<<'\n';
}
   return 0;
}
