#abc282f. [abc282_f]Union of Two Sets

[abc282_f]Union of Two Sets

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 gives you an integer NN.
  • You print an integer MM between 11 and 5000050000, inclusive.
  • You also print MM pairs of integers (l1,r1),(l2,r2),ldots,(lM,rM)(l_1, r_1), (l_2, r_2), \\ldots, (l_M, r_M) such that 1leqlileqrileqN1 \\leq l_i \\leq r_i \\leq N for every i=1,2,ldots,Mi = 1, 2, \\ldots, M (the MM pairs do not have to be distinct).

(Phase 22)

  • The judge gives you an integer QQ.
  • You and the judge repeats the following QQ times.
    • The judge gives you two integers LL and RR as a query.
    • You respond with two integers aa and bb between 11 and MM, inclusive (possibly with a=ba = b). Here, aa and bb must satisfy the condition below. Otherwise, your submission will be judged incorrect.
      • The union of the set lbracela,la+1,ldots,rarbrace\\lbrace l_a, l_a+1, \\ldots, r_a\\rbrace and the set lbracelb,lb+1,ldots,rbrbrace\\lbrace l_b, l_b+1, \\ldots, r_b\\rbrace equals the set lbraceL,L+1,ldots,Rrbrace\\lbrace L, L+1, \\ldots, R\\rbrace.

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

Constraints

  • 1leqNleq40001 \\leq N \\leq 4000
  • 1leqQleq1051 \\leq Q \\leq 10^5
  • 1leqLleqRleqN1 \\leq L \\leq R \\leq N
  • All values in the input are integers.

Input and Output

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

(Phase 11)

  • First, NN is given from the input.
  • Next, an integer MM between 11 and 5000050000, inclusive, should be printed.
  • Then, (l1,r1),(l2,r2),ldots,(lM,rM)(l_1, r_1), (l_2, r_2), \\ldots, (l_M, r_M) should be printed, one at a time. Specifically, for each i=1,2,ldots,Mi = 1, 2, \\ldots, M, the ii-th output should be (li,ri)(l_i, r_i) in the following format:

lil_i rir_i

(Phase 22)

  • First, QQ is given from the input.
  • In each query, integers LL and RR representing the query are given in the following format:

LL RR

  • In response to each query, two integers aa and bb should be printed in the following format:

aa bb

Cautions

  • At the end of each output, print a newline and flush Standard Output. Otherwise, you may get the TLE