SAC '22 Code Challenge 5 P3 - Querying Presents

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

Mr. DeMello has decided to sabotage the marks of his Ni student advisory!

To do this, he will assign each student the exams of another student in the advisory, ensuring no student gets their original exams.

Since you are not in Mr. DeMello's advisory (and want to ruin your friends' marks), he asks you to calculate the number of ways for him to assign the exams in his advisory mod109+7.

Can you help him?

Constraints

1T100

Subtask 1 [30%]

1Ni8

Subtask 2 [70%]

1Ni106

Input Specification

The first line will contain an integer, T, the number of test cases.

The next T lines will contain an integer, Ni, the number of students in his advisory.

Output Specification

Output T lines, the number of ways to assign each student the exams of another student in each advisory mod109+7.

Sample Input

Copy
3
3
8
13

Sample Output

Copy
2
14833
290792918

Explanation for Sample Output

For the first test case, there are 2 different assignments:


Comments

There are no comments at the moment.