Everyone knows the Fibonacci sequence, right? f1=1f_1=1f1=1, f2=1f_2=1f2=1, f3=2f_3=2f3=2, f4=3f_4=3f4=3, …\dots…, fn=fn−1+fn−2f_n=f_{n-1}+f_{n-2}fn=fn−1+fn−2.
Now the problem is simple: given nnn and mmm, compute fn mod mf_n \bmod mfnmodm.
Input nnn and mmm.
Output fn mod mf_n \bmod mfnmodm.
5 1000
5
For 100%100\%100% of the data, 1≤n≤2×1091\le n \le 2\times 10^91≤n≤2×109, 1≤m≤109+101\le m \le 10^9+101≤m≤109+10.
Using your Hydro universal account