#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 1010 ;
const int mod = 1e9 + 7 ;
ll a[maxn] ;
ll b[maxn] ;

int main(){
	int t ;
	cin >> t ;
	while(t--){
		int n , k ;
		cin >> n >> k ;
		memset(a , 0 , sizeof(a)) ;
		memset(b , 0 , sizeof(b)) ;
 		if(k == 1){
			cout << 1 << endl ;
			continue ;
		}
		else if(n == 1){
			cout << 2 << endl ;
			continue ;
		}
		ll sum = 2 ;
		a[n] = 1 ;
		for(int i = n - 1 ; i >= 1 ; i--){
			a[i] += a[i+1] ;
			sum += a[i] ;
			sum %= mod ;
		} 
		int cnt = 1 ;
		k-- ;
		while(k != 1){
			if(cnt % 2){
				b[n] = 0 ;
				for(int i = n - 1 ; i >= 1 ; i--){
					b[i] = b[i+1] + a[i+1] ;
				//	cout << k << " " << b[i] << " " << i << endl ;
					b[i] %= mod ;
					sum += b[i] ;
					sum %= mod ;
				}
			}
			else{
				a[1] = 0 ;
				for(int i = 2 ; i <= n ; i++){
					a[i] = a[i-1] + b[i-1] ;
					a[i] = a[i] % mod ;
				//	cout << k << " " << a[i] << " " << i << endl ;
					sum += a[i] ;
					sum %= mod ;
				}
			}
			k-- ;
			cnt++ ;
		}
		cout << sum % mod << endl ;
	}
	return 0 ;
}