#include <iostream>
#include <cstring>
#define MAX 31
using namespace std;
int main() {
int tests, n, m;
long long c[MAX][MAX];
memset(c, 0, sizeof(c));
for(int i = 0; i < MAX; i++) c[i][0] = 1;
for(int i = 0; i < MAX; i++)
for(int j = 1; j <= MAX; j++)
c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
cin >> tests;
while(tests--) {
cin >> n >> m;
cout << c[n][m - 1] << "\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2RlZmluZSBNQVggMzEKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmludCBtYWluKCkgewoJaW50IHRlc3RzLCBuLCBtOwoJbG9uZyBsb25nIGNbTUFYXVtNQVhdOwoJbWVtc2V0KGMsIDAsIHNpemVvZihjKSk7Cglmb3IoaW50IGkgPSAwOyBpIDwgTUFYOyBpKyspIGNbaV1bMF0gPSAxOwoJZm9yKGludCBpID0gMDsgaSA8IE1BWDsgaSsrKQoJCWZvcihpbnQgaiA9IDE7IGogPD0gTUFYOyBqKyspCgkJCWNbaV1bal0gPSBjW2kgLSAxXVtqXSArIGNbaSAtIDFdW2ogLSAxXTsKCWNpbiA+PiB0ZXN0czsKCXdoaWxlKHRlc3RzLS0pIHsKCQljaW4gPj4gbiA+PiBtOwoJCWNvdXQgPDwgY1tuXVttIC0gMV0gPDwgIlxuIjsKCX0KCQoJcmV0dXJuIDA7Cn0=