This page is still under construction.

Parts of this page are still being built. What you see may change.

Phibonacci

Time limit1sMemory limit256 MB

Summary
Given n and k, decide whether (P_n)^k equals A φ^k + B for integers A and B and print them modulo 1,000,000,007, or -1.
Level

Hard9 of 10

Topics
Number theory, Math
Solved
No attempts yet

Problem

The Fibonacci numbers are defined by the recurrence below.

Fn={0n=01n=1Fn−1+Fn−2n>1F_n = \begin{cases} 0 & n = 0 \\ 1 & n = 1 \\ F_{n-1} + F_{n-2} & n > 1 \end{cases}

The Fibonacci numbers are closely tied to the golden ratio φ=5+12\varphi = \frac{\sqrt{5}+1}{2}, one of the two roots of x2=x+1x^2 = x + 1. One example of that tie is the closed form Fn=φn−(1−φ)n5F_n = \frac{\varphi^n - (1 - \varphi)^n}{\sqrt{5}}. Now use φ\varphi to define the Phibonacci numbers by the recurrence below.

Pn={1n=0φn=1Pn−1+Pn−2n>1P_n = \begin{cases} 1 & n = 0 \\ \varphi & n = 1 \\ P_{n-1} + P_{n-2} & n > 1 \end{cases}

If you set F−1=1F_{-1} = 1, then Pn=Fnφ+Fn−1P_n = F_n \varphi + F_{n-1} holds for every n≥0n \ge 0. The question here is whether (Pn)k(P_n)^k can be written as Aφk+BA \varphi^k + B for two integers AA and BB. If it can, print AA and BB. If it cannot, print -1.

Input

The first line contains two integers nn and kk, separated by a space.

The bounds are 0≤n≤10120 \le n \le 10^{12} and 1≤k≤10121 \le k \le 10^{12}.

Output

On the first line, print the two integers AA and BB with (Pn)k=Aφk+B(P_n)^k = A \varphi^k + B, each taken modulo 1,000,000,007 and separated by a space. If no such pair of integers exists, print -1.

Hint

For n=3n = 3 and k=2k = 2, (P3)2=(2φ+1)2=4φ2+4φ+1=8φ2−3(P_3)^2 = (2\varphi + 1)^2 = 4\varphi^2 + 4\varphi + 1 = 8\varphi^2 - 3. The remainder of −3-3 modulo 1,000,000,007 is 1,000,000,004.

Examples5

  1. Example 1

    Input
    5 1
    
    Expected output
    5 3
    
  2. Example 2

    Input
    3 2
    
    Expected output
    8 1000000004
    
  3. Example 3

    Input
    0 1
    
    Expected output
    0 1
    
  4. Example 4

    Input
    1 1
    
    Expected output
    1 0
    
  5. Example 5

    Input
    2 3
    
    Expected output
    4 1