A - Edge Checker

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

下の画像で示す図において、a 番の点と b 番の点が線で直接結ばれているかを答えてください。

制約

  • 1 \leq a \lt b \leq 10
  • a, b は整数

入力

入力は以下の形式で標準入力から与えられる。

a b

出力

a 番の点と b 番の点が線で直接結ばれている場合は Yes を出力し、結ばれていない場合は No を出力せよ。
ジャッジは英大文字と英小文字を厳密に区別することに注意せよ。


入力例 1

4 5

出力例 1

Yes

問題文で示した図において、4 番の点と 5 番の点は線で直接結ばれています。 よって、Yes を出力します。


入力例 2

3 5

出力例 2

No

問題文で示した図において、3 番の点と 5 番の点は線で直接結ばれていません。 よって、No を出力します。


入力例 3

1 10

出力例 3

Yes

Score : 100 points

Problem Statement

In the figure shown in the image below, are the points numbered a and b directly connected by a line segment?

Constraints

  • 1 \leq a \lt b \leq 10
  • a and b are integers.

Input

Input is given from Standard Input in the following format:

a b

Output

If the points numbered a and b are directly connected by a line segment, print Yes; otherwise, print No.
The judge is case-sensitive: be sure to print uppercase and lowercase letters correctly.


Sample Input 1

4 5

Sample Output 1

Yes

In the figure shown in the Problem Statement, the points numbered 4 and 5 are directly connected by a line segment.
Thus, Yes should be printed.


Sample Input 2

3 5

Sample Output 2

No

In the figure shown in the Problem Statement, the points numbered 3 and 5 are not directly connected by a line segment.
Thus, No should be printed.


Sample Input 3

1 10

Sample Output 3

Yes
B - Not Overflow

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 100

問題文

整数 N が与えられます。 N-2^{31} 以上かつ 2^{31} 未満ならば Yes を、そうでないならば No を出力してください。

制約

  • -2^{63} \leq N < 2^{63}
  • N は整数である。

入力

入力は以下の形式で標準入力から与えられる。

N

出力

N-2^{31} 以上かつ 2^{31} 未満ならば Yes を、そうでないならば No を出力せよ。


入力例 1

10

出力例 1

Yes

10-2^{31} 以上かつ 2^{31} 未満であるので、Yes を出力します。


入力例 2

-9876543210

出力例 2

No

-9876543210-2^{31} 未満であるので、No を出力します。


入力例 3

483597848400000

出力例 3

No

4835978484000002^{31} 以上であるので、No を出力します。

Score : 100 points

Problem Statement

You are given an integer N. If N is between -2^{31} and 2^{31}-1 (inclusive), print Yes; otherwise, print No.

Constraints

  • -2^{63} \leq N < 2^{63}
  • N is an integer.

Input

Input is given from Standard Input in the following format:

N

Output

If N is between -2^{31} and 2^{31}-1 (inclusive), print Yes; otherwise, print No.


Sample Input 1

10

Sample Output 1

Yes

10 is between -2^{31} and 2^{31}-1, so Yes should be printed.


Sample Input 2

-9876543210

Sample Output 2

No

-9876543210 is less than -2^{31}, so No should be printed.


Sample Input 3

483597848400000

Sample Output 3

No

483597848400000 is greater than 2^{31}-1, so No should be printed.

C - Same Name

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

N 人の人がいます。i \, (1 \leq i \leq N) 人目の人の姓は S_i、名は T_i です。

同姓同名であるような人の組が存在するか、すなわち 1 \leq i \lt j \leq N かつ S_i=S_j かつ T_i=T_j を満たすような整数対 (i,j) が存在するか判定してください。

制約

  • 2 \leq N \leq 1000
  • N は整数
  • S_i,T_i は英小文字のみからなる長さ 1 以上 10 以下の文字列

入力

入力は以下の形式で標準入力から与えられる。

N
S_1 T_1
S_2 T_2
\hspace{0.6cm}\vdots
S_N T_N

出力

同姓同名であるような人の組が存在するなら Yes を、存在しないなら No を出力せよ。


入力例 1

3
tanaka taro
sato hanako
tanaka taro

出力例 1

Yes

1 人目の人と 3 人目の人が同姓同名です。


入力例 2

3
saito ichiro
saito jiro
saito saburo

出力例 2

No

同姓同名であるような人の組は存在しません。


入力例 3

4
sypdgidop bkseq
bajsqz hh
ozjekw mcybmtt
qfeysvw dbo

出力例 3

No

Score : 200 points

Problem Statement

There are N people. The family name and given name of the i-th person (1 \leq i \leq N) are S_i and T_i, respectively.

Determine whether there is a pair of people with the same family and given names. In other words, determine whether there is a pair of integers (i,j) such that 1 \leq i \lt j \leq N, S_i=S_j, and T_i=T_j.

Constraints

  • 2 \leq N \leq 1000
  • N is an integer.
  • Each of S_i and T_i is a string of length between 1 and 10 (inclusive) consisting of English lowercase letters.

Input

Input is given from Standard Input in the following format:

N
S_1 T_1
S_2 T_2
\hspace{0.6cm}\vdots
S_N T_N

Output

If there is a pair of people with the same family and given names, print Yes; otherwise, print No.


Sample Input 1

3
tanaka taro
sato hanako
tanaka taro

Sample Output 1

Yes

The first and third persons have the same family and given names.


Sample Input 2

3
saito ichiro
saito jiro
saito saburo

Sample Output 2

No

No two persons have the same family and given names.


Sample Input 3

4
sypdgidop bkseq
bajsqz hh
ozjekw mcybmtt
qfeysvw dbo

Sample Output 3

No
D - Piano

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 200

問題文

無限に長いピアノの鍵盤があります。 この鍵盤内の連続する区間であって、白鍵 W 個と黒鍵 B 個からなるものは存在しますか?

文字列 wbwbwwbwbwbw を無限に繰り返してできる文字列を S とおきます。

S の部分文字列であって、W 個の wB 個の b からなるものは存在しますか?

S の部分文字列とは S の部分文字列とは、ある 2 つの正整数 l,r\ (l\leq r) に対して、Sl 文字目、l+1 文字目、\dotsr 文字目をこの順に繋げてできる文字列のことをいいます。

制約

  • W,B は整数
  • 0\leq W,B \leq 100
  • W+B \geq 1

入力

入力は以下の形式で標準入力から与えられる。

W B

出力

S の部分文字列であって、W 個の wB 個の b からなるものが存在するならば Yes を、存在しないならば No を出力せよ。


入力例 1

3 2

出力例 1

Yes

S の最初の 15 文字は wbwbwwbwbwbwwbw であり、S11 文字目から 15 文字目までを取り出してできる文字列 bwwbw3 個の w2 個の b からなる部分文字列の一例です。


入力例 2

3 0

出力例 2

No

3 個の w0 個の b からなる文字列は www のみですが、これは S の部分文字列ではありません。


入力例 3

92 66

出力例 3

Yes

Score: 200 points

Problem Statement

There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of W white keys and B black keys?

Let S be the string formed by infinitely repeating the string wbwbwwbwbwbw.

Is there a substring of S that consists of W occurrences of w and B occurrences of b?

What is a substring of S? A substring of S is a string that can be formed by concatenating the l-th, (l+1)-th, \dots, r-th characters of S in this order for some two positive integers l and r (l\leq r).

Constraints

  • W and B are integers.
  • 0\leq W,B \leq 100
  • W+B \geq 1

Input

The input is given from Standard Input in the following format:

W B

Output

If there is a substring of S that consists of W occurrences of w and B occurrences of b, print Yes; otherwise, print No.


Sample Input 1

3 2

Sample Output 1

Yes

The first 15 characters of S are wbwbwwbwbwbwwbw. You can take the 11-th through 15-th characters to form the string bwwbw, which is a substring consisting of three occurrences of w and two occurrences of b.


Sample Input 2

3 0

Sample Output 2

No

The only string consisting of three occurrences of w and zero occurrences of b is www, which is not a substring of S.


Sample Input 3

92 66

Sample Output 3

Yes
E - Max MEX

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

長さ N の非負整数列 A が与えられます。
A から K 要素を選んで順序を保ったまま抜き出した列を B としたとき、 MEX(B) としてありえる最大値を求めてください。

但し、数列 X に対して MEX(X) は以下の条件を満たす唯一の非負整数 m として定義されます。

  • 0 \le i < m を満たす全ての整数 iX に含まれる。
  • mX に含まれない。

制約

  • 入力は全て整数
  • 1 \le K \le N \le 3 \times 10^5
  • 0 \le A_i \le 10^9

入力

入力は以下の形式で標準入力から与えられる。

N K
A_1 A_2 \dots A_N

出力

答えを出力せよ。


入力例 1

7 3
2 0 2 3 2 1 9

出力例 1

3

この入力では A=(2,0,2,3,2,1,9) であり、ここから K=3 要素を選んで抜き出して数列 B を得ます。例えば、

  • 1,2,3 要素目を抜き出した時、 MEX(B)=MEX(2,0,2)=1
  • 3,4,6 要素目を抜き出した時、 MEX(B)=MEX(2,3,1)=0
  • 2,6,7 要素目を抜き出した時、 MEX(B)=MEX(0,1,9)=2
  • 2,3,6 要素目を抜き出した時、 MEX(B)=MEX(0,2,1)=3

のようになります。
達成可能な MEX の最大値は 3 です。

Score : 300 points

Problem Statement

You are given a length-N sequence of non-negative integers.
When B is a sequence obtained by choosing K elements from A and concatenating them without changing the order, find the maximum possible value of MEX(B).

Here, for a sequence X, we define MEX(X) as the unique non-negative integer m that satisfies the following conditions:

  • Every integer i such that 0 \le i < m is contained in X.
  • m is not contained in X.

Constraints

  • All values in the input are integers.
  • 1 \le K \le N \le 3 \times 10^5
  • 0 \le A_i \le 10^9

Input

The input is given from Standard Input in the following format:

N K
A_1 A_2 \dots A_N

Output

Print the answer.


Sample Input 1

7 3
2 0 2 3 2 1 9

Sample Output 1

3

In this input, A=(2,0,2,3,2,1,9), and you obtain the sequence B by picking K=3 elements. For example,

  • If the 1-st, 2-nd, and 3-rd elements are chosen, MEX(B)=MEX(2,0,2)=1.
  • If the 3-rd, 4-th, and 6-th elements are chosen, MEX(B)=MEX(2,3,1)=0.
  • If the 2-nd, 6-th, and 7-th elements are chosen, MEX(B)=MEX(0,1,9)=2.
  • If the 2-nd, 3-rd, and 6-th elements are chosen, MEX(B)=MEX(0,2,1)=3.

The maximum possible MEX is 3.

F - Collision 2

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 300

問題文

xy 座標平面上に N 人の人がいます。人 i(X_i, Y_i) にいます。すべての人は異なる地点にいます。

L, R からなる長さ N の文字列 S があります。
iS_i = R ならば右向きに、S_i = L ならば左向きに、一斉に同じ速度で歩き始めます。ここで、右は x 軸の正の向き、左は x 軸の負の向きです。

たとえば (X_1, Y_1) = (2, 3), (X_2, Y_2) = (1, 1), (X_3, Y_3) =(4, 1), S = RRL の場合は次の図のように動きます。

image

反対の向きに歩いている人同士が同じ地点に来ることを「衝突」と呼びます。すべての人が歩き続けたとき、衝突は発生しますか?

制約

  • 2 \leq N \leq 2 \times 10^5
  • 0 \leq X_i \leq 10^9
  • 0 \leq Y_i \leq 10^9
  • i \neq j ならば (X_i, Y_i) \neq (X_j, Y_j) である。
  • X_i, Y_i はすべて整数である。
  • SL および R からなる長さ N の文字列である。

入力

入力は以下の形式で標準入力から与えられる。

N
X_1 Y_1
X_2 Y_2
\vdots
X_N Y_N
S

出力

衝突が発生するならば Yes を、発生しないならば No を出力せよ。


入力例 1

3
2 3
1 1
4 1
RRL

出力例 1

Yes

この入力は問題文にある例と同じケースです。
すべての人が歩き続けると人 2 と人 3 が衝突します。よって Yes を出力します。


入力例 2

2
1 1
2 1
RR

出力例 2

No

1 と人 2 は同じ向きに歩いているので衝突することはありません。


入力例 3

10
1 3
1 4
0 0
0 2
0 4
3 1
2 4
4 2
4 4
3 3
RLRRRLRLRR

出力例 3

Yes

Score : 300 points

Problem Statement

There are N people in an xy-plane. Person i is at (X_i, Y_i). The positions of all people are different.

We have a string S of length N consisting of L and R.
If S_i = R, Person i is facing right; if S_i = L, Person i is facing left. All people simultaneously start walking in the direction they are facing. Here, right and left correspond to the positive and negative x-direction, respectively.

For example, the figure below shows the movement of people when (X_1, Y_1) = (2, 3), (X_2, Y_2) = (1, 1), (X_3, Y_3) =(4, 1), S = RRL.

image

We say that there is a collision when two people walking in opposite directions come to the same position. Will there be a collision if all people continue walking indefinitely?

Constraints

  • 2 \leq N \leq 2 \times 10^5
  • 0 \leq X_i \leq 10^9
  • 0 \leq Y_i \leq 10^9
  • (X_i, Y_i) \neq (X_j, Y_j) if i \neq j.
  • All X_i and Y_i are integers.
  • S is a string of length N consisting of L and R.

Input

Input is given from Standard Input in the following format:

N
X_1 Y_1
X_2 Y_2
\vdots
X_N Y_N
S

Output

If there will be a collision, print Yes; otherwise, print No.


Sample Input 1

3
2 3
1 1
4 1
RRL

Sample Output 1

Yes

This input corresponds to the example in the Problem Statement.
If all people continue walking, Person 2 and Person 3 will collide. Thus, Yes should be printed.


Sample Input 2

2
1 1
2 1
RR

Sample Output 2

No

Since Person 1 and Person 2 walk in the same direction, they never collide.


Sample Input 3

10
1 3
1 4
0 0
0 2
0 4
3 1
2 4
4 2
4 4
3 3
RLRRRLRLRR

Sample Output 3

Yes
G - Loong and Takahashi

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 350

問題文

N 行 横 N 列のマスからなるグリッドがあります。ここで、N45 以下の奇数です。

上から i 行目、左から j 列目のマスをマス (i,j) と表します。

このグリッドに、以下の条件を満たすように高橋君と 1 から N^2-1 までの番号がついた N^2-1 個のパーツからなる 1 匹の龍を配置します。

  • 高橋君はグリッドの中央、すなわちマス (\frac{N+1}{2},\frac{N+1}{2}) に配置しなければならない。
  • 高橋君がいるマスを除く各マスには龍のパーツをちょうど 1 つ配置しなければならない。
  • 2 \leq x \leq N^2-1 を満たす全ての整数 x について、龍のパーツ x はパーツ x-1 があるマスと辺で隣接するマスに配置しなければならない。
    • マス (i,j) とマス (k,l) が辺で隣接するとは、|i-k|+|j-l|=1 であることを意味します。

条件を満たす配置方法を 1 つ出力してください。なお、条件を満たす配置は必ず存在します。

制約

  • 3 \leq N \leq 45
  • N は奇数である

入力

入力は以下の形式で標準入力から与えられる。

N

出力

N 行出力せよ。
X_{i,j} を、マス (i,j) に高橋君を配置するとき T、パーツ x を配置するとき x とし、i 行目には X_{i,1},\ldots,X_{i,N} を空白区切りで出力せよ。


入力例 1

5

出力例 1

1 2 3 4 5
16 17 18 19 6
15 24 T 20 7
14 23 22 21 8
13 12 11 10 9

この他、以下の出力も条件をすべて満たすため正解となります。

9 10 11 14 15
8 7 12 13 16
5 6 T 18 17
4 3 24 19 20 
1 2 23 22 21

一方、以下の出力はそれぞれ不正解となります。

高橋君が中央にいない。

1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 T

パーツ 23 とパーツ 24 のあるマスが辺で隣接していない。

1 2 3 4 5
10 9 8 7 6
11 12 24 22 23
14 13 T 21 20
15 16 17 18 19

Score : 350 points

Problem Statement

There is a grid with N rows and N columns, where N is an odd number at most 45.

Let (i,j) denote the cell at the i-th row from the top and j-th column from the left.

In this grid, you will place Takahashi and a dragon consisting of N^2-1 parts numbered 1 to N^2-1 in such a way that satisfies the following conditions:

  • Takahashi must be placed at the center of the grid, that is, in cell (\frac{N+1}{2},\frac{N+1}{2}).
  • Except for the cell where Takahashi is, exactly one dragon part must be placed in each cell.
  • For every integer x satisfying 2 \leq x \leq N^2-1, the dragon part x must be placed in a cell adjacent by an edge to the cell containing part x-1.
    • Cells (i,j) and (k,l) are said to be adjacent by an edge if and only if |i-k|+|j-l|=1.

Print one way to arrange the parts to satisfy the conditions. It is guaranteed that there is at least one arrangement that satisfies the conditions.

Constraints

  • 3 \leq N \leq 45
  • N is odd.

Input

The input is given from Standard Input in the following format:

N

Output

Print N lines.
The i-th line should contain X_{i,1},\ldots,X_{i,N} separated by spaces, where X_{i,j} is T when placing Takahashi in cell (i,j) and x when placing part x there.


Sample Input 1

5

Sample Output 1

1 2 3 4 5
16 17 18 19 6
15 24 T 20 7
14 23 22 21 8
13 12 11 10 9

The following output also satisfies all the conditions and is correct.

9 10 11 14 15
8 7 12 13 16
5 6 T 18 17
4 3 24 19 20 
1 2 23 22 21

On the other hand, the following outputs are incorrect for the reasons given.

Takahashi is not at the center.

1 2 3 4 5
10 9 8 7 6
11 12 13 14 15
20 19 18 17 16
21 22 23 24 T

The cells containing parts 23 and 24 are not adjacent by an edge.

1 2 3 4 5
10 9 8 7 6
11 12 24 22 23
14 13 T 21 20
15 16 17 18 19
H - Tangency of Cuboids

Time Limit: 2 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

3 次元空間内に N 個の直方体があります。

直方体同士は重なっていません。厳密には、相異なるどの 2 つの直方体の共通部分の体積も 0 です。

i 番目の直方体は、2(X_{i,1},Y_{i,1},Z_{i,1}), (X_{i,2},Y_{i,2},Z_{i,2}) を結ぶ線分を対角線とし、辺は全ていずれかの座標軸に平行です。

各直方体について、他のいくつの直方体と面で接しているか求めてください。
厳密には、各 i に対し、1\leq j \leq N かつ j\neq i である j のうち、i 番目の直方体の表面と j 番目の直方体の表面の共通部分の面積が正であるものの個数を求めてください。

制約

  • 1 \leq N \leq 10^5
  • 0 \leq X_{i,1} < X_{i,2} \leq 100
  • 0 \leq Y_{i,1} < Y_{i,2} \leq 100
  • 0 \leq Z_{i,1} < Z_{i,2} \leq 100
  • 直方体同士は体積が正の共通部分を持たない
  • 入力は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

N
X_{1,1} Y_{1,1} Z_{1,1} X_{1,2} Y_{1,2} Z_{1,2}
\vdots
X_{N,1} Y_{N,1} Z_{N,1} X_{N,2} Y_{N,2} Z_{N,2}

出力

答えを出力せよ。


入力例 1

4
0 0 0 1 1 1
0 0 1 1 1 2
1 1 1 2 2 2
3 3 3 4 4 4

出力例 1

1
1
0
0

1 番目の直方体と 2 番目の直方体は、2(0,0,1),(1,1,1) を結ぶ線分を対角線とする長方形を共有しています。
1 番目の直方体と 3 番目の直方体は、点 (1,1,1) を共有していますが、面で接してはいません。


入力例 2

3
0 0 10 10 10 20
3 4 1 15 6 10
0 9 6 1 20 10

出力例 2

2
1
1

入力例 3

8
0 0 0 1 1 1
0 0 1 1 1 2
0 1 0 1 2 1
0 1 1 1 2 2
1 0 0 2 1 1
1 0 1 2 1 2
1 1 0 2 2 1
1 1 1 2 2 2

出力例 3

3
3
3
3
3
3
3
3

Score : 500 points

Problem Statement

There are N rectangular cuboids in a three-dimensional space.

These cuboids do not overlap. Formally, for any two different cuboids among them, their intersection has a volume of 0.

The diagonal of the i-th cuboid is a segment that connects two points (X_{i,1},Y_{i,1},Z_{i,1}) and (X_{i,2},Y_{i,2},Z_{i,2}), and its edges are all parallel to one of the coordinate axes.

For each cuboid, find the number of other cuboids that share a face with it.
Formally, for each i, find the number of j with 1\leq j \leq N and j\neq i such that the intersection of the surfaces of the i-th and j-th cuboids has a positive area.

Constraints

  • 1 \leq N \leq 10^5
  • 0 \leq X_{i,1} < X_{i,2} \leq 100
  • 0 \leq Y_{i,1} < Y_{i,2} \leq 100
  • 0 \leq Z_{i,1} < Z_{i,2} \leq 100
  • Cuboids do not have an intersection with a positive volume.
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

N
X_{1,1} Y_{1,1} Z_{1,1} X_{1,2} Y_{1,2} Z_{1,2}
\vdots
X_{N,1} Y_{N,1} Z_{N,1} X_{N,2} Y_{N,2} Z_{N,2}

Output

Print the answer.


Sample Input 1

4
0 0 0 1 1 1
0 0 1 1 1 2
1 1 1 2 2 2
3 3 3 4 4 4

Sample Output 1

1
1
0
0

The 1-st and 2-nd cuboids share a rectangle whose diagonal is the segment connecting two points (0,0,1) and (1,1,1).
The 1-st and 3-rd cuboids share a point (1,1,1), but do not share a surface.


Sample Input 2

3
0 0 10 10 10 20
3 4 1 15 6 10
0 9 6 1 20 10

Sample Output 2

2
1
1

Sample Input 3

8
0 0 0 1 1 1
0 0 1 1 1 2
0 1 0 1 2 1
0 1 1 1 2 2
1 0 0 2 1 1
1 0 1 2 1 2
1 1 0 2 2 1
1 1 1 2 2 2

Sample Output 3

3
3
3
3
3
3
3
3
I - Shortest Good Path

Time Limit: 4 sec / Memory Limit: 1024 MiB

配点 : 500

問題文

N 個の頂点と M 本の辺からなる単純(自己ループおよび多重辺を持たない)かつ連結な無向グラフが与えられます。
i = 1, 2, \ldots, M について、i 番目の辺は頂点 u_i と頂点 v_i を結びます。

下記の 2 つの条件をともに満たす整数列 (A_1, A_2, \ldots, A_k) を長さ kパスと呼びます。

  • すべての i = 1, 2, \dots, k について、1 \leq A_i \leq N
  • すべての i = 1, 2, \ldots, k-1 について、頂点 A_i と頂点 A_{i+1} は辺で直接結ばれている。

空列も長さ 0 のパスとみなします。

S = s_1s_2\ldots s_N01 のみからなる長さ N の文字列とします。 パス A = (A_1, A_2, \ldots, A_k) が下記を満たすとき、パス AS に関する良いパスと呼びます。

  • すべての i = 1, 2, \ldots, N について、次を満たす。
    • s_i = 0 ならば、A に含まれる i の個数は偶数である。
    • s_i = 1 ならば、A に含まれる i の個数は奇数である。

S として考えられる文字列(すなわち、01 のみからなる長さ N の文字列)は 2^N 個ありますが、そのすべてにわたる「 S に関する良いパスのうち最短のものの長さ」の総和を出力してください。

この問題の制約下において、01 からなる長さ N のどのような文字列を S として選んでも、S に関する良いパスが少なくとも 1 つ存在することが示せます。

制約

  • 2 \leq N \leq 17
  • N-1 \leq M \leq \frac{N(N-1)}{2}
  • 1 \leq u_i, v_i \leq N
  • 与えられるグラフは単純かつ連結
  • 入力はすべて整数

入力

入力は以下の形式で標準入力から与えられる。

N M
u_1 v_1
u_2 v_2
\vdots
u_M v_M

出力

答えを出力せよ。


入力例 1

3 2
1 2
2 3

出力例 1

14
  • S = 000 のとき、空列 ()S に関する最短の良いパスであり、その長さは 0 です。
  • S = 100 のとき、(1)S に関する最短の良いパスであり、その長さは 1 です。
  • S = 010 のとき、(2)S に関する最短の良いパスであり、その長さは 1 です。
  • S = 110 のとき、(1, 2)S に関する最短の良いパスであり、その長さは 2 です。
  • S = 001 のとき、(3)S に関する最短の良いパスであり、その長さは 1 です。
  • S = 101 のとき、(1, 2, 3, 2)S に関する最短の良いパスであり、その長さは 4 です。
  • S = 011 のとき、(2, 3)S に関する最短の良いパスであり、その長さは 2 です。
  • S = 111 のとき、(1, 2, 3)S に関する最短の良いパスであり、その長さは 3 です。

よって、求める答えは 0 + 1 + 1 + 2 + 1 + 4 + 2 + 3 = 14 です。


入力例 2

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

出力例 2

108

Score : 500 points

Problem Statement

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

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

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

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

Let S = s_1s_2\ldots s_N be a string of length N consisting of 0 and 1. A path A = (A_1, A_2, \ldots, A_k) is said to be a good path with respect to S if the following conditions are satisfied:

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

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

Under the Constraints of this problem, it can be proved that, for any string S of length N consisting of 0 and 1, there is at least one good path with respect to S.

Constraints

  • 2 \leq N \leq 17
  • N-1 \leq M \leq \frac{N(N-1)}{2}
  • 1 \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:

N M
u_1 v_1
u_2 v_2
\vdots
u_M v_M

Output

Print the answer.


Sample Input 1

3 2
1 2
2 3

Sample Output 1

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

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


Sample Input 2

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

Sample Output 2

108