def main(): A,B,C = map(int,input().split()); MOD = pow(10,9) + 7 K = int(input()) x = pow(2,K,MOD-1) a = pow(A,x,MOD) b = pow(B,x,MOD) c = pow(C,x,MOD) ans = a*b*c%MOD print(ans) if __name__ == '__main__': main()