F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

KK's Chemical

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 268    Accepted Submission(s): 102


Problem Description
Our lovely KK has a difficult Chemical problem.
There are $N\left(1\leq N\leq 100 \right)$ bottles of chemicals in the laboratory numbered from $0$ to $N-1$.
KK was told to tidy up the laboratory.
He needs to put them in K $\left(1\leq K\leq 1000 \right)$ different boxes.
KK knows that it may cause explosion if the bottle numbered $i$ and the bottle numbered $c[i]$ been put in the same box.
In order to survive, KK can not put any two bottles of chemicals that will cause the explosion in the same box.
Now KK wants to know how many different ways are there that he can put the bottles in boxes safely.
As the number may be huge, you should output the number mod ${10}^{9}+7$.
It's guaranteed that $c[i] \neq i$.
 

Input
The first line of the input file contains an integer $T\left( 1\leq T\leq 200\right)$, which indicates the number of test cases.

For each test case, there are two lines.

The first line includes two integers $N\left(1\leq N\leq 100 \right)$ and $K\left(1\leq K\leq 1000 \right)$,indicating the number of the chemicals and the number of the boxes.

The second line includes $N$ integers $c[i]\left( 0\leq c[i]\leq N-1\right)$.
 

Output
For each test case, there are one lines,includes a integer,indicating the answer mod ${10}^{9}+7$.
 

Sample Input
3 3 3 1 2 0 4 3 1 2 0 0 3 2 1 2 0
 

Sample Output
6 12 0
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-10 01:48:16, Gzip enabled