There are players, numbered from to .
Player
's score is defined to be
.
Here,
refers to the largest positive integer that
divides both
and
.
Your task is to find an ordering of the players, from left to right, that satisfies the following conditions:
It can be proved that these rules uniquely
define an ordering of the
people.
Your task is to find this ordering.
For each test case, print space-separated integers on a new line — the player numbers in the required preference order.
5 1 2 3 4 5
1 2 1 3 1 2 4 2 1 3 5 1 2 3 4
Test case : There is only one player.
Test case
:
There are two players.
Player
has a score of
, while player
has a score of
.
Player
has a higher score, and so appears to the
left of player
, making the only possible order
.
Test case
:
There are four players. It can be verified
that players
and
have a score of
, player
has a score of
, and player
has a score of
.
So,
Thus, the final order is .