atcoder#ABC244F. [ABC244F] Shortest Good Path

[ABC244F] Shortest Good Path

Score : 500500 points

Problem Statement

You are given a simple connected undirected graph with NN vertices and MM edges. (A graph is said to be simple if it has no multi-edges and no self-loops.) For i=1,2,,Mi = 1, 2, \ldots, M, the ii-th edge connects Vertex uiu_i and Vertex viv_i.

A sequence (A1,A2,,Ak)(A_1, A_2, \ldots, A_k) is said to be a path of length kk if both of the following two conditions are satisfied:

  • For all i=1,2,,ki = 1, 2, \dots, k, it holds that 1AiN1 \leq A_i \leq N.
  • For all i=1,2,,k1i = 1, 2, \ldots, k-1, Vertex AiA_i and Vertex Ai+1A_{i+1} are directly connected by an edge.

An empty sequence is regarded as a path of length 00.

Let S=s1s2sNS = s_1s_2\ldots s_N be a string of length NN consisting of 00 and 11. A path A=(A1,A2,,Ak)A = (A_1, A_2, \ldots, A_k) is said to be a good path with respect to SS if the following conditions are satisfied:

  • For all i=1,2,,Ni = 1, 2, \ldots, N, it holds that:- if si=0s_i = 0, then AA has even number of ii's.
    • if si=1s_i = 1, then AA has odd number of ii's.

There are 2N2^N possible SS (in other words, there are 2N2^N strings of length NN consisting of 00 and 11). Find the sum of "the length of the shortest good path with respect to SS" over all those SS.

Under the Constraints of this problem, it can be proved that, for any string SS of length NN consisting of 00 and 11, there is at least one good path with respect to SS.

Constraints

  • 2N172 \leq N \leq 17
  • N1MN(N1)2N-1 \leq M \leq \frac{N(N-1)}{2}
  • 1ui,viN1 \leq u_i, v_i \leq N
  • The given graph is simple and connected.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN MM

u1u_1 v1v_1

u2u_2 v2v_2

\vdots

uMu_M vMv_M

Output

Print the answer.

3 2
1 2
2 3
14
  • For S=000S = 000, the empty sequence ()() is the shortest good path with respect to SS, whose length is 00.
  • For S=100S = 100, (1)(1) is the shortest good path with respect to SS, whose length is 11.
  • For S=010S = 010, (2)(2) is the shortest good path with respect to SS, whose length is 11.
  • For S=110S = 110, (1,2)(1, 2) is the shortest good path with respect to SS, whose length is 22.
  • For S=001S = 001, (3)(3) is the shortest good path with respect to SS, whose length is 11.
  • For S=101S = 101, (1,2,3,2)(1, 2, 3, 2) is the shortest good path with respect to SS, whose length is 44.
  • For S=011S = 011, (2,3)(2, 3) is the shortest good path with respect to SS, whose length is 22.
  • For S=111S = 111, (1,2,3)(1, 2, 3) is the shortest good path with respect to SS, whose length is 33.

Therefore, the sought answer is 0+1+1+2+1+4+2+3=140 + 1 + 1 + 2 + 1 + 4 + 2 + 3 = 14.

5 5
4 2
2 3
1 3
2 1
1 5
108