CF1934D2.XOR Break — Game Version

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

This is an interactive problem.

This is the game version of the problem. Note that the solution of this problem may or may not share ideas with the solution of the solo version. You can solve and get points for both versions independently.

Alice and Bob are playing a game. The game starts with a positive integer nn , with players taking turns. On each turn of the game, the following sequence of events takes place:

  • The player having the integer pp breaks it into two integers p1p_{1} and p2p_{2} , where 0<p1<p0 \lt p_{1} \lt p , 0<p2<p0 \lt p_{2} \lt p and p1p2=pp_{1} \oplus p_{2} = p .
  • If no such p1p_{1} , p2p_{2} exist, the player loses.
  • Otherwise, the opponent does either select the integer p1p_{1} or p2p_{2} .
  • The game continues with the selected integer. The opponent will try to break it.

As Alice, your goal is to win. You can execute a maximum of 6363 break operations. You have the choice to play first or second. The system will act for Bob.

Here \oplus denotes the bitwise XOR operation.

输入格式

Each test contains multiple test cases. The first line of input contains a single integer tt ( 1t10001 \leq t \leq 1000 ) — the number of test cases.

The only line of each test case contains a single integer nn ( 1n10181 \leq n \leq 10^{18} ) — the number the game starts with.

输出格式

For each test case, the interaction begins by reading the integer nn .

After reading nn , print a single line containing either "first" or "second", denoting what you want to play as (as first or second correspondingly).

On Alice's turn, you are required to print two positive integers, p1p_{1} and p2p_{2} such that 0<p1<p0 \lt p_{1} \lt p , 0<p2<p0 \lt p_{2} \lt p and p1p2=pp_{1} \oplus p_{2} = p . Here, pp equals one of the two integers printed by Bob in the previous turn. If no turn has occurred previously, pp is equal to nn . If Alice cannot perform a break operation, print "0 0" to receive a Wrong answer verdict.

On Bob's turn, you should read two integers, p1p_{1} and p2p_{2} such that 0<p1<p0 \lt p_{1} \lt p , 0<p2<p0 \lt p_{2} \lt p and p1p2=pp_{1} \oplus p_{2} = p . Here, pp equals one of the two integers printed by Alice in the previous turn. If no turn has occurred previously, pp is equal to nn . If Bob cannot perform a break operation p1=0p_{1} = 0 and p2=0p_2 = 0 in which case you should proceed to the next test case.

If any break operation performed by Alice is invalid, the interactor prints "-1 -1" and your code should promptly exit to receive a wrong answer verdict.

If Alice performs 6363 turns and Bob can still execute a break operation on the current integers, the interactor prints "-1 -1", and your code should promptly exit to receive a wrong answer verdict.

After printing a query, do not forget to output the end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:

  • fflush(stdout) or cout.flush() in C++;
  • System.out.flush() in Java;
  • flush(output) in Pascal;
  • stdout.flush() in Python;
  • see the documentation for other languages.

In this problem, hacks are disabled.

输入输出样例

  • 输入#1

    4
    1
    
    0 0
    3
    
    
    0 0
    13
    
    
    3 4
    
    0 0
    777777770001
    
    
    0 0

    输出#1

    second
    
    
    first
    2 1
    
    
    first
    10 7
    
    1 2
    
    
    first
    777777770000 1

说明/提示

Explanation for the interaction.

Interactor / BobAliceExplanation4 tt 1 nn for the first test casesecondAlice chooses to go second0 0Bob says he cannot break p=1p = 1 3 nn for the second test casefirstAlice chooses to go first1 2Alice breaks p=3p = 3 into p1=1p_1 = 1 and p2=2p_2 = 2 0 0Bob says he cannot break p=1p = 1 or p=2p = 2 13 nn for the third test casefirstAlice chooses to go first10 7Alice breaks p=13p = 13 into p1=10p_1 = 10 and p2=7p_2 = 7 3 4Bob breaks p=7p = 7 into p1=3p_1 = 3 and p2=4p_2 = 4 1 2Alice breaks p=3p = 3 into p1=1p_1 = 1 and p2=2p_2 = 2 0 0Bob says he cannot break p=1p = 1 or p=2p = 2 777777770001 nn for the fourth test casefirstAlice chooses to go first777777770000 1Alice breaks p=777777770001p = 777\,777\,770\,001 into p1=777777770000p_1 = 777\,777\,770\,000 and p2=1p_2 = 1 0 0Bob says he cannot perform break operation.This table is for explanation only and does not reflect the actual behavior of the interactor.

Note that in the last test case Bob could choose p1p_1 and perform a break operation but he gave up.

首页