{"problem":{"name":"E. Competitive Seagulls","description":{"content":"There are two seagulls playing a very peculiar game. First they line up N unit squares in a line, all originally colored white. Let L be the length of the longest continuous sub-segment of white unit","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF10135E"},"statements":[{"statement_type":"Markdown","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## Input\n\nThe 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).\n\n## Output\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[samples]","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"**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 $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF10135E","tags":[],"sample_group":[],"created_at":"2026-03-03 11:00:39"}}