Kevin's Cards
Kevin is playing a card game with his three friends, Tuga, Messy Kevin, and Klevin. This game is played with a special big deck of cards, such that each player is dealt cards labelled
to
.
To best strategise for the game before it starts, Kevin wants to arrange his hand of cards in a particular manner. Kevin wants to arrange his cards such that no two adjacent cards have a difference of 1. Specifically, for all ,
. Can you tell Kevin one such arrangement of the cards, or let him know if it is impossible?
Input
The input consists of a single integer (
), the number of cards each player will be dealt in this game. The cards of Kevin's hand are labelled
through
.
Output
If it is possible to arrange the numbers such that no two adjacent cards have an absolute difference of 1, output any of the arrangements on a single line, separated by spaces. Any valid arrangement will be accepted.
If it is impossible, output Impossible.
Example
Input 1
5
Output 1
1 3 5 2 4
Input 2
3
Output 2
Impossible
There is no way to arrange 1 2 3 in a valid manner. We can simply enumerate all permutations and check that none of them work: 1 2 3, 1 3 2, 2 1 3, 2 3 1, 3 1 2, 3 2 1.
Comments