a, b, c = map(int, input().split()) k = int(input()) mod = 10**9 + 7 p = pow(2, k, mod - 1) print(pow(a, p, mod) * pow(b, p, mod) * pow(c, p, mod) % mod)