Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 900 点
問題文
N 個の山が横一列に並んでいます. 左から i 番目の山には A_i 個の石があります.
FirstLeft くんと SecondRight くんがゲームをします. FirstLeft くんから始めて,二人は交互に手番をプレイします. それぞれの手番では,以下の操作を行います.
- FirstLeft くんの手番: FirstLeft くんは,石が 1 個以上ある山の中で最も左にある山から,1 個以上の石を取り除く.
- SecondRight くんの手番: SecondRight くんは,石が 1 個以上ある山の中で最も右にある山から,1 個以上の石を取り除く.
自分の手番で操作できなくなったプレイヤーの負けです. 二人が最適に行動する時,どちらが勝利するか判定してください.
1 つの入力ファイルにつき,T 個のテストケースを解いてください.
制約
- 1 \leq T \leq 100
- 1 \leq N \leq 100
- 1 \leq A_i \leq 10^9
入力
入力は以下の形式で標準入力から与えられる. 入力の 1 行目は以下のとおりである.
T
そして,T 個のテストケースが続く. これらはそれぞれ以下の形式で与えられる.
N A_1 A_2 \cdots A_N
出力
各テストケースについて,FirstLeft くんが勝つ場合は First
,SecondRight くんが勝つ場合は Second
と出力せよ.
各テストケースごとに改行せよ.
入力例 1
3 1 10 2 3 2 3 2 1 2
出力例 1
First First Second
例えば,3 個目のゲームにおいて,次のようなシナリオが考えられます.
- FirstLeft くんが一番左の山から石を 2 個とる.山にある石の個数は (0,1,2) になる.
- SecondRight くんが一番右の山から石を 1 個とる.山にある石の個数は (0,1,1) になる.
- FirstLeft くんが真ん中の山から石を 1 個とる.山にある石の個数は (0,0,1) になる.
- SecondRight くんが一番右の山から石を 1 個とる.山にある石の個数は (0,0,0) になる.
- FirstLeft くんは操作を行うことができず,敗北する.
Score : 900 points
Problem Statement
There are N piles of stones lying in a row. The i-th pile from the left contains A_i stones.
Two players, FirstLeft and SecondRight, play a game. They alternately play a turn, with FirstLeft going first. In each turn, the player does the following operation:
- In FirstLeft's turn: he removes one or more stones from the leftmost pile with one or more stones.
- In SecondRight's turn: he removes one or more stones from the rightmost pile with one or more stones.
The player who becomes unable to play his turn loses. Determine the winner of the game when the players act optimally.
Solve T test cases in an input file.
Constraints
- 1 \leq T \leq 100
- 1 \leq N \leq 100
- 1 \leq A_i \leq 10^9
Input
Input is given from Standard Input in the following format. The first line of input is as follows:
T
Then, T test cases follow, each of which is in the following format:
N A_1 A_2 \cdots A_N
Output
For each test case, print First
if FirstLeft wins, and print Second
if SecondRight wins.
Use one line for each case.
Sample Input 1
3 1 10 2 3 2 3 2 1 2
Sample Output 1
First First Second
For example, in the third game, one possible scenario is as follows:
- FirstLeft takes 2 stones from the leftmost pile. The piles now contain 0,1,2 stone(s).
- SecondRight takes 1 stone from the rightmost pile. The piles now contain 0,1,1 stone(s).
- FirstLeft takes 1 stone from the middle pile. The piles now contain 0,0,1 stone(s).
- SecondRight takes 1 stone from the rightmost pile. The piles now contain 0,0,0 stones.
- FirstLeft is unable to do his operation and loses.