#author SANKALP SAXENA  

# Enter your code here. Read input from STDIN. Print output to STDOUT

a = int(input());
b = int(input());
n = int(input());

print(a**b, pow(a,b, n), sep = '\n');
bc2e8e1789e075ed5e10edc9939b0ef84c4e5c45
<mask token>

<mask token>
print(a ** b, pow(a, b, n), sep='\n')

a = int(input())
b = int(input())
n = int(input())
print(a ** b, pow(a, b, n), sep='\n')

#author SANKALP SAXENA  

# Enter your code here. Read input from STDIN. Print output to STDOUT

a = int(input());
b = int(input());
n = int(input());

print(a**b, pow(a,b, n), sep = '\n');