Many recurrent sequences acquire new interesting properties if they are calculated modulo of some number. Due to the finiteness of the division residues, sequences turn into cycles or loops. The Fibonacci numbers are a good example of a looping sequence. The Fibonacci sequence is defined by the recurrence relation $$$ F_i = F_{i-1} + F_{i-2} $$$, where $$$ F_0 = 0, F_1 = 1 $$$.
When calculating such a sequence taken modulo $$$ n $$$, after a certain number of steps, there is a return to the initial values of $$$ 0 $$$ and $$$ 1 $$$. The minimum number of steps required to loop the sequence is denoted as $$$ \pi(n) $$$ and is called the Pisano period. The number $$$ \pi(n) $$$ exists for any $$$ n $$$. For each $$$ \pi(n) $$$ is valid $$$ F_{i} \equiv F_{i+\pi(n)} (mod~n) $$$ with any $$$ i $$$.
The relationship between the length of the Pisano period $$$ \pi(n) $$$ and the number $$$ n $$$ itself is quite complex and comes down to calculating Pisano periods for prime numbers. For a prime number $$$ p $$$, the value of $$$ \pi(p) $$$ is calculated according to the following rules:
A single line contains a prime number $$$ p $$$ ($$$ 2 \leq p \leq 10^9 $$$).
In a single line print a number – the length of the Pisano period $$$ \pi(p) $$$.
11
10
5
20