Kill 'em All
Practice
4.5 (11 votes)
Combinatorics
Mathematics
Graph theory
Approved
Medium
Problem
27% Success 93 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

The link to the Russian translation.

Alex has opened the evil vault and is looking for her sister. The vault is evil and has an unstable shape. All Alex knows about it is this:

There are n spots in the vault and there are tunnels between some pairs of spots. The graph of these spots is simple, undirected and connected.

In an undirected graph, the distance between v and u (d(v,u)) is the length (number of edges) of the shortest path from v to u. Diameter of a graph is the value of max(d(v, u) for v, u in V (set of vertices)).

Alex also knows that if she adds any edge that doesn't exist in the current graph (edge between to distinct vertices) its diameter will change.

Alex wants to know the number of graphs with this property. She also notes that the order (label) of vertices doesn't matter (so she wants the number of isomorphism classes of such graphs).

Alex has a great position in the armory, so, don't make her force you...!

Input

The first line of input contains a single integer T, the number of scenarios (1 ≤ T ≤ 500). The next T lines contain the description of these scenarios, each with one integer n (1 ≤ n ≤ 106).

Output

For each scenario prints its answer modulo 1000 000 007 (109+7) in one line.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
17 votes
Tags:
Data StructuresTreeApprovedMedium-HardSegment tree
Points:20
25 votes
Tags:
Basic ProgrammingBasics of ImplementationEasyImplementationString Manipulation
Points:30
3 votes
Tags:
AlgorithmsOpenApprovedMediumMathamatics