Cubic Cycle

아직 제출이 없습니다시간 제한2초메모리 제한1024 MB

문제

Consider an undirected graph GG with vertices VV and edges EE. A Hamiltonian Cycle is a subset of edges CEC⊆E such that every vertex in vv is the endpoint of precisely two edges in CC and the graph HH with vertices VV and edges CC is connected. In simpler terms, the edges of CC form a single cycle that includes all vertices.

Hamiltonian cycles are beautiful objects, but can be hard to find. Your most recent homework assignment in your Graph Theory course has given you the task of finding a Hamiltonian cycle in a particular graph GG (or determine if one exists). The graph itself is also beautiful, each vertex in GG is the endpoint of precisely three edges.

But it feels unfair to produce only one Hamiltonian cycle. All Hamiltonian cycles deserve recognition! So, you decided that you will in fact produce all Hamiltonian cycles in your homework solution.

Your task is to count the number of Hamiltonian cycles you will have to produce in your homework solution.

Figure 1: Illustration of the three Hamiltonian cycles in the first sample input. The cycles are depicted with thick edges.

입력

The first line contains a single even integer NN (4N504≤N≤50) giving the number of nodes.

Then 3N/23⋅N/2 lines follow, each containing two integers u,vu,v (0u\<N0≤u\<N, 0v\<N0≤v\<N, uvu≠v) describing an edge connecting vertex uu to vertex vv. You are guaranteed any pair of nodes is connected by at most one edge and that each node is the endpoint of precisely three edges in the input.

출력

Display a single line with a single integer indicating the number of Hamiltonian cycles in the given graph.