# R39260119
a = input().split()
print(a[0]+"^"+a[1]+" mod "+a[2]+"="+str(pow(int(a[0]), int(a[1]), int(a[2]))))