Fibonacci Half Sequence
Time limit2sMemory limit1024 MB
For n up to 10^18, find the lexicographically smallest sequence a with a[a[n]] = f[n], where f is 1, 2, 3, 5, ...; print -1 if a[n] exceeds 10^18.
Problem
The Fibonacci sequence starts with 1 and 2 and is defined as follows.
- For ,
The half sequence of this Fibonacci sequence is defined as follows.
- is the lexicographically smallest sequence among all sequences that satisfy for every positive integer .
Sequence is lexicographically smaller than if there exists an such that for every less than , and .
Input
The first line contains the number of test cases .
Each of the next lines contains one value of .
Output
For each , print on its own line. If , print -1 instead.