[Solved] Palindromic Hamiltonian Path solution codeforces

Palindromic Hamiltonian Path solution codeforces


You are given a simple undirected graph with nn vertices, nn is even. You are going to write a letter on each vertex. Each letter should be one of the first kk letters of the Latin alphabet.

A path in the graph is called Hamiltonian if it visits each vertex exactly once. A string is called palindromic if it reads the same from left to right and from right to left. A path in the graph is called palindromic if the letters on the vertices in it spell a palindromic string without changing the order.

A string of length nn is good if:

  • each letter is one of the first kk lowercase Latin letters;
  • if you write the ii-th letter of the string on the ii-th vertex of the graph, there will exist a palindromic Hamiltonian path in the graph.

Note that the path doesn’t necesserily go through the vertices in order 1,2,,n1,2,…,n.

Count the number of good strings.

Input

The first line contains three integers nnmm and kk (2n122≤n≤12nn is even; 0mn(n1)20≤m≤n⋅(n−1)21k121≤k≤12) — the number of vertices in the graph, the number of edges in the graph and the number of first letters of the Latin alphabet that can be used.

Each of the next mm lines contains two integers vv and uu (1v,un1≤v,u≤nvuv≠u) — the edges of the graph. The graph doesn’t contain multiple edges and self-loops.

Output

Print a single integer — number of good strings.

Examples Palindromic Hamiltonian Path solution codeforces
input Palindromic Hamiltonian Path solution codeforces

Copy Palindromic Hamiltonian Path solution codeforces
4 3 3
1 2
2 3
3 4
output

Copy
9
input

Copy
4 6 3
1 2
1 3
1 4
2 3
2 4
3 4
output

Copy
21
input

Copy
12 19 12
1 3
2 6
3 6
3 7
4 8
8 5
8 7
9 4
5 9
10 1
10 4
10 6
9 10
11 1
5 11
7 11
12 2
12 5
12 11
output

Copy
456165084

 

 


Solution: Click here


Also read : Airline Restrictions codechef solution

Palindromic Hamiltonian Path solution codeforces

Leave a Comment

Your email address will not be published. Required fields are marked *