A - Counting Passes

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

N 人の人 1,2,\dots,N がある試験を受け、人 iA_i 点を取りました。
この試験では、 L 点以上を取った人のみが合格となります。
N 人のうち何人が合格したか求めてください。

制約

  • 入力は全て整数
  • 1 \le N \le 100
  • 1 \le L \le 1000
  • 0 \le A_i \le 1000

入力

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

N L
A_1 A_2 \dots A_N

出力

答えを整数として出力せよ。


入力例 1

5 60
60 20 100 90 40

出力例 1

3

5 人が試験を受けました。 60 点以上取ると合格です。

  • 160 点を取ったので、合格です。
  • 220 点を取ったので、不合格です。
  • 3100 点を取ったので、合格です。
  • 490 点を取ったので、合格です。
  • 540 点を取ったので、不合格です。

以上より、合格したのは 3 人だと分かります。


入力例 2

4 80
79 78 77 76

出力例 2

0

合格者がいない場合もあります。


入力例 3

10 50
31 41 59 26 53 58 97 93 23 84

出力例 3

6

Score : 100 points

Problem Statement

N people labeled 1,2,\dots,N took an exam, and person i scored A_i points.
Only those who scored at least L points pass this exam.
Determine how many people out of the N have passed the exam.

Constraints

  • All input values are integers.
  • 1 \le N \le 100
  • 1 \le L \le 1000
  • 0 \le A_i \le 1000

Input

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

N L
A_1 A_2 \dots A_N

Output

Print the answer as an integer.


Sample Input 1

5 60
60 20 100 90 40

Sample Output 1

3

Five people took the exam. You need to score at least 60 points to pass.

  • Person 1 scored 60 points, so they passed.
  • Person 2 scored 20 points, so they did not pass.
  • Person 3 scored 100 points, so they passed.
  • Person 4 scored 90 points, so they passed.
  • Person 5 scored 40 points, so they did not pass.

From the above, we can see that three people have passed.


Sample Input 2

4 80
79 78 77 76

Sample Output 2

0

There may be cases no one has passed.


Sample Input 3

10 50
31 41 59 26 53 58 97 93 23 84

Sample Output 3

6
B - Same

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 100

問題文

N 個の整数 A _ 1,A _ 2,\ldots,A _ N が与えられます。

これらの値がすべて等しいならば Yes 、そうでなければ No と出力してください。

制約

  • 2\leq N\leq100
  • 1\leq A _ i\leq100\ (1\leq i\leq N)
  • 入力はすべて整数

入力

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

N
A _ 1 A _ 2 \ldots A _ N

出力

与えられた A _ 1,A _ 2,\ldots,A _ N の値がすべて等しいなら Yes を、そうでなければ No1 行で出力せよ。


入力例 1

3
3 2 4

出力例 1

No

A _ 1\neq A _ 2 なので、No と出力してください。


入力例 2

4
3 3 3 3

出力例 2

Yes

A _ 1=A _ 2=A _ 3=A _ 4 なので、Yes と出力してください。


入力例 3

10
73 8 55 26 97 48 37 47 35 55

出力例 3

No

Score : 100 points

Problem Statement

You are given N integers A _ 1,A _ 2,\ldots,A _ N.

If their values are all equal, print Yes; otherwise, print No.

Constraints

  • 2\leq N\leq100
  • 1\leq A _ i\leq100\ (1\leq i\leq N)
  • All input values are integers.

Input

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

N
A _ 1 A _ 2 \ldots A _ N

Output

Print a single line containing Yes if the values of the given A _ 1,A _ 2,\ldots,A _ N are all equal, and No otherwise.


Sample Input 1

3
3 2 4

Sample Output 1

No

We have A _ 1\neq A _ 2, so you should print No.


Sample Input 2

4
3 3 3 3

Sample Output 2

Yes

We have A _ 1=A _ 2=A _ 3=A _ 4, so you should print Yes.


Sample Input 3

10
73 8 55 26 97 48 37 47 35 55

Sample Output 3

No
C - How many?

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

a+b+c \leq S かつ a \times b \times c \leq T を満たす非負整数の組 (a,b,c) はいくつありますか?

制約

  • 0 \leq S \leq 100
  • 0 \leq T \leq 10000
  • S, T は整数である。

入力

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

S T

出力

条件を満たす非負整数の組 (a,b,c) の個数を出力せよ。


入力例 1

1 0

出力例 1

4

条件を満たす非負整数の組 (a,b,c)(0,0,0), (0,0,1), (0,1,0), (1,0,0)4 つです。


入力例 2

2 5

出力例 2

10

入力例 3

10 10

出力例 3

213

入力例 4

30 100

出力例 4

2471

Score : 200 points

Problem Statement

How many triples of non-negative integers (a, b, c) satisfy a+b+c \leq S and a \times b \times c \leq T?

Constraints

  • 0 \leq S \leq 100
  • 0 \leq T \leq 10000
  • S and T are integers.

Input

Input is given from Standard Input in the following format:

S T

Output

Print the number of triples of non-negative integers (a,b,c) satisfying the conditions.


Sample Input 1

1 0

Sample Output 1

4

The triples (a,b,c) satisfying the conditions are (0,0,0), (0,0,1), (0,1,0), and (1,0,0) ― there are four of them.


Sample Input 2

2 5

Sample Output 2

10

Sample Input 3

10 10

Sample Output 3

213

Sample Input 4

30 100

Sample Output 4

2471
D - Next

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 200

問題文

N 個の整数 A_1, A_2, \ldots, A_N が与えられます。 このうち最大でない整数の中で最大である整数を求めてください。

ただし、この問題の制約下で答えは必ず存在します。

制約

  • 2 \leq N \leq 100
  • 1 \leq A_i \leq 100
  • A_1, A_2, \ldots, A_N がすべて等しいということはない
  • 入力値はすべて整数

入力

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

N
A_1 A_2 \ldots A_N

出力

答えを出力せよ。


入力例 1

5
2 1 3 3 2

出力例 1

2

2,1,3,3,2 の中で最大である整数は 3 です。

2,1,3,3,2 の中で 3 でない整数は 2,1,23 つであり、これらの中で最大である整数は 2 です。


入力例 2

4
4 3 2 1

出力例 2

3

入力例 3

8
22 22 18 16 22 18 18 22

出力例 3

18

Score : 200 points

Problem Statement

You are given N integers A_1, A_2, \ldots, A_N. Find the largest among those integers that are not the largest.

The constraints of this problem guarantee that the answer exists.

Constraints

  • 2 \leq N \leq 100
  • 1 \leq A_i \leq 100
  • It is not the case that all A_1, A_2, \ldots, A_N are equal.
  • All input values are integers.

Input

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

N
A_1 A_2 \ldots A_N

Output

Print the answer.


Sample Input 1

5
2 1 3 3 2

Sample Output 1

2

The largest integer among 2,1,3,3,2 is 3.

The integers that are not 3 among 2,1,3,3,2 are 2,1,2, among which the largest is 2.


Sample Input 2

4
4 3 2 1

Sample Output 2

3

Sample Input 3

8
22 22 18 16 22 18 18 22

Sample Output 3

18
E - Consecutive

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 300

問題文

英小文字のみからなる長さ N の文字列 S = S_1S_2\ldots S_N が与えられます。

また、S に関する Q 個の質問が与えられます。 i = 1, 2, \ldots, Q について、i 番目の質問は 2 つの整数 l_i, r_i で表される下記の質問です。

Sl_i 文字目から r_i 文字目までからなる部分文字列 S_{l_i}S_{l_i+1}\ldots S_{r_i} において、 同じ英小文字が 2 つ隣りあう箇所は何個ありますか? すなわち、l_i \leq p \leq r_i-1 かつ S_p = S_{p+1}を満たす整数 p は何個ありますか?

Q 個の質問それぞれの答えを出力してください。

制約

  • N, Q は整数
  • 1 \leq N, Q \leq 3 \times 10^5
  • S は英小文字のみからなる長さ N の文字列
  • l_i, r_i は整数
  • 1 \leq l_i \leq r_i \leq N

入力

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

N Q
S
l_1 r_1
l_2 r_2
\vdots
l_Q r_Q

出力

Q 行出力せよ。 i = 1, 2, \ldots, Q について、i 行目には i 番目の質問に対する答えを出力せよ。


入力例 1

11 4
mississippi
3 9
4 10
4 6
7 7

出力例 1

2
2
0
0

4 個の質問それぞれに対する答えは下記の通りです。

  • 1 個目の質問に関して、S_3S_4\ldots S_9 = ssissip で同じ英小文字が隣り合う箇所は、S_3S_4 = ssS_6S_7 = ss2 個です。
  • 2 個目の質問に関して、S_4S_5\ldots S_{10} = sissipp で同じ英小文字が隣り合う箇所は、S_6S_7 = ssS_9S_{10} = pp2 個です。
  • 3 個目の質問に関して、S_4S_5S_6 = sis で同じ英小文字が隣り合う箇所は 0 個です。
  • 4 個目の質問に関して、S_7 = s で同じ英小文字が隣り合う箇所は 0 個です。

入力例 2

5 1
aaaaa
1 5

出力例 2

4

S_1S_2\ldots S_5 = aaaaa で同じ英小文字が隣り合う箇所は、 S_1S_2 = aaS_2S_3 = aaS_3S_4 = aaS_4S_5 = aa4 個です。

Score : 300 points

Problem Statement

You are given a string S = S_1S_2\ldots S_N of length N consisting of lowercase English letters.

Additionally, you are given Q queries about the string S. For i = 1, 2, \ldots, Q, the i-th query is represented by two integers l_i, r_i and asks the following.

In the substring S_{l_i}S_{l_i+1}\ldots S_{r_i} of S, which ranges from the l_i-th to the r_i-th character, how many places are there where the same lowercase English letter occurs twice in a row? In other words, how many integers p satisfy l_i \leq p \leq r_i-1 and S_p = S_{p+1}?

Print the answer for each of the Q queries.

Constraints

  • N and Q are integers.
  • 1 \leq N, Q \leq 3 \times 10^5
  • S is a string of length N consisting of lowercase English letters.
  • l_i and r_i are integers.
  • 1 \leq l_i \leq r_i \leq N

Input

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

N Q
S
l_1 r_1
l_2 r_2
\vdots
l_Q r_Q

Output

Print Q lines. For i = 1, 2, \ldots, Q, the i-th line should contain the answer to the i-th query.


Sample Input 1

11 4
mississippi
3 9
4 10
4 6
7 7

Sample Output 1

2
2
0
0

The answers to the four queries are as follows.

  • For the first query, S_3S_4\ldots S_9 = ssissip has two places where the same lowercase English letter occurs twice in a row: S_3S_4 = ss and S_6S_7 = ss.
  • For the second query, S_4S_5\ldots S_{10} = sissipp has two places where the same lowercase English letter occurs twice in a row: S_6S_7 = ss and S_9S_{10} = pp.
  • For the third query, S_4S_5S_6 = sis has zero places where the same lowercase English letter occurs twice in a row.
  • For the fourth query, S_7 = s has zero places where the same lowercase English letter occurs twice in a row.

Sample Input 2

5 1
aaaaa
1 5

Sample Output 2

4

S_1S_2\ldots S_5 = aaaaa has four places where the same lowercase English letter occurs twice in a row: S_1S_2 = aa, S_2S_3 = aa, S_3S_4 = aa, and S_4S_5 = aa.

F - Four Variables

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 300

問題文

正整数 N が与えられます。
正整数の組 (A,B,C,D) であって、AB + CD = N を満たすものの個数を求めてください。

なお、本問の制約の下、答えが 9 \times 10^{18} 以下であることが証明できます。

制約

  • 2 \leq N \leq 2 \times 10^5
  • N は整数

入力

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

N

出力

答えを出力せよ。


入力例 1

4

出力例 1

8

(A,B,C,D) として以下の 8 個が考えられます。

  • (A,B,C,D)=(1,1,1,3)
  • (A,B,C,D)=(1,1,3,1)
  • (A,B,C,D)=(1,2,1,2)
  • (A,B,C,D)=(1,2,2,1)
  • (A,B,C,D)=(1,3,1,1)
  • (A,B,C,D)=(2,1,1,2)
  • (A,B,C,D)=(2,1,2,1)
  • (A,B,C,D)=(3,1,1,1)

入力例 2

292

出力例 2

10886

入力例 3

19876

出力例 3

2219958

Score : 300 points

Problem Statement

You are given a positive integer N.
Find the number of quadruples of positive integers (A,B,C,D) such that AB + CD = N.

Under the constraints of this problem, it can be proved that the answer is at most 9 \times 10^{18}.

Constraints

  • 2 \leq N \leq 2 \times 10^5
  • N is an integer.

Input

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

N

Output

Print the answer.


Sample Input 1

4

Sample Output 1

8

Here are the eight desired quadruples.

  • (A,B,C,D)=(1,1,1,3)
  • (A,B,C,D)=(1,1,3,1)
  • (A,B,C,D)=(1,2,1,2)
  • (A,B,C,D)=(1,2,2,1)
  • (A,B,C,D)=(1,3,1,1)
  • (A,B,C,D)=(2,1,1,2)
  • (A,B,C,D)=(2,1,2,1)
  • (A,B,C,D)=(3,1,1,1)

Sample Input 2

292

Sample Output 2

10886

Sample Input 3

19876

Sample Output 3

2219958
G - ABC Transform

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 400

問題文

A, B, C のみからなる文字列 S が与えられます。

S^{(0)}:=S とし、i=1,2,3,\ldots について S^{(i)}S^{(i-1)} の各文字を ABC, BCA, CAB と同時に置き換えたものと定義します。

以下の Q 個のクエリに答えてください。i 個目のクエリの内容は以下の通りです。

  • S^{(t_i)} の先頭から k_i 文字目を出力せよ。

制約

  • SA, B, C のみからなる長さ 1 以上 10^5 以下の文字列
  • 1 \leq Q \leq 10^5
  • 0 \leq t_i \leq 10^{18}
  • 1 \leq k_i \leq \min(10^{18},\ S^{(t_i)} の長さ)
  • Q, t_i, k_i は整数

入力

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

S
Q
t_1 k_1
t_2 k_2
\hspace{0.4cm}\vdots
t_Q k_Q

出力

Q 個のクエリを添字の昇順に、すなわち与えられる順に処理し、出力ごとに改行せよ。


入力例 1

ABC
4
0 1
1 1
1 3
1 6

出力例 1

A
B
C
B

S^{(0)}=ABC, S^{(1)}=BCCAAB です。

よって各クエリへの答えは順に A, B, C, B となります。


入力例 2

CBBAACCCCC
5
57530144230160008 659279164847814847
29622990657296329 861239705300265164
509705228051901259 994708708957785197
176678501072691541 655134104344481648
827291290937314275 407121144297426665

出力例 2

A
A
C
A
A

Score : 400 points

Problem Statement

You are given a string S consisting of A, B, C.

Let S^{(0)}:=S. For i=1,2,3,\ldots, let S^{(i)} be the result of simultaneously replacing the characters of S^{(i-1)} as follows: ABC, BCA, CAB.

Answer Q queries. The i-th query is as follows.

  • Print the k_i-th character from the beginning of S^{(t_i)}.

Constraints

  • S is a string of length between 1 and 10^5 (inclusive) consisting of A, B, C.
  • 1 \leq Q \leq 10^5
  • 0 \leq t_i \leq 10^{18}
  • 1 \leq k_i \leq \min(10^{18}, the length of S^{(t_i)})
  • Q, t_i, k_i are integers.

Input

Input is given from Standard Input in the following format:

S
Q
t_1 k_1
t_2 k_2
\hspace{0.4cm}\vdots
t_Q k_Q

Output

Process the Q queries in ascending order of index, that is, in the given order. Each answer should be followed by a newline.


Sample Input 1

ABC
4
0 1
1 1
1 3
1 6

Sample Output 1

A
B
C
B

We have S^{(0)}=ABC, S^{(1)}=BCCAAB.

Thus, the answers to the queries are A, B, C, B in the given order.


Sample Input 2

CBBAACCCCC
5
57530144230160008 659279164847814847
29622990657296329 861239705300265164
509705228051901259 994708708957785197
176678501072691541 655134104344481648
827291290937314275 407121144297426665

Sample Output 2

A
A
C
A
A
H - Warp

実行時間制限: 3 sec / メモリ制限: 1024 MiB

配点 : 500

問題文

2 次元平面の原点に高橋君がいます。
高橋君はこれから、ワープを N 回繰り返します。各ワープでは、以下の 3 つのうちいずれか 1 つを行います。

  • 現在いる座標 (x,y) から (x+A,y+B) に移動する
  • 現在いる座標 (x,y) から (x+C,y+D) に移動する
  • 現在いる座標 (x,y) から (x+E,y+F) に移動する

平面上の M 箇所 (X_1,Y_1),\ldots,(X_M,Y_M) には障害物があり、これらの座標に移動することはできません。

N 回のワープによる移動経路として考えられるものは何通りですか? 998244353 で割ったあまりを求めてください。

制約

  • 1 \leq N \leq 300
  • 0 \leq M \leq 10^5
  • -10^9 \leq A,B,C,D,E,F \leq 10^9
  • (A,B),(C,D),(E,F) は相異なる
  • -10^9 \leq X_i,Y_i \leq 10^9
  • (X_i,Y_i)\neq(0,0)
  • (X_i,Y_i) は相異なる
  • 入力に含まれる値は全て整数である

入力

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

N M
A B C D E F
X_1 Y_1
X_2 Y_2
\vdots
X_M Y_M

出力

答えを出力せよ。


入力例 1

2 2
1 1 1 2 1 3
1 2
2 2

出力例 1

5

以下の 5 通りが考えられます。

  • (0,0)\to(1,1)\to(2,3)
  • (0,0)\to(1,1)\to(2,4)
  • (0,0)\to(1,3)\to(2,4)
  • (0,0)\to(1,3)\to(2,5)
  • (0,0)\to(1,3)\to(2,6)

入力例 2

10 3
-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
-1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

出力例 2

0

入力例 3

300 0
0 0 1 0 0 1

出力例 3

292172978

Score : 500 points

Problem Statement

Takahashi is at the origin of a two-dimensional plane.
Takahashi will repeat teleporting N times. In each teleportation, he makes one of the following moves:

  • Move from the current coordinates (x,y) to (x+A,y+B)
  • Move from the current coordinates (x,y) to (x+C,y+D)
  • Move from the current coordinates (x,y) to (x+E,y+F)

There are obstacles on M points (X_1,Y_1),\ldots,(X_M,Y_M) on the plane; he cannot teleport to these coordinates.

How many paths are there resulting from the N teleportations? Find the count modulo 998244353.

Constraints

  • 1 \leq N \leq 300
  • 0 \leq M \leq 10^5
  • -10^9 \leq A,B,C,D,E,F \leq 10^9
  • (A,B), (C,D), and (E,F) are distinct.
  • -10^9 \leq X_i,Y_i \leq 10^9
  • (X_i,Y_i)\neq(0,0)
  • (X_i,Y_i) are distinct.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
A B C D E F
X_1 Y_1
X_2 Y_2
\vdots
X_M Y_M

Output

Print the answer.


Sample Input 1

2 2
1 1 1 2 1 3
1 2
2 2

Sample Output 1

5

The following 5 paths are possible:

  • (0,0)\to(1,1)\to(2,3)
  • (0,0)\to(1,1)\to(2,4)
  • (0,0)\to(1,3)\to(2,4)
  • (0,0)\to(1,3)\to(2,5)
  • (0,0)\to(1,3)\to(2,6)

Sample Input 2

10 3
-1000000000 -1000000000 1000000000 1000000000 -1000000000 1000000000
-1000000000 -1000000000
1000000000 1000000000
-1000000000 1000000000

Sample Output 2

0

Sample Input 3

300 0
0 0 1 0 0 1

Sample Output 3

292172978
I - Shiritori

実行時間制限: 2 sec / メモリ制限: 1024 MiB

配点 : 500

問題文

N 個の文字列 S _ 1,S _ 2,\ldots,S _ N が与えられます。 S _ i\ (1\leq i\leq N) は英小文字からなる長さ 10 以下の空でない文字列で、互いに異なります。

先手太郎君と後手次郎君がしりとりをします。 このしりとりでは、先手太郎君と後手次郎君の手番が交互に訪れます。 はじめの手番は先手太郎君の手番です。 それぞれのプレイヤーは自分の手番において整数 i\ (1\leq i\leq N)1 つ選びます。 このとき、i は次の 2 つの条件を満たしていなければなりません。

  • i は、しりとりが開始してからこれまでの 2 人の手番で選ばれたどの整数とも異なる
  • この手番がしりとりの最初の手番であるか、直前に選ばれた整数を j として、S _ j の最後の文字と S _ i の最初の文字が等しい

条件を満たす i を選べなくなったプレイヤーの負けで、負けなかったプレイヤーの勝ちです。

2 人が最適に行動したときに勝つのはどちらかを判定してください。

制約

  • 1 \leq N \leq 16
  • N は整数
  • S _ i\ (1\leq i\leq N) は英小文字からなる長さ 10 以下の空でない文字列
  • S _ i\neq S _ j\ (1\leq i\lt j\leq N)

入力

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

N
S_1
S_2
\vdots
S_N

出力

2 人が最適に行動したとき、先手太郎君が勝つなら First、後手次郎君が勝つなら Second と出力せよ。


入力例 1

6
enum
float
if
modint
takahashi
template

出力例 1

First

例えば、ゲームは以下のように進行します。 この進行例では 2 人の行動が必ずしも最適とは限らないことに注意してください。

  • 先手太郎君が i=3 を選ぶ。S _ i=if である。
  • 後手次郎君が i=2 を選ぶ。S _ i=float であり、if の最後の文字と float の最初の文字は等しい。
  • 先手太郎君が i=5 を選ぶ。S _ i=takahashi であり、float の最後の文字と takahashi の最初の文字は等しい。
  • 後手次郎君は i\neq2,3,5 であって S _ i の最初の文字が i と等しいものを選べないため、負ける。

このとき、先手太郎君が勝ちます。


入力例 2

10
catch
chokudai
class
continue
copy
exec
havoc
intrinsic
static
yucatec

出力例 2

Second

入力例 3

16
mnofcmzsdx
lgeowlxuqm
ouimgdjxlo
jhwttcycwl
jbcuioqbsj
mdjfikdwix
jhvdpuxfil
peekycgxco
sbvxszools
xuuqebcrzp
jsciwvdqzl
obblxzjhco
ptobhnpfpo
muizaqtpgx
jtgjnbtzcl
sivwidaszs

出力例 3

First

Score : 500 points

Problem Statement

You are given N strings S _ 1,S _ 2,\ldots,S _ N. S _ i\ (1\leq i\leq N) is a non-empty string of length at most 10 consisting of lowercase English letters, and the strings are pairwise distinct.

Taro the First and Jiro the Second play a word-chain game. In this game, the two players take alternating turns, with Taro the First going first. In each player's turn, the player chooses an integer i\ (1\leq i\leq N), which should satisfy the following two conditions:

  • i is different from any integer chosen by the two players so far since the game started;
  • the current turn is the first turn of the game, or the last character of S_j equals the first character of S_i, where j is the last integer chosen.

The player who is unable to choose a conforming i loses; the other player wins.

Determine which player will win if the two players play optimally.

Constraints

  • 1 \leq N \leq 16
  • N is an integer.
  • S _ i\ (1\leq i\leq N) is a non-empty string of length at most 10 consisting of lowercase English letters.
  • S _ i\neq S _ j\ (1\leq i\lt j\leq N)

Input

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

N
S_1
S_2
\vdots
S_N

Output

Print First if Taro the First wins when the two players play optimally; print Second if Jiro the Second wins.


Sample Input 1

6
enum
float
if
modint
takahashi
template

Sample Output 1

First

For example, the game progresses as follows. Note that the two players may not be playing optimally in this example.

  • Taro the First chooses i=3. S _ i=if.
  • Jiro the Second chooses i=2. S _ i=float, and the last character of if equals the first character of float.
  • Taro the First chooses i=5. S _ i=takahashi, and the last character of float equals the first character of takahashi.
  • Jiro the Second is unable to choose i\neq2,3,5 such that S _ i starts with i, so he loses.

In this case, Taro the First wins.


Sample Input 2

10
catch
chokudai
class
continue
copy
exec
havoc
intrinsic
static
yucatec

Sample Output 2

Second

Sample Input 3

16
mnofcmzsdx
lgeowlxuqm
ouimgdjxlo
jhwttcycwl
jbcuioqbsj
mdjfikdwix
jhvdpuxfil
peekycgxco
sbvxszools
xuuqebcrzp
jsciwvdqzl
obblxzjhco
ptobhnpfpo
muizaqtpgx
jtgjnbtzcl
sivwidaszs

Sample Output 3

First