cho.sh
Notes
Loading...

Extended Fibonacci Numbers

Time limit

2s

Memory limit

128 MB

Problem

The Fibonacci numbers are defined as follows.

F(n):={0if n=0; 1if n=1; F(n−1)+F(n−2)if n>1.F(n) := \begin{cases}0 & \text{if }n = 0\text{;} \\\ 1 & \text{if }n = 1\text{;} \\\ F(n-1) + F(n-2) & \text{if }n > 1\text{.} \end{cases}F(n):=⎩⎨⎧​0 1 F(n−1)+F(n−2)​if n=0;if n=1;if n>1.​

This definition is normally used for nonnegative integers (n). We can extend it to negative indices by requiring the recurrence (F(n)=F(n-1)+F(n-2)) to keep holding even when (n \le 1). For example, when (n=1), the equality (F(1)=F(0)+F(-1)) must hold, so (F(-1)=1).

Given an integer (n), determine the sign and absolute value of (F(n)).

Input

The first line contains an integer (n). It satisfies (|n| \le 1,000,000).

Output

On the first line, print 1 if (F(n)) is positive, 0 if it is zero, and -1 if it is negative.

On the second line, print (|F(n)|) modulo (1,000,000,000).