By Kay Akashi
Given a recursion rule , where , output the value of mod given .
.
.
.
The first line of input contains integers, and . The second line of input contains integer, .
Output a single integer, the value of mod .
3 4
5
241
, , , , and .
2915 2999
965736817718
56311101