The well known Fibonacci numbers are defined recursively as follows: , , for . The first Fibonacci numbers are 0, 1, 1, 2, 3, 5, 8, 13, 21, ….
Let us generalize the Fibonacci numbers. For every pair of natural numbers and , define the sequence as , , for . Note that is the traditional Fibonacci sequence.
You are given a natural number . Please compute how many pairs exist such that has a where . For instance, for there are exactly three such sequences: , , and .
Input consists of several cases, each with a different natural number between 1 and .
For every , print the number of pairs such that appears at a position in .
Depending on your solution, Cassini’s identity could be useful: .
Input
2 1 3 9 10 1000 1000000
Output
3 1 4 8 10 780 773883