#include <iostream>
#include <cstring>
using namespace std;
const int N = 2010, mod = 1e9 + 7;
int c[N];
int main()
{
int n;
cin >> n;
while(n -- )
{
int a, b;
cin >> a >> b;
memset(c, 0, sizeof c);
c[0] = 1;
for(int i = 1; i <= a; i ++ )
for(int j = i; j > 0; j -- )
c[j] = (c[j - 1] + c[j]) % mod;
printf("%d\n", c[b]);
}
return 0;
}