atcoder#ABC286F. [ABC286F] Guess The Number 2

[ABC286F] Guess The Number 2

Score : 500500 points

Problem Statement

This is an interactive task, where your and the judge's programs interact via Standard Input and Output.

You and the judge will follow the procedure below. The procedure consists of phases 11 and 22; phase 11 is immediately followed by phase 22.

(Phase 11)

  • The judge decides an integer NN between 11 and 10910^9 (inclusive), which is hidden.
  • You print an integer MM between 11 and 110110 (inclusive).
  • You also print an integer sequence A=(A1,A2,,AM)A=(A_1,A_2,\ldots,A_M) of length MM such that 1AiM1 \leq A_i \leq M for all i=1,2,,Mi = 1, 2, \ldots, M.

(Phase 22)

  • The judge gives you an integer sequence B=(B1,B2,,BM)B=(B_1,B_2,\ldots,B_M) of length MM. Here, Bi=fN(i)B_i = f^N(i). f(i)f(i) is defined by f(i)=Aif(i)=A_i for all integers ii between 11 and MM (inclusive), and fN(i)f^N(i) is the integer resulting from replacing ii with f(i)f(i) NN times.
  • Based on the given BB, you identify the integer NN that the judge has decided, and print NN.

After the procedure above, terminate the program immediately to be judged correct.

Constraints

  • NN is an integer between 11 and 10910^9 (inclusive).

Input and Output

This is an interactive task, where your and the judge's programs interact via Standard Input and Output.

(Phase 11)

  • First, print an integer MM between 11 and 110110 (inclusive). It must be followed by a newline.
M
  • Then, print a sequence A=(A1,A2,,AM)A=(A_1,A_2,\ldots,A_M) of length MM consisting of integers between 11 and MM (inclusive), with spaces in between. It must be followed by a newline.
A_1 A_2 \ldots A_M

(Phase 22)

  • First, an integer sequence B=(B1,B2,,BM)B=(B_1,B_2,\ldots,B_M) of length MM is given from the input.
B_1 B_2 \ldots B_M
  • Find the integer NN and print it. It must be followed by a newline.
N

If you print something illegal, the judge prints -1. In that case, your submission is already considered incorrect. Since the judge program terminates at this point, it is desirable that your program terminates too.

Notes

  • After each output, add a newline and then flush Standard Output. Otherwise, you may get a TLE verdict.
  • If an invalid output is printed during the interaction, or if the program terminates halfway, the verdict will be indeterminate.
  • After you print the answer (or you receive -1), immediately terminate the program normally. Otherwise, the verdict will be indeterminate.
  • Note that an excessive newline is also considered an invalid input.

Sample Interaction

The following is a sample interaction with N=2N = 2.

Input Output Description
The judge has decided that N=2N=2. NN is hidden: it is not given as an input.
4 You print MM.
2 3 4 4 You print A=(2,3,4,4)A=(2,3,4,4).
3 4 4 4 f2(1)=3,f2(2)=4,f2(3)=4f^2(1)=3,f^2(2)=4,f^2(3)=4, and f2(4)=4f^2(4)=4, so the judge gives B=(3,4,4,4)B=(3,4,4,4) to your program.
2 Based on BB, you have identified that N=2N=2. Print NN and terminate the program normally.