Secret Santa

Time limit: 0.2s Memory limit: 64MB Input: Output:

Christmas is just around the corner and John's colleagues decided to organize a Secret Santa.

According to Google, Secret Santa is a Western Christmas tradition in which members of a group or community are randomly assigned a person to whom they give a gift.

There are NN students in John's class (him included) and he is very curious to know the number of possible ways Secret Santa can be organized. The number John asks being big, you should output it modulo 109+710^9 + 7

Because there are a lot of John's on the planet, you will need to answer QQ queries regarding the possible ways Secret Santa can be organized in John's class. A valid way of organizing Secret Santa is a way such that no child gets gifts from two different children and there is no child who has to give a gift to himself/herself.

Input data

The first line of the input contains an integer QQ, the number of queries.

Each of the following QQ lines contains an integer NN.

Output data

The output will contain on each line the answer for the corresponding test case.

Constraints and clarifications

  • 1Q1051 \leq Q \leq 10^5
  • 2N1052 \leq N \leq 10^5
  • For tests worth 1010 points, 2N202 \leq N \leq 20.
  • For tests worth another 5050 points, the sum of all NN in the input doesn't exceed 200 000200 \ 000.

Example 1

stdin

4
5
6
9
12

stdout

44
265
133496
176214841

Log in or sign up to be able to send submissions!