#P6204. [USACO07CHN] Treasure G

[USACO07CHN] Treasure G

Problem Description

Carmen and his friends recently dug up a box of treasure. They plan to bury it at some node in a road network.

The entire road network has NN nodes, and these nodes are connected by NN roads. All roads are bidirectional. Every node is connected to at least one road, and no node is connected to more than 44 roads. Carmen decides not to bury the treasure at a node that has 44 roads connected to it, because the traffic there is heavy and it is easy to be exposed.

Carmen drew a map of the road network and marked an XX at the planned burial location. To study the best burial plan, he drew all possible cases. For example, the following shows all burial cases when N=4N=4:

After careful study, he found that the last two plans are essentially the same. Two maps are essentially the same if and only if:

  • The treasure burial locations correspond to each other.
  • If there is a road between two nodes, then there is also a road between the corresponding nodes.
  • If there is no road between two nodes, then there is also no road between the corresponding nodes.

Now you need to find how many essentially different burial plans there are.

Input Format

The first line contains an integer NN (4N1054 \leq N \leq 10^5).

The next NN lines each contain two integers u,vu, v (1u,vN1 \leq u, v \leq N), describing a road.

It is guaranteed that there is at most one road directly connecting any two nodes, and there is no road from node uu to node uu.

Output Format

Output the number of essentially different burial plans.

4
1 2
2 3
3 1
1 4
3

Hint

Translated by ChatGPT 5