The Filter

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

문제

Alice, the mathematician, likes to study real numbers that are between 00 and 11. Her favourite tool is the filter.

A filter covers part of the number line. When a number reaches a filter, two events can happen. If a number is not covered by the filter, the number will pass through. If a number is covered, the number will be removed.

Alice has infinitely many filters. Her first 33 filters look like this:

In general, the kk-th filter can be defined as follows:

  • Consider the number line from 00 to 11.
  • Split this number line into 3k3^k equal-sized pieces. There are 3k+13^k + 1 points and 3k3^k intervals.
  • The kk-th filter consists of the 2nd2^\text{nd} interval, 5th5^\text{th} interval, 8th8^\text{th} interval, and in general, the (3i1)th(3i - 1)^\text{th} interval. The points are not part of the kk-th filter.

Alice has instructions for constructing the Cantor set. Start with the number line from 00 to 11. Apply all filters on the number line, and remove the numbers that are covered. The remaining numbers form the Cantor set.

Alice wants to research the Cantor set, and she came to you for help. Given an integer NN, Alice would like to know which fractions xN\frac{x}{N} are in the Cantor set.

입력

The first line contains the integer NN.

출력

Output all integers xx where 0xN0 \le x \le N and xN\frac{x}{N} is in the Cantor set.

Output the answers in increasing order. The number of answers will not exceed 10610^6.

제한

  • 2N1092 \le N \le 10^9