const N = require("fs").readFileSync(0, "utf8").toString().trim().split('\n').map(Number);
let arr = Array.from({length : 15}, () => new Array(14).fill(0));
arr[0] = arr[0].map((v,i) => v = i+1);
for(let i=1; i<15; i++) {
    arr[i].forEach((v, idx, row) => {
        if(idx===0) row[idx] = 1;
        else {
            row[idx] = row[idx-1] + arr[i-1][idx];
        }
    });
}

for(let t=1; t<=N[0]; t++) {
    let [k, n] = [N[2*t-1], N[2*t]-1];
    console.log(arr[k][n]);
}