#include <iostream>
#include <vector>
using namespace std;
int comb[31][31];
int compute(int M, int N);
int main()
{
	comb[0][0] = 1;
	for (int i = 0; i < 31; i++){
		comb[i][0] = 1;
		comb[i][1] = i;
		for (int j = 1; j < 31; j++) {
			comb[i][j] = -1;
		}
	}
	int T, M, N;
	vector<int> output;
	cin >> T;
	for (int i = 0; i < T; i++) {
		cin >> N >> M;
		output.push_back(compute(M, N));
	}
	vector<int>::iterator iter = output.begin();
	vector<int>::iterator end = output.end();
	while (iter != end) {
		cout << *iter << endl;
		iter++;
	}


	return 0;
}
int compute(int M, int N) {
	if (comb[M][N] != -1) { return comb[M][N]; }
	comb[M][N] = compute(M - 1, N)+ compute(M - 1, N - 1);
	return comb[M][N];
}