cho.sh
Notes
Loading...

Card 1

Time limit

2s

Memory limit

128 MB

Problem

There are N cards numbered from 1 through N in a stack. Initially, card 1 is on top and card N is on the bottom.

Repeat the following two operations until only one card remains.

  1. Discard the top card.
  2. If any cards remain, move the new top card to the bottom of the stack.

For N = 4, the initial order from top to bottom is 1, 2, 3, 4. After discarding 1 and moving 2 to the bottom, the order becomes 3, 4, 2. Then 3 is discarded and 4 is moved to the bottom, leaving 2, 4. Finally, 2 is discarded and 4 remains.

Given N, write a program that prints the discarded card numbers in order, followed by the number of the final remaining card.

Input

The first line contains an integer N. (1 <= N <= 1,000)

Output

Print one line containing the discarded card numbers in order, followed by the final remaining card number. Separate adjacent numbers with a single space.