A Bit Sequence Puzzle#1705

A Bit Sequence Puzzle

1 second
64 megabytes
Very easy

A student named Alex is very inquisitive and is always searching for something new on the Internet. Recently, Alex was lucky and found a video lecture by a famous mathematician, which was carefully watched that evening. The next day, after an additional programming class, Alex created the following puzzle, which is now offered for you to solve.

You are given a non-negative integer. This number is the first term of the sequence. Now, this number should be represented in binary form, and the following operation is performed repeatedly on its bit sequence: In the next term, the new value of a bit is equal to the sum of this bit and the next bit modulo . Since the last bit has no right neighbor, following the recommendation from the lecture, Alex again writes the first bit at the end when performing the operation. Alex was surprised to see that at some step, the sequence generated in this way becomes periodic—apparently, this was mentioned in the lecture as well, but Alex does not remember exactly...

Alex became interested in these questions: At which step does the sequence first become periodic according to the algorithm described above, and what is the length of the period? Help Alex find the answers to these questions.

Input

The only non-negative integer , not exceeding 10^8, is the first term of the sequence.

Output

On a single line, output the required two numbers separated by a space: the step when the first member of such a periodic sequence appears and the length of the period of this sequence.

Examples

Example 1

Loading
Loading