Sorting

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

Sashka regularly takes part in online programming competitions. The prize for the current one is participation in a summer programming camp in the Maldives. Especially for this contest she has set her username to be Sorting. One of the tasks is the following:

The jury has come up with a permutation p_1,p_2,p_3,,p_Np\_1, p\_2, p\_3, \dots , p\_N of the numbers from 11 to NN. The task is to find the permutation and in order to do so you can ask the jury the following two types of questions:

  1. Given two positions xx and yy in the permutation (1x,yN1 ≤ x, y ≤ N), is it true that p_x<p_yp\_x < p\_y?
  2. Given a number dd and two positions xx and yy in the permutation (1x,y,dN1 ≤ x, y, d ≤ N), is it true that p_xp_y0(modd)|p\_x − p\_y| ≡ 0 \pmod d. In other words, is it true that the difference of the elements in the permutation at the xx-th and yy-th positions is divisible by dd?

You have to ask as few questions as possible from the first type (see the scoring section below), but the number of questions of the second type is unlimited.

Help Sashka by writing a program sorting, which by given NN restores the permutation. It must contain the function solve, which will be compiled and executed with a jury’s program.

제한

  • 2N500,0002 ≤ N ≤ 500\\,000
  • 1p_iN1 ≤ p\_i ≤ N for each 1iN1 ≤ i ≤ N.
  • p_ip_jp\_i \ne p\_j for each 1i<jN1 ≤ i < j ≤ N.