Թաքցված խնդիր
|Այս խնդիրը թաքցված է խմբագրական խրհրդի անդամի կողմից քանի որ կամ այն ոչ ճիշտ լեզվով է գրված,|կամ թեստային տվյալներն են սխալ, կամ խնդրի ձևակերպումը պարզ չէ։|

ACM_0070 - DERANGED EXAMS

   The first question on the Data Structures and Algorithms final exam has a list of N  terms and a second list of N  definitions.  Students are to match each term with the correct definition.

   Unfortunately, Joe, who wrote a Visual BASIC program in high school and assumed he knew all there was to know about Computer Science, did not bother to come to class or read the textbook. He has to guess randomly what the matches are. Let S(N, k) be the number of ways Joe can answer the question and get at least the first k matches wrong.

   For this problem, you will write a program to compute S(N, k).

Input

   The first line of input contains a single integer P , (1 P 1000), which is the number of data sets that follow. Each data set should be processed identically and independently.

   Each data set consists of a single line of input containing three space separated decimal integers. The first integer is the data set number. The second integer is the number, N (1 N 17), of terms to be matched in the question. The third integer is the number, k (0 k N ), of initial matches to be incorrect. 

Output

   For each data set there is a single line of output.  It contains the data set number followed by a single space which is then followed by the value of S(N, k).

Examples

stdin

stdout

1

4

1 4 1

2 7 3

3 10 5

4 17 17

1 18

2 3216

3 2170680

4 130850092279664

 


Ավելացրեց.Հրանտ Հովհաննիսյան
Ամսաթիվ.2014-01-05
Ժամանակի սահմանափակումը.1s
Ծրագրի տեքստի սահմանափակումը.50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Լեզուներ.Բոլորը բացի ASM32 ASM64 GAWK CLPS CLOJURE D ERL FSHARP FORTRAN GOSU HASK ICON ICK NEM NIM OBJC-CLANG PICO PIKE PYPY PYPY3 PY_NBC RUST SCM guile CHICKEN SED TCL WHITESPACE
Աղբյուրը.NA Greater New York 2013.E

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.