Algebraic Teamwork

No attempts yetTime limit3sMemory limit256 MB

Problem

Researchers in group theory and researchers in linear algebra want to combine their two theories. In group theory, permutations, also called bijective functions, matter a lot. For a finite set AA, a function σ:AA\sigma : A \to A is a permutation of AA if and only if there is a function ρ:AA\rho : A \to A such that σ(ρ(a))=a\sigma(\rho(a)) = a and ρ(σ(a))=a\rho(\sigma(a)) = a hold for every aAa \in A.

The other half of the team, the linear algebra experts, work with idempotent functions a lot. They appear as projections when a 3D game computes shadows, and as closure operators such as the transitive closure. A function p:AAp : A \to A is idempotent if and only if p(p(a))=p(a)p(p(a)) = p(a) holds for every aAa \in A.

The team wants to know how many permutations of a finite set AA are not idempotent. They already found that this count depends only on the size of AA. Given a size nn, count the permutations of a set of nn elements that are not idempotent.

Input

The first line contains the number of test cases tt (1t1001 \le t \le 100). Each of the next tt lines contains one set size nn (1n1051 \le n \le 10^5).

Output

For each test case, print one line with the number of permutations of a set of nn elements that are not idempotent, modulo 109+7=100000000710^9 + 7 = 1000000007.