1219 整数模


Submit solution

Points: 100
Time limit: 1.0s
Memory limit: 32M

Problem types
Allowed languages
C, C++, Java, Python

Description

a除以m的余数称为a对于m的模。求ap对于m的模。

Input

输入数据中含有一些数据组,每个数据组占一行,包括a、p、m(0<a,p<2^32,1≤m<2^16)三个整数,若三个数都为0,则表示输入结束。

Output

针对每组数据,输出a的p次幂对于m的模,每个结果占一行。

Sample

Input

3 18132 17
0 0 0

Output

13

Source: qianneng


Comments

There are no comments at the moment.