import sys
from collections import deque, defaultdict, Counter
from functools import cache
import math
import heapq

# for line in sys.stdin:
#     a = line.split()
#     print(int(a[0]) + int(a[1]))

a, b, c, d, mod = map(int, sys.stdin.readline().split())

x = a * b

print(pow(x, c*d, mod))