One day the sultan's most trusted vizier
died in battle. Sultan wants to choose a vizier from his soldiers. But it was
hard choice for Sultan to select just one man from available N
. So Sultan decides to prepare such a game that will help him to choose
new vizier. First of all Sultan asks to his favorite soldiers to take a unique
number (from 1 to N) and after he enumerates all his soldiers with remaining
unique numbers. The rules of Sultan`s game is simple: he arrange soldiers by
their numbers in increasing order. Then he eliminates all soldiers whom were
standing in 1, 3, 5… positions. After last soldier in eliminated Sultan rearrange
soldiers by using same rule and starts elimination game again. Sultan`s game
continues until just one soldiers left un eliminated. So Sultan promotes this
soldier to vizier position.
Input
The number of soldiers (n <10 ^ 7) and
the number sultan's
favorite soldiers m (m <= n).
The numbers selected by the sultan's
favorite soldiers s [i] (s [i]>
= 1 && s [i] <= n).
Output
Print the number which number to be vizier.
Print the game ranked number selected by
soldiers from the Sultan's favorite.
|
Input
|
Output
|
|
6 3
1 5 6
|
4
1 3 5
|
Для отправки решений необходимо