MOD = 10**9+7 A, B, C = map(int, input().split()) K = int(input()) if A*B*C == 1: exit(print(1)) ans = pow(A*B*C, pow(2, K, MOD - 1), MOD) print(ans)