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