a, b, c = map(int, input().split('^')) print((a ** b) ** c % 1000000007, a ** (b ** c) % 1000000007)