Fibonacci numbers (2)

For every given pair of natural numbers n and m, compute F_(n) mod  m,
where F_(n) is the n-th Fibonacci number (starting at 0).

Input

The input consists of several pairs of n and m. Assume 0 ≤ n ≤ 10⁹ and
2 ≤ m ≤ 10³.

Output

For every given pair, print F_(n) mod  m.

Hint

Consider the problem P61833.

Problem information

Author: Salvador Roura

Generation: 2026-03-10T19:46:25.995Z

© Jutge.org, 2006–2026.
https://jutge.org
