QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 512 MB Total points: 100

#10366. Isomorphism

Statistics

You have $n$ vertices. You can add undirected edges between these $n$ vertices, with at most one edge between any two vertices and no self-loops. You want to know the maximum number of edges you can add.

The answer to this problem is obviously $\displaystyle \frac{n(n-1)}{2}$. Therefore, there is an additional constraint: the graph must not have any non-trivial automorphisms. A graph $G$ has a non-trivial automorphism if there exists a permutation $p_1, p_2, \ldots, p_n$ of $1, 2, \ldots, n$ such that for all vertices $u, v$, there is an edge between $(u, v)$ if and only if there is an edge between $(p_u, p_v)$, and the permutation is non-trivial, meaning there exists at least one vertex $u$ such that $p_u \neq u$.

  • For example, for a graph with $5$ vertices and edges $(1,2), (2,3), (3,4), (4,5), (5,1), (1,3)$, the permutation $p_1=3, p_2=2, p_3=1, p_4=5, p_5=4$ is a non-trivial automorphism of the graph.

You need to answer the maximum number of edges in an undirected simple graph with $n$ vertices that has no non-trivial automorphisms. If no such graph exists for $n$ vertices, output -1. Otherwise, output the answer modulo $10^9+7$.

Input

The first line contains a positive integer $T$, representing the number of test cases.

Each of the next $T$ lines contains a positive integer $n$, representing the number of vertices in the graph.

Output

Output $T$ lines, each containing either -1 or the answer modulo $10^9+7$.

Examples

Input 1

6
1
2
3
4
5
6

Output 1

0
-1
-1
-1
-1
9

Subtasks

Test Case $T \leq$ $n \leq$
$1$ $10$ $10$
$2$
$3$ $100$ $100$
$4$
$5$ $10^4$ $10^5$
$6$
$7$ $10^9$
$8$
$9$ $10^{18}$
$10$ $1$ $10^{100}$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.