Given the first two values of a sequence defined by a Fibonacci-like recurrence, answer the n-th term modulo .
You are given two integers and that define a sequence as follows:
For a given index , compute the value of modulo .
Because the values can become negative, the answer should always be reported in the standard non-negative modulo form.
This is a direct sequence-evaluation problem with a repeating pattern in the recurrence.
Example 1
Input
1 2 1
Output
1
Explanation
The first term is .
Example 2
Input
1 2 4
Output
1
Explanation
The sequence is , so . For illustration, the sample output format here shows the direct value modulo normalization would be used in practice.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.