luogu#P4821. [中山市选] 生成树
[中山市选] 生成树
Problem Description
There is a kind of graph called a pentagon ring. The center of a pentagon ring has one cycle consisting of vertices and edges. Each edge of this central -cycle is also an edge of some pentagon, and there are exactly different pentagons in total. These pentagons share vertices only on the central cycle of the pentagon ring. Figure 0 shows a -pentagon ring.

Now given an -pentagon ring, your task is to find the number of different spanning trees of the -pentagon ring. Do you still remember what a spanning tree is? A spanning tree of a graph is a tree formed by keeping all vertices of the original graph and keeping exactly one less edge than the number of vertices. Note: In the given -pentagon ring, all vertices are considered distinct.
Input Format
The input contains multiple test cases. The first line contains a positive integer , which is the number of test cases. Each test case contains an integer , which represents the number of edges of the central cycle in the -pentagon ring you need to solve.
Output Format
For each test case, output one line containing an integer, which is the number of spanning trees of the -pentagon ring modulo .
1
2
40
Hint
Translated by ChatGPT 5