Calculate R = (BP) mod M for large B, P, and M. Integer B and P are in the range 0 to 2147483647 (=231 – 1) inclusive. Integer M is in the range 1 to 46340 inclusive. Note you cannot calculate R directly because M is too large.
There are multiple test cases. Each test case is given in three lines, containing B, P, and M in each line.
For each test case, output the answer R in a single line.