#!/usr/bin/python3 mod = 10**9 + 7 a, b, c = map(int, input().split('^')) r1 = pow(pow(a, b, mod), c, mod) r2 = pow(a, pow(b, c, mod-1) + (mod-1), mod) print(r1, r2)