import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Solution {

    public static void main(String[] args) {
        /* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
        
        Scanner sc = new Scanner(System.in);
        int tests = sc.nextInt();
        
        for(int t = 0; t < tests; t++) {
            BigInteger n = sc.nextBigInteger(),
                       k = sc.nextBigInteger();
            
            System.out.println(choose(n, k));
        }
        
    }
    
    private static BigInteger choose_helper(BigDecimal c, BigInteger n, BigInteger cache_n_minus_i_plus_1, BigInteger i) {
		if (i.equals(BigInteger.ZERO))
			return c.toBigInteger();
		else
			return choose_helper(
                c.multiply(new BigDecimal(cache_n_minus_i_plus_1).divide(new BigDecimal(i))), 
                n, cache_n_minus_i_plus_1.subtract(BigInteger.ONE), i.subtract(BigInteger.ONE));
	}

	// n choose k: distinct subsets of k items chosen from n items
	public static BigInteger choose(BigInteger n, BigInteger k) {
        BigInteger low_k = n.subtract(k).min(k);
        return choose_helper(BigDecimal.ONE, n, n.subtract(k).add(BigInteger.ONE), n.subtract(k).min(k));
	}
}