////#include <iostream>
////#include <cstdio>
////#include <cstring>
////#include <algorithm>
////
////#define LL long long
////
////LL gcd(LL a,LL b) {
////    if(b == 0) return a;
////    else return gcd(b,a % b);
////}
////
////inline LL calc(LL x) {
////    LL ret = 0;
////    while(x) {
////        ret += x % 10;
////        x /= 10;
////    }
////    return ret;
////}
////
////int main() {
////    int T; scanf("%d",&T);
////    LL n,x;
////    while(T--) {
////        scanf("%lld",&n);
////        x = 0;
////        for(LL i=n; i; i++) {
////            if(gcd(i,calc(i)) >= 2) {
////                printf("%lld\n",i);
////                break;
////            }
////        }
////    }
////    return 0;
////}
//
//#include <iostream>
//#include <cstring>
//#include <cstdio>
//#include <algorithm>
//#include <map>
//#define Maxn 100005
//using namespace std;
//int a[1005000];
//map<int,int> mp;
//int main(int argc,char* argv[]) {
//    int T; scanf("%d",&T);
//
//    while(T--) {
//        mp.clear();
//        int k = 524288,tmp = k;
//        while (tmp) {
//            a[tmp] = 0;
//            tmp >>= 1;
//        }
//        int n,w,x,ans = 0;
//        cin >> n >> w;
//        for(int i=0; i<n; i++) cin >> x,a[x]++;
//        while(n) {
//            int tmp = k,sum = w;
//            while(tmp) {
//                if(a[tmp]) {
//                    int cnt = sum / tmp;
//                    cnt = min(cnt,a[tmp]);
//                    sum -= cnt * tmp;
//                    a[tmp] -= cnt;
//                    n -= cnt;
//                }
//                tmp >>= 1;
//            }
//            ans++;
//        }
//        cout << ans << endl;
//    }
//    return 0;
//}

#include <iostream>
#include <cstring>
#include <cstdio>
#define Maxn 1005
using namespace std;
int dp[Maxn][Maxn];
const int Mod = 1e9 + 7;

int solve(int n,int k,int total) {
    if(n <= 0 || k <= 1) return 1;
    else {
        if(dp[n][k] == -1)
            dp[n][k] = ((solve(n - 1,k,total) % Mod + solve(total - n,k - 1,total) % Mod)) % Mod;
        return (dp[n][k] % Mod);
    }
}

int main(int argc,char* argv[]) {
    int T,n,k; scanf("%d",&T);
    while(T--) {
        scanf("%d %d",&n,&k);
        memset(dp,-1,sizeof(dp));
        cout << solve(n,k,n) << endl;
    }

    return 0;
}