The Fibonacci numbers are defined by the recurrence below.
Fn=⎩⎨⎧01Fn−1+Fn−2n=0n=1n>1
The Fibonacci numbers are closely tied to the golden ratio φ=25+1, one of the two roots of x2=x+1. One example of that tie is the closed form Fn=5φn−(1−φ)n. Now use φ to define the Phibonacci numbers by the recurrence below.
Pn=⎩⎨⎧1φPn−1+Pn−2n=0n=1n>1
If you set F−1=1, then Pn=Fnφ+Fn−1 holds for every n≥0. The question here is whether (Pn)k can be written as Aφk+B for two integers A and B. If it can, print A and B. If it cannot, print -1.
The first line contains two integers n and k, separated by a space.
The bounds are 0≤n≤1012 and 1≤k≤1012.
On the first line, print the two integers A and B with (Pn)k=Aφk+B, each taken modulo 1,000,000,007 and separated by a space. If no such pair of integers exists, print -1.
For n=3 and k=2, (P3)2=(2φ+1)2=4φ2+4φ+1=8φ2−3. The remainder of −3 modulo 1,000,000,007 is 1,000,000,004.