This page is still under construction.

Parts of this page are still being built. What you see may change.

Self-Describing Sequences

Time limit1sMemory limit256 MB

Summary
Count length-N sequences where each entry A[i] equals the number of times i appears in the sequence.
Level

Hard8 of 10

Topics
Math, Combinatorics, Backtracking
Solved
No attempts yet

Problem

You are given a natural number NN. A sequence A=(A0,A1,…,AN−1)A = (A_0, A_1, \ldots, A_{N-1}) of length NN is self-describing when the following holds for every ii with 0≤i<N0 \le i < N.

AiA_i equals the number of times the value ii occurs in AA.

Count the self-describing sequences of length NN.

Input

The first line contains a natural number TT, the number of test cases. Each of the next TT lines contains one sequence length NN (1≤N≤100)(1 \le N \le 100).

Output

For each test case, print on one line the number of self-describing sequences of length NN, taken modulo 1,000,000,007.

Hint

For N=5N = 5 the only sequence that satisfies the condition is (2,1,2,0,0)(2, 1, 2, 0, 0). For N=4N = 4 there are two, (2,0,2,0)(2, 0, 2, 0) and (1,2,1,0)(1, 2, 1, 0).

Examples6

  1. Example 1

    Input
    3
    2
    5
    4
    
    Expected output
    0
    1
    2
    
  2. Example 2

    Input
    1
    1
    
    Expected output
    0
    
  3. Example 3

    Input
    1
    3
    
    Expected output
    0
    
  4. Example 4

    Input
    1
    7
    
    Expected output
    1
    
  5. Example 5

    Input
    1
    100
    
    Expected output
    1
    
  6. Example 6

    Input
    10
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    Expected output
    0
    0
    0
    2
    1
    0
    1
    1
    1
    1