#include <bits/stdc++.h>

using namespace std;
#define int long long
const int mod=1e9+7;
int32_t main()
{
   int t; cin>>t;
   while(t--)
   {
      int n,k; cin>>n>>k;
      if(k==1)
     {
         cout<<1<<endl;
         continue;
     }
      vector<vector<int>>dp(k+2,vector<int>(n+1,0));
      dp[k][1]=1;
      int ans=n+1;
      for(int i=2;i<=n;i++)
      dp[k-1][i]=1; 
      int turn=2;
      for(int i=k-2;i>=1;i--)
      {
          if(turn==1)
          {
              for(int j=2;j<=n;j++)
              {
                  
                  dp[i][j]=(dp[i+1][j-1]+dp[i][j-1])%mod;
                  ans+=dp[i][j];
                  ans%=mod;
              }
              turn=2;
          }
          else
          {
              for(int j=n-1;j>=1;j--)
              {
                  dp[i][j]=(dp[i+1][j+1]+dp[i][j+1])%mod;
                  ans+=dp[i][j];
                  ans%=mod;
              }
              turn=1;
          }
      }
      cout<<ans<<endl;
       
   }
}