import sys input = lambda: sys.stdin.readline().rstrip() mod = 1000000007 ################## def large_pow(a, b, c, mod): "return (a^(b^c)) % mod. p:prime." r = pow(b, c, mod-1) return pow(a, r, mod) a, b, c = map(int, input().split()) k = int(input()) ans = large_pow((a*b*c)%mod, 2, k, mod) print(ans)