// Arup Guha
// Solution to 2011 NY Regional Problem H: Maximum in the Cycle of 1
// 10/22/2012

import java.util.*;

public class h {
	
	public static void main(String[] args) {
		
		Scanner stdin = new Scanner(System.in);
		
		int numC = stdin.nextInt();
		
		// Loop through cases.
		for (int loop=0; loop<numC; loop++) {
			
			int caseNum = stdin.nextInt();
			int n = stdin.nextInt();
			int k = stdin.nextInt();
			
			System.out.println(caseNum+" "+solve(n,k));
			
		}
	}
	
	// Solve the problem for n and k.
	public static long solve(int n, int k) {
		
		// Case where 1 goes to itself, everything else can be anything.
		if (k == 1) return fact(n-1);
		
		// Add up all possible cases where we loop over each set of values in
		// [2, k-1] being part of the cycle which 1 and k are required to be in.
		long ans = 0;
		for (int i=0; i<=k-2; i++) {
			ans = ans + fact(i+1)*fact(n-i-2)*combo(k-2, i);
		}
		
		return ans;
		
	}
	
	// Returns n factor.
	public static long fact(int n) {
		long ans = 1;
		for (int i=1; i<=n; i++)
			ans = ans*i;
		return ans ;
	}
	
	// Returns n choose k.
	public static long combo(int n, int k) {
		return fact(n)/fact(k)/fact(n-k);
	}
}