Under construction

Still being built. Things may change

Fibonacci product

Interview

Time limit1sMemory limit1024 MB

Summary
Given n, count the ways to write it as a product of Fibonacci numbers greater than 1, where order does not matter.
Level

Medium5 of 10

Topics
Backtracking, Recursion, Math
Solved
No attempts yet

Statement

The Fibonacci sequence is defined as follows: F0=1F_0 = 1, F1=1F_1 = 1, Fn=Fn−2+Fn−1F_n = F_{n-2} + F_{n-1}. The sequence begins 1,1,2,3,5,8,13,21,34,…1, 1, 2, 3, 5, 8, 13, 21, 34, \dots.

A natural number nn is given. Count the number of ways to write nn as a product of Fibonacci numbers, each greater than 1.

Input

The first line contains an integer tt, the number of test cases (1≤t≤501 \le t \le 50). Each of the next tt lines contains one integer nn (2≤n≤10182 \le n \le 10^{18}).

Output

For each test case, print the number of ways on a separate line.

Hint

In the example, the number 2 can be written as a product of Fibonacci numbers in exactly one way: 2=22 = 2. The number 7 cannot be written as a product of Fibonacci numbers. The number 8 can be written in two ways: 8=2×2×28 = 2 \times 2 \times 2 and 8=88 = 8. The number 40 can be written in two ways: 40=2×2×2×540 = 2 \times 2 \times 2 \times 5 and 40=5×840 = 5 \times 8.

Examples1

  1. Example 1

    Input
    5
    2
    7
    8
    40
    64
    
    Expected output
    1
    0
    2
    2
    3