#https://www.hackerrank.com/challenges/python-power-mod-power


# Enter your code here. Read input from STDIN. Print output to STDOUT
a = int(raw_input(""))
b = int(raw_input(""))
m = int(raw_input(""))
print(pow(a,b))
print(pow(a,b,m))

