AtCoder Regular Contest 209 (Div. 1)
A
Bracket Game
AtCoder
⌀ 1284
原题
←B →
翻译中…

Problem Statement

翻译中…

There is a string $S$ consisting of ( and ).

翻译中…

Taro and Jiro will play the following game using this string.

翻译中…

Taro goes first and Jiro goes second; they alternately choose and perform one of the following three types of operations:

翻译中…
  • Delete the first character of $S$.
  • Delete the last character of $S$.
  • Declare termination.
翻译中…

The game ends when the length of $S$ becomes exactly $K$, or when either player declares termination. At the end of the game, if $S$ is a correct bracket sequence, Jiro wins; otherwise, Taro wins.

翻译中…

Given $S$ before the game starts, determine the winner when both players act optimally.

翻译中…

You are given $T$ test cases. Solve each of them.

翻译中…

What is a correct bracket sequence? A correct bracket sequence is a string that can be reduced to an empty string by repeating the operation of deleting a substring () zero or more times.

翻译中…

Constraints

翻译中…
  • $1 \le T \le 10^5$
  • $1 \le K < |S| \le 10^6$
  • $S$ is a string consisting of ( and ).
  • $T$ and $K$ are integers.
  • The sum of $|S|$ over all test cases is at most $10^6$.
翻译中…

Input

翻译中…

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

翻译中…

T
case_1
case_2
\vdots
case_T

翻译中…

Each case is given in the following format:

翻译中…

S
K

翻译中…

Output

翻译中…

For each test case, print First if Taro wins, and Second if Jiro wins.

翻译中…

样例

Input #1
4
(()())
2
(())()
2
(()
2
(()()())((()()(())()))
12
Output #1
Second
First
First
First
For the first test case, here is an example of how the game might proceed: - Before the game starts, $S$ is `(()())`. - Taro deletes the first character of $S$, resulting in `()())`. - Next, Jiro deletes the last character of $S$, resulting in `()()`. - Next, Taro deletes the last character of $S$, resulting in `()(`. - Next, Jiro deletes the last character of $S$, resulting in `()`, and the length of $S$ becomes $K=2$, so the game ends. - The final $S$ is a correct bracket sequence, so Jiro wins. In the third test case, for example, Taro can win by declaring termination on the first turn.
题目信息
题号
arc209_a
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。