CF-2087H•Codeforces

Nim with Special Numbers

*special

Let's recall the rules of the game "Nim". The game is played by two players who take turns. They have a certain number of piles of stones (the piles can be of the same size or different sizes; the size is defined as the number of stones in a pile). On their turn, a player must choose any non-empty pile of stones and remove any number of stones from it (at least one). The player who cannot make a move loses.

In this problem, a modified version of the game will be used. There is a special set of numbers SS that prohibits certain moves. For each number sisi in this set, if the current size of the pile of stones is strictly greater than sisi, it cannot be made strictly less than sisi in one move. In other words, if the current size of the pile is xx, and the player tries to make a move that results in a size of yy, and x>si>yx>si>y for some number si∈Ssi∈S, such a move is not allowed.

Your task is as follows. Initially, the set SS is empty. You need to process queries of three types:

  • add a certain number sisi to the set;
  • remove a certain number sisi from the set;
  • determine who will win if this modified version of Nim is played with piles of stones of sizes a1,a2,…,aka1,a2,…,ak. Assume that both players play optimally.

Input

The first line contains a single integer qq (1≤q≤3⋅1051≤q≤3⋅105) — the number of queries.

Each query is given in one line in one of the following formats:

  • 11 sisi (1≤si≤3⋅1051≤si≤3⋅105) — if the number sisi is in the set SS, remove it; otherwise, add it to SS;
  • 22 kiki ai,1ai,1 ai,2ai,2 ... ai,kiai,ki (1≤ki≤31≤ki≤3; 1≤ai,j≤3⋅1051≤ai,j≤3⋅105) — determine who will win the game if it uses kiki piles of stones with sizes ai,1,ai,2,…,ai,kiai,1,ai,2,…,ai,ki.

Output

For each query of type 22, output First if the player making the first move will win, or Second if they will lose.

Sample 1
Input
11
2 2 1 4
1 2
2 2 1 4
2 3 3 1 4
1 3
2 3 3 1 4
2 2 1 4
1 4
2 2 1 5
1 2
2 2 1 5
Output
First
Second
Second
Second
Second
First
Second

Discussions & Comments

Share your approach or ask questions about this problem (0)

You must be logged in to comment or start a discussion on this problem.

Log In

No comments yet. Be the first to comment!

Actions

Open on Codeforces

About Platform

CO
Codeforces
External Judge

Problem Discussions

0

Have questions or want to share your solution approach? Join the discussion.

View / write comments