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