{"raw_statement":[{"iden":"statement","content":"There are two seagulls playing a very peculiar game. First they line up N unit squares in a line, all originally colored white.\n\nLet L be the length of the longest continuous sub-segment of white unit squares. Let P be any prime that satisfies the condition that . The player can choose any P if it satisfies the conditions but if there is no value of P that does, then P is set to 1.\n\nThe current player then proceeds to choose any continuous sub-segment of white unit squares of length P and paint them black. The player who can’t make a move loses.\n\nIf both players play optimally and the first player starts, which player is going to win the game?\n\nThe first line of input is T – the number of test cases.\n\nEach test case contains a line with a single integer N (1 ≤ N ≤ 107).\n\nFor each test case, output on a single line \"first\" (without quotes) if the first player would win the game, or \"second\" if the second would win.\n\n"},{"iden":"input","content":"The first line of input is T – the number of test cases.Each test case contains a line with a single integer N (1 ≤ N ≤ 107)."},{"iden":"output","content":"For each test case, output on a single line \"first\" (without quotes) if the first player would win the game, or \"second\" if the second would win."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case, let $ N \\in \\mathbb{Z} $ denote the number of initially white unit squares in a line.  \n\nLet $ L $ be the length of the longest contiguous segment of white squares.  \nLet $ P $ be the largest prime $ \\leq L $, or $ 1 $ if no such prime exists (i.e., if $ L = 0 $ or $ L = 1 $).  \n\nA move consists of selecting a contiguous white segment of length exactly $ P $ and coloring it black.  \n\nThe game is played by two players alternately, starting with the first player. A player unable to move loses.  \n\n**Constraints**  \n$ 1 \\leq T \\leq 10^4 $, $ 1 \\leq N \\leq 10^7 $  \n\n**Objective**  \nDetermine the winner under optimal play: output \"first\" if the first player wins, \"second\" otherwise.  \n\nThis is equivalent to computing the Grundy number (nimber) $ g(N) $ of the game state with $ N $ contiguous white squares, where a move reduces the segment by removing a contiguous block of length $ p $, with $ p $ being the largest prime $ \\leq $ current segment length (or 1 if none).  \n\nThe game is equivalent to an impartial game with state $ N $, and transitions:  \n$$ g(N) = \\mathrm{mex} \\left\\{ g(N - p) \\mid p \\text{ is the largest prime } \\leq N \\right\\} $$  \nwith $ g(0) = 0 $.  \n\nThe first player wins iff $ g(N) \\neq 0 $.","simple_statement":"Two players take turns painting a continuous segment of white squares black.  \nInitially, there are N white squares in a row.  \nOn each turn, a player must choose a prime number P such that P ≤ length of the longest continuous white segment, and paint exactly P consecutive white squares black.  \nIf no such prime exists, P = 1.  \nThe player who cannot move loses.  \nFirst player starts. Both play optimally.  \nFor each test case with N, output \"first\" or \"second\".","has_page_source":false}