N, M, L, K, B = map(int, input().split()) if L == 1: print(pow(1 + M, N, B)) exit() now = [0] * L now[0] = now[1] = 1 lst = [] while N != 1: if N % 2 == 0: lst.append(1) N //= 2 else: lst.append(0) N -= 1 lst.reverse() for flag in lst: if flag: nex = [0] * (2 * L) for i in range(L): for j in range(L): nex[i + j] += now[i] * now[j] nex[i + j] %= B for i in range(L, 2 * L): nex[i - L] += nex[i] * M nex[i - L - 1] %= B else: nex = [0] * (L + 1) for i in range(L): nex[i] += now[i] nex[i + 1] += now[i] nex[i] %= B nex[i + 1] %= B nex[0] += nex[L] * M nex[0] %= B now = nex[:L] print(now[K])