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