#include <iostream>
typedef unsigned long long ULL;
const int FindPopulation(const ULL k, const ULL n)
{
ULL** index;
index = new ULL *[k + 1];
for (ULL i = 0; i < k + 1; i++)
index[i] = new ULL[n + 1];
for (ULL i = 0; i < k + 1; i++)
{
for (ULL j = 0; j < n + 1; j++)
{
index[i][j] = 0;
}
}
ULL result = 0;
for (ULL i = 0; i <= k; i++)
{
for (ULL j = 0; j < n; j++)
{
if (i == 0) {
index[i][j] = j + 1;
}
else {
ULL h = index[i][(j == 0 ? 0 : (j - 1))];
index[i][j] = (h == 0 ? 0 : h) + index[i - 1][j];
}
//std::cout << index[i][j] << " ";
}
//std::cout << std::endl;
}
result = index[k][n - 1];
for (ULL i = 0; i < k; i++)
delete[] index[i];
delete[] index;
return result;
}
int main(void)
{
std::cin.tie(NULL);
std::cout.tie(NULL);
std::ios::sync_with_stdio(false);
int T = 0;
std::cin >> T;
for (decltype(T) i = 0; i < T; i++)
{
int k, n;
std::cin >> k;
std::cin >> n;
ULL result = FindPopulation(k, n);
std::cout << result << "\n";
}
return 0;
}