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 nn vertices and nn edges. Each edge of this central nn-cycle is also an edge of some pentagon, and there are exactly nn different pentagons in total. These pentagons share vertices only on the central cycle of the pentagon ring. Figure 0 shows a 44-pentagon ring.

https://cdn.luogu.com.cn/upload/pic/22665.png

Now given an nn-pentagon ring, your task is to find the number of different spanning trees of the nn-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 nn-pentagon ring, all vertices are considered distinct.

Input Format

The input contains multiple test cases. The first line contains a positive integer TT, which is the number of test cases. Each test case contains an integer nn, which represents the number of edges of the central cycle in the nn-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 nn-pentagon ring modulo 20072007.

1
2
40

Hint

2n1002\leq n \leq 100

Translated by ChatGPT 5