Under construction

Still being built. Things may change

Algorithm Final Exam

Time limit1sMemory limit128 MB

Summary
Count permutations of N items in which the first k positions are all wrong.
Level

Medium5 of 10

Topics
Combinatorics, Math
Solved
No attempts yet

Problem

The algorithm final exam asks for one thing only, connecting terms to definitions with lines. The left column lists NN terms and the right column lists NN definitions, each in a single row, and a student draws one line from every term to a definition. Two different terms go to two different definitions, so one answer sheet is a permutation that maps terms to definitions.

Seonyeong trusted her programming skill and did not study. The exam had nothing to do with programming, so she guesses every line.

Let S(N,k)S(N,k) be the number of answer sheets in which the first kk terms from the top are all wrong once Seonyeong has drawn every line. The remaining N−kN-k terms may be right or wrong.

Given NN and kk, write a program that computes S(N,k)S(N,k).

Input

The first line contains the number of test cases. Each test case is one line holding the test case number and two integers NN and kk, separated by spaces. (1≤N≤171 \le N \le 17, 0≤k≤N0 \le k \le N)

Output

For each test case, print the test case number given in the input and S(N,k)S(N,k) on one line, separated by a single space.

Examples1

  1. Example 1

    Input
    4
    1 4 1
    2 7 3
    3 10 5
    4 17 17
    
    Expected output
    1 18
    2 3216
    3 2170680
    4 130850092279664