There are $n$ warriors in a row. The power of the $i$-th warrior is $a_i$. All powers are pairwise distinct.

You have two types of spells which you may cast:   Fireball: you spend $x$ mana and destroy exactly $k$ consecutive warriors;  Berserk: you spend $y$ mana, choose two consecutive warriors, and the warrior with greater power destroys the warrior with smaller power. 

For example, let the powers of warriors be $[2, 3, 7, 8, 11, 5, 4]$, and $k = 3$. If you cast Berserk on warriors with powers $8$ and $11$, the resulting sequence of powers becomes $[2, 3, 7, 11, 5, 4]$. Then, for example, if you cast Fireball on consecutive warriors with powers $[7, 11, 5]$, the resulting sequence of powers becomes $[2, 3, 4]$.

You want to turn the current sequence of warriors powers $a_1, a_2, \dots, a_n$ into $b_1, b_2, \dots, b_m$. Calculate the minimum amount of mana you need to spend on it.


-----Input-----

The first line contains two integers $n$ and $m$ ($1 \le n, m \le 2 \cdot 10^5$) — the length of sequence $a$ and the length of sequence $b$ respectively.

The second line contains three integers $x, k, y$ ($1 \le x, y, \le 10^9; 1 \le k \le n$) — the cost of fireball, the range of fireball and the cost of berserk respectively.

The third line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le n$). It is guaranteed that all integers $a_i$ are pairwise distinct.

The fourth line contains $m$ integers $b_1, b_2, \dots, b_m$ ($1 \le b_i \le n$). It is guaranteed that all integers $b_i$ are pairwise distinct.


-----Output-----

Print the minimum amount of mana for turning the sequnce $a_1, a_2, \dots, a_n$ into $b_1, b_2, \dots, b_m$, or $-1$ if it is impossible.


-----Examples-----
Input
5 2
5 2 3
3 1 4 5 2
3 5

Output
8

Input
4 4
5 1 4
4 3 1 2
2 4 3 1

Output
-1

Input
4 4
2 1 11
1 3 2 4
1 3 2 4

Output
0

Difficulty: HARD
Tags: Constructive algorithms

Amortized analysis

Implementation

Greedy algorithms

Mathematics
Skill types: Amortized analysis

Greedy algorithms

Starter code:

Solutions:
total = 0
array1 = []
array2 = []
input_array1 = input().split()
n = int(input_array1[0])
m = int(input_array1[1])
input_array0 = input().split()
x = int(input_array0[0])
k = int(input_array0[1])
y = int(input_array0[2])
input_array2 = input().split()
input_array3 = input().split()
for i in range(0, n):
	array1.append(int(input_array2[i]))
for i in range(0, m):
	array2.append(int(input_array3[i]))
start = 1
closure = 0
j = i = 0
s = 0
if n == m:
	if array1 == array2:
		print(0)
		exit()
	else:
		print(-1)
		exit()
while j < n:
	r = -1
	p = -1
	i = j
	maxi = 0
	l = length = 0
	while i < n:
		if s < m:
			a = array2[s] == array1[i]
		else:
			a = 0
		if i == 0 and a:
			r = array1[0]
			start = 2
			i += 1
			s += 1
		elif a == 0:
			if i != 0 and start == 1:
				r = array1[i - 1]
				start = 2
			if array1[i] > maxi:
				maxi = array1[i]
			i += 1
			length += 1
			l = length
		else:
			p = array1[i]
			s += 1
			break
	if x / k > y:
		if maxi < p or maxi < r:
			total += y * length
			start = 1
		elif k > length:
			print(-1)
			closure = 1
			break
		else:
			total += (length - k) * y + x
			start = 1
	elif l % k == 0:
		total += x * (l / k)
		start = 1
	elif maxi < p or maxi < r:
		total += l % k * y + int(l / k) * x
		start = 1
	elif k < length:
		total += l % k * y + int(l / k) * x
		start = 1
	else:
		print(-1)
		closure = 1
		break
	j = i + 1
	if closure == 1:
		break
if closure != 1:
	print(int(total))


(n, m) = [int(x) for x in input().split()]
(fire_mana, fire_range, bsk_mana) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
(i, k) = (0, 0)
min_mana = 0
last_target = 0
for j in range(n):
	if a[j] == b[k]:
		enemies = j - i
		if enemies > 0:
			edgepower = max(last_target, b[k])
			max_enemypower = max(a[i:j])
			mana_used = 0
			if max_enemypower > edgepower:
				enemies -= fire_range
				mana_used += fire_mana
			if enemies < 0:
				min_mana = -1
				break
			if fire_mana / fire_range < bsk_mana:
				mana_used += fire_mana * (enemies // fire_range)
				enemies %= fire_range
			mana_used += bsk_mana * enemies
			min_mana += mana_used
		last_target = b[k]
		i = j + 1
		k += 1
		if k == m:
			break
if k != m:
	min_mana = -1
if min_mana != -1:
	enemies = n - i
	if enemies > 0:
		edgepower = last_target
		max_enemypower = max(a[i:])
		mana_used = 0
		if max_enemypower > edgepower:
			enemies -= fire_range
			mana_used += fire_mana
		if enemies < 0:
			min_mana = -1
		else:
			if fire_mana / fire_range < bsk_mana:
				mana_used += fire_mana * (enemies // fire_range)
				enemies %= fire_range
			mana_used += bsk_mana * enemies
			min_mana += mana_used
print(min_mana)


from sys import stdin

def mp():
	return map(int, stdin.readline().split())

def ml():
	return list(map(int, stdin.readline().split()))
(n, m) = mp()
(x, k, y) = mp()
a = ml()
b = ml()

def delSeg(st, end, mx):
	cnt = end - st
	aend = max(a[end], a[st - 1] if st - 1 > 0 else 0) if end < n else a[st - 1]
	if cnt == 0:
		return 0
	if cnt < k and mx > aend:
		return -1
	if x <= k * y:
		return cnt // k * x + cnt % k * y
	elif mx < aend:
		return cnt * y
	else:
		return x + (cnt - k) * y
prev = 0
j = 0
mx = -1
(ans, flag) = (0, True)
for i in range(n):
	if j < m and a[i] == b[j]:
		ret = delSeg(prev, i, max(a[prev:i]) if prev != i else 0)
		if ret == -1:
			flag = False
			break
		else:
			ans += ret
		j += 1
		prev = i + 1
	elif j >= m:
		mx = max(a[prev:n])
		ret = delSeg(prev, n, mx)
		if ret == -1:
			flag = False
			break
		else:
			ans += ret
		break
	i += 1
if flag and j >= m:
	print(ans)
else:
	print(-1)


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
(X, K, Y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

def score(T, bmax):
	L = len(T)
	if L == 0:
		return 0
	tmax = max(T)
	if L < K:
		if tmax > bmax:
			return -1
		return L * Y
	elif K * Y >= X:
		return L // K * X + L % K * Y
	elif tmax > bmax:
		return X + (L - K) * Y
	else:
		return L * Y
bind = 0
T = []
ans = 0
for a in A:
	if bind < M and B[bind] == a:
		bmax = B[bind]
		if bind > 0:
			bmax = max(B[bind - 1], bmax)
		res = score(T, bmax)
		if res == -1:
			ans = -1
			break
		ans += res
		bind += 1
		T = []
		continue
	T.append(a)
if bind != M:
	ans = -1
else:
	res = score(T, B[M - 1])
	if res == -1:
		ans = -1
	else:
		ans += res
print(ans)


def one_segment(left, right, lower, upper):
	if left == right + 1:
		return 0
	singles = 0
	groups = 0
	to_delete = right - left + 1
	maxi = max(aa[left:right + 1])
	if to_delete < k:
		if maxi > max(lower, upper):
			return -1
		else:
			return to_delete * y
	if to_delete > k:
		singles += to_delete % k
		to_delete = to_delete - singles
	if k * y > x:
		groups += to_delete / k
	elif maxi < max(lower, upper):
		singles += to_delete
	else:
		singles += to_delete - k
		groups += 1
	return singles * y + groups * x
(n, m) = list(map(int, input().strip().split()))
(x, k, y) = list(map(int, input().strip().split()))
aa = list(map(int, input().strip().split()))
bb = list(map(int, input().strip().split()))
not_poss = 0
pl1 = -1
l1 = 0
ans = 0
for l2 in bb:
	if not_poss == 1:
		break
	while l1 < len(aa) and aa[l1] != l2:
		l1 += 1
	if l1 == len(aa):
		not_poss = 1
		break
	else:
		temp = 0
		if pl1 == -1 and l1 != 0:
			temp = one_segment(0, l1 - 1, -1, aa[l1])
		elif pl1 != -1:
			temp = one_segment(pl1 + 1, l1 - 1, aa[pl1], aa[l1])
		if temp == -1:
			not_poss = 1
			break
		else:
			ans += temp
		pl1 = l1
if not_poss == 0 and l1 < len(aa):
	temp = one_segment(l1 + 1, len(aa) - 1, aa[l1], -1)
	if temp == -1:
		not_poss = 1
	else:
		ans += temp
if not_poss == 1:
	print(-1)
else:
	print(int(ans))


from sys import stdin
(n, m) = map(int, stdin.readline().rstrip().split(' '))
(x, k, y) = map(int, stdin.readline().rstrip().split(' '))
l = list(map(int, stdin.readline().rstrip().split(' ')))
l2 = list(map(int, stdin.readline().rstrip().split(' ')))
z = {}
for i in range(n):
	z[l[i]] = i
mana = 0
start = -1
arr = []
for i in range(m):
	a = z[l2[i]] - start
	if start == -1:
		max_border = l2[i]
	else:
		max_border = max([l2[i], l[start]])
	if a < 0:
		mana = -1
		break
	elif a > 1:
		c = 0
		ma = 0
		for j in range(start + 1, z[l2[i]]):
			c += 1
			ma = max(ma, l[j])
		if c < k and ma > max_border:
			mana = -1
			break
		elif k * y < x:
			if ma > max_border:
				adding = x + (c - k) * y
				mana += adding
			else:
				adding = c * y
				mana += adding
		else:
			adding = c // k * x + y * (c % k)
			mana += adding
	start = z[l2[i]]
if mana != -1:
	if l2[-1] != l[-1]:
		c = 0
		ma = 0
		for i in range(z[l2[-1]] + 1, n):
			ma = max(ma, l[i])
			c += 1
		if c < k and ma > l2[-1]:
			mana = -1
		elif k * y < x:
			if ma > l2[-1]:
				adding = x + (c - k) * y
				mana += adding
			else:
				adding = c * y
				mana += adding
		else:
			adding = c // k * x + y * (c % k)
			mana += adding
print(mana)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [-1] + list(map(int, input().split())) + [-2]
b = [-1] + list(map(int, input().split())) + [-2]
if m > n:
	print(-1)
elif m == n:
	print(-int(a != b))
else:
	g = {}
	for i in range(n + 2):
		g[a[i]] = i
	binds = []
	for i in b:
		if i not in g or (binds and binds[-1] > g[i]):
			print(-1)
			return ()
		binds.append(g[i])
	dels = []
	for i in range(len(binds) - 1):
		dels.append([])
		for j in range(binds[i], binds[i + 1] + 1):
			dels[-1].append(a[j])
	ans = 0
	for d in dels:
		todel = len(d) - 2
		if todel:
			mx = max(d)
			allys = max(d[0], d[-1]) == mx
			if y * k < x:
				if allys:
					ans += todel * y
				else:
					if todel < k:
						print(-1)
						return ()
					ans += y * (todel - k) + x
			elif todel < k:
				if allys:
					ans += todel * y
				else:
					print(-1)
					return ()
			else:
				ans += y * (todel % k) + x * (todel // k)
	print(ans)


import sys
input = sys.stdin.readline
(n, m) = list(map(int, input().split()))
(x, k, y) = list(map(int, input().split()))
B = list(map(int, input().split()))
A = list(map(int, input().split()))
inda = 0
for b in B:
	if b == A[inda]:
		inda += 1
	if inda == len(A):
		break
if inda != len(A):
	print(-1)
	return
B += [0]
A = set(A) | {0}
ONE = 0
TWO = 0
C = []
ANS = 0
for b in B:
	if not b in A:
		C.append(b)
	else:
		ONE = TWO
		TWO = b
		MAX = max(ONE, TWO)
		L = len(C)
		ST = 0
		for c in C:
			if c > MAX:
				ST += 1
		if ST > 0 and L < k:
			print(-1)
			return
		elif ST > 0:
			COST = x
			rest = L - k
			COST += min(rest // k * x + rest % k * y, rest * y)
			ANS += COST
			C = []
		else:
			COST = min(L // k * x + L % k * y, L * y)
			ANS += COST
			C = []
print(ANS)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
(n, m) = rint()
(x, k, y) = rint()
a = list(rint())
b = list(rint())
a.append(-10 ** 10)
b.append(-10 ** 10)
ans = 0
j = 0
l = 0
max_in = -1
lv = -10 ** 10
for i in range(n + 1):
	if a[i] == b[j]:
		rv = a[i]
		if l < k:
			if max_in < max(lv, rv):
				ans += y * l
			else:
				ans = -1
				break
		elif x < y * k:
			ans += x * (l // k) + y * (l % k)
		elif max_in < max(lv, rv):
			ans += y * l
		else:
			ans += x + y * (l - k)
		l = 0
		lv = rv
		j += 1
		max_in = -1
	else:
		max_in = max(max_in, a[i])
		l += 1
if j != m + 1:
	ans = -1
print(ans)


for _ in range(1):
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.append(0)
	b.append(0)
	itr = 0
	prev = 0
	leng = 0
	maxp = 0
	mana = 0
	for i in range(n + 1):
		if a[i] == b[itr]:
			if maxp < max(prev, a[i]):
				mana += min(leng // k * x + leng % k * y, leng * y)
				leng = 0
				maxp = 0
				itr += 1
				prev = a[i]
				continue
			if leng < k:
				break
			mana += min(x + (leng - k) * y, leng // k * x + leng % k * y)
			leng = 0
			maxp = 0
			prev = a[i]
			itr += 1
		else:
			leng += 1
			maxp = max(maxp, a[i])
	if itr != m + 1:
		print(-1)
	else:
		print(mana)


from sys import stdin, stdout

def get_ans(mx, x, k, y, a, l, r):
	cnt = r - l - 1
	amx = 0
	if l >= 0:
		amx = max(amx, a[l])
	if r < len(a):
		amx = max(amx, a[r])
	ans = cnt // k * x + cnt % k * y
	if amx > mx:
		ans = min(cnt * y, ans)
	else:
		if cnt < k:
			return [False, None]
		ans = min(x + (cnt - k) * y, ans)
	return [True, ans]

def berserk_and_fireball(n, m, x, k, y, a, b):
	ans = 0
	j = 0
	mx = 0
	l = -1
	for r in range(n):
		if j < m and a[r] == b[j]:
			lr = get_ans(mx, x, k, y, a, l, r)
			if not lr[0]:
				return -1
			ans += lr[1]
			j += 1
			l = r
			mx = 0
		else:
			mx = max(mx, a[r])
	if j < m:
		return -1
	lr = get_ans(mx, x, k, y, a, l, n)
	if not lr[0]:
		return -1
	ans += lr[1]
	return ans
(n, m) = map(int, stdin.readline().split())
(x, k, y) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
stdout.write(str(berserk_and_fireball(n, m, x, k, y, a, b)))


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
(n, m) = list(map(int, input().split()))
(x, k, y) = list(map(int, input().split()))
la = list(map(int, input().split()))
lb = list(map(int, input().split()))
lol = 0
if y * k < x:
	lol = 1
j = 0
ind = []
for i in range(n):
	if j == m:
		break
	if la[i] == lb[j]:
		ind.append(i)
		j += 1
if j != m:
	print(-1)
else:
	l = la
	ans = 0
	curr = ind[0]
	flag = 0
	le = ind[0]
	mx = 0
	for j in range(0, ind[0]):
		mx = max(mx, l[j])
	if lol == 1:
		if mx < l[ind[0]]:
			ans += le * y
		elif le and le < k:
			flag = 1
		elif le:
			ans += (le - k) * y + x
	elif le and le < k:
		if mx < l[ind[0]]:
			ans += le * y
		else:
			flag = 1
	else:
		rem = le % k
		ans += rem * y
		ans += le // k * x
	for i in range(1, len(ind)):
		le = ind[i] - curr - 1
		mx = 0
		for j in range(curr + 1, ind[i]):
			mx = max(mx, l[j])
		if lol == 1:
			if mx < l[curr] or mx < l[ind[i]]:
				ans += le * y
			elif le and le < k:
				flag = 1
				break
			elif le:
				ans += (le - k) * y + x
		elif le and le < k:
			if mx < l[ind[i]] or mx < l[ind[i]]:
				ans += le * y
			else:
				flag = 1
				break
		else:
			rem = le % k
			ans += rem * y
			ans += le // k * x
		curr = ind[i]
	le = n - 1 - ind[-1]
	mx = 0
	for j in range(ind[-1] + 1, n):
		mx = max(mx, l[j])
	if lol == 1:
		if mx < l[ind[-1]]:
			ans += le * y
		elif le and le < k:
			flag = 1
		elif le:
			ans += (le - k) * y + x
	elif le and le < k:
		if mx < l[ind[-1]]:
			ans += le * y
		else:
			flag = 1
	else:
		rem = le % k
		ans += rem * y
		ans += le // k * x
	if flag:
		print(-1)
	else:
		print(ans)


def kill(left, a, right, x, k, y):
	g = len(a)
	if g < k:
		if max(a) > max(left, right):
			print(-1)
			exit(0)
	if x < y * k:
		return g // k * x + g % k * y
	elif max(a) > max(left, right):
		return x + (g - k) * y
	else:
		return g * y

def main():
	(n, m) = map(int, input().split(' '))
	(x, k, y) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	i = 0
	j = 0
	g = 0
	M = 0
	while i < n and j < m:
		if a[i] == b[j]:
			if g > 0:
				M += kill(b[j - 1] if j > 0 else 0, a[i - g:i], b[j], x, k, y)
				g = 0
			i += 1
			j += 1
		else:
			i += 1
			g += 1
	if i == n and j < m:
		print(-1)
		return
	g += n - i
	if g > 0:
		M += kill(b[j - 1] if j > 0 else 0, a[n - g:n], b[j] if j < m else 0, x, k, y)
	print(M)
main()


mod = 1000000007
eps = 10 ** (-9)

def main():
	import sys
	input = sys.stdin.readline

	class SegmentTree:

		def __init__(self, A, initialize=True, segfunc=max, ident=-2000000000):
			self.N = len(A)
			self.LV = (self.N - 1).bit_length()
			self.N0 = 1 << self.LV
			self.segfunc = segfunc
			self.ident = ident
			if initialize:
				self.data = [self.ident] * self.N0 + A + [self.ident] * (self.N0 - self.N)
				for i in range(self.N0 - 1, 0, -1):
					self.data[i] = segfunc(self.data[i * 2], self.data[i * 2 + 1])
			else:
				self.data = [self.ident] * (self.N0 * 2)

		def update(self, i, x):
			i += self.N0 - 1
			self.data[i] = x
			for _ in range(self.LV):
				i >>= 1
				self.data[i] = self.segfunc(self.data[i * 2], self.data[i * 2 + 1])

		def query(self, l, r):
			l += self.N0 - 1
			r += self.N0 - 1
			ret_l = self.ident
			ret_r = self.ident
			while l < r:
				if l & 1:
					ret_l = self.segfunc(ret_l, self.data[l])
					l += 1
				if r & 1:
					ret_r = self.segfunc(self.data[r - 1], ret_r)
					r -= 1
				l >>= 1
				r >>= 1
			return self.segfunc(ret_l, ret_r)
	(N, M) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	idx = {a: i for (i, a) in enumerate(A)}
	i_list = [0]
	for b in B:
		i_list.append(idx[b] + 1)
	i_list.append(N + 1)
	for i in range(M + 1):
		if i_list[i] > i_list[i + 1]:
			print(-1)
			exit()
	ST = SegmentTree(A)
	ans = 0
	for j in range(M + 1):
		i1 = i_list[j]
		i2 = i_list[j + 1]
		L = i2 - i1 - 1
		if L == 0:
			continue
		ma = 0
		if i1 > 0:
			ma = max(ma, A[i1 - 1])
		if i2 <= N:
			ma = max(ma, A[i2 - 1])
		if ma > ST.query(i1 + 1, i2):
			cost = min(y * L, y * (L % k) + x * (L // k))
		else:
			if L < k:
				print(-1)
				exit()
			cost = min(y * (L % k) + x * (L // k), y * (L - k) + x)
		ans += cost
	print(ans)
main()


production = True
import sys, math, collections

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()[:-1]
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = list(next_line)
		elif input_format == 4:
			formatted_input = list(map(int, list(next_line)))
		elif input_format == 5:
			formatted_input = next_line.split()
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 2:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)

def mapl(iterable, format=0):
	if format == 0:
		return list(map(int, iterable))
	elif format == 1:
		return list(map(str, iterable))
	elif format == 2:
		return list(map(list, iterable))

def uu(r, k, p):
	log('uu', r, k, p)
	l = len(r)
	q = collections.deque([(0, 0)])
	s = []
	dp = dict()
	c = 0
	while q:
		c += 1
		(n, w) = q.popleft()
		if n in dp:
			if p:
				if dp[n] >= w:
					continue
			elif dp[n] <= w:
				continue
		dp[n] = w
		if n > l:
			continue
		h = n
		for i in range(n, l):
			if r[i]:
				h = i
				break
		else:
			if p:
				w += (l - n) // k
			s.append(w)
			continue
		b = h - n
		if p:
			nw = w + b // k
		else:
			nw = w
		q.append((h + k, nw + 1))
		for i in range(b):
			if p:
				nw = w + (b - i) // k
			else:
				nw = w
			q.append((h + k - (i + 1), w + 1))
	log('dp', dp)
	log('s', s)
	log('c', c)
	if s:
		return ter(p, max(s), min(s))
	else:
		return -1

def ff(l, o, x, k, y):
	f = k * y < x
	m = max(l)
	n = len(l)
	if f:
		log('beserk p', x, k, y)
		if o > m:
			return y * n
		if n < k:
			return -1
		return x + y * (n - k)
	else:
		if not n % k:
			return n // k * x
		p = 1
	r = [int(i > o) for i in l]
	t = uu(r, k, p)
	if t == -1:
		return -1
	b = n - t * k
	log(l, o, t, b, p)
	log(x, t, y, b)
	return x * t + y * b

def solve():
	(n, m) = input(1)
	(x, k, y) = input(1)
	a = input(1)
	b = input(1)
	q = 0
	for i in a:
		if i == b[q]:
			q += 1
		if q == m:
			break
	else:
		out(-1)
		return
	g = set(b)
	r = []
	c = []
	s = 0
	for (i, j) in enu(a):
		if j not in g:
			if i > 0 and (not c):
				s = a[i - 1]
			c.append(j)
		elif c:
			s = max(s, j)
			r.append((c, s))
			c = []
			s = 0
	if c:
		r.append((c, s))
	log(r)
	t = 0
	for (i, j) in r:
		d = ff(i, j, x, k, y)
		if d == -1:
			out(-1)
			return
		log('d', d)
		t += d
	out(t)
	return
solve()


(la, z) = map(int, input().split())
(cost1, range, cost2) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
b.append(0)
maxi = 0
(add, j, i) = (0, 0, 0)
rama = []
while True:
	if j == la:
		break
	if a[j] == b[i]:
		rama.append([add, maxi])
		i += 1
		j += 1
		(maxi, add) = (0, 0)
	else:
		add += 1
		maxi = max(maxi, a[j])
		j += 1
rama.append([add, maxi])
b = [0] + b
(cost, flag) = (0, 0)
if i != z or j != la:
	print(-1)
elif i == z and j == la and (len(rama) == 0):
	print(0)
elif cost1 <= cost2 * range:
	i = 1
	while i < z + 2:
		f = b[i]
		e = b[i - 1]
		maxu = max(f, e)
		maxi = max(maxu, rama[i - 1][1])
		c = rama[i - 1][0]
		if range <= c:
			cost += c // range * cost1 + c % range * cost2
		elif maxi == maxu:
			cost += c % range * cost2
		else:
			flag = -1
			break
		i += 1
	if flag == -1:
		print(-1)
	else:
		print(cost)
else:
	i = 1
	while i < z + 2:
		f = b[i]
		e = b[i - 1]
		maxu = max(f, e)
		maxi = max(maxu, rama[i - 1][1])
		c = rama[i - 1][0]
		if range <= c:
			if maxi == maxu:
				cost += c * cost2
			else:
				cost += cost1 + (c - range) * cost2
		elif maxi == maxu:
			cost += c * cost2
		else:
			flag = -1
			break
		i += 1
	if flag == -1:
		print(-1)
	else:
		print(cost)


import math
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a = [0] + a + [0]
b = [0] + b + [0]
j = 0
max_int = 0
max_outside = True
counter = 0
abcoincide = 0
mana = 0
unlucky = False
for i in range(0, len(a)):
	if a[i] == b[j]:
		abcoincide += 1
		if counter != 0:
			if a[i] > max_int:
				max_outside = True
			if x / k < y:
				if not max_outside and math.floor(counter / k) == 0:
					unlucky = True
				else:
					mana += math.floor(counter / k) * x + (counter - math.floor(counter / k) * k) * y
			elif not max_outside and math.floor(counter / k) == 0:
				unlucky = True
			elif not max_outside:
				mana += x + (counter - k) * y
			else:
				mana += y * counter
		max_outside = True
		max_int = a[i]
		counter = 0
		j += 1
	else:
		counter += 1
		if a[i] > max_int:
			max_outside = False
			max_int = a[i]
if unlucky or abcoincide != len(b):
	print(-1)
else:
	print(mana)


def get_ints():
	return map(int, input().split())

def main():
	(n, m) = get_ints()
	(x, k, y) = get_ints()
	a = list(get_ints())
	b = list(get_ints())

	def compute(l, r):
		cnt = r - l - 1
		if cnt == 0:
			return 0
		s = a[l + 1:r]
		maks = max((a[z] if z >= 0 and z < n else 0 for z in [l, r]))
		need_x = maks < max(s)
		res = 0
		if need_x:
			if cnt < k:
				return -1
			else:
				cnt -= k
				res += x
		if x < y * k:
			res += x * (cnt // k) + y * (cnt % k)
		else:
			res += cnt * y
		return res
	apos = {a[i]: i for i in range(n)}
	bpos = [apos.get(e, n) for e in b]
	if sorted(bpos) != bpos:
		return -1
	bpos += [n, -1]
	ans = 0
	for i in range(m + 1):
		res = compute(bpos[i - 1], bpos[i])
		if res < 0:
			return -1
		ans += res
	return ans
print(main())


import math
(n, m) = [int(i) for i in input().split()]
(x, k, y) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
start = 0
if m >= n:
	if m > n:
		print(-1)
	if m == n:
		if a == b:
			print(0)
		else:
			print(-1)
else:
	flag = 0
	points = []
	for i in range(n):
		if a[i] == b[start]:
			points.append(i)
			start += 1
			if start >= m:
				flag = 1
				start = m - 1
	if len(points) != m:
		print(-1)
	else:
		if points[0] != 0:
			points.insert(0, -1)
		if points[-1] != n - 1:
			points.append(n)
		costs = [0] * n
		if flag == 0:
			print(-1)
		g_mi = flag1 = 0
		for i in range(len(points) - 1):
			g_mi = flag1 = 0
			if points[i + 1] - points[i] == 1:
				continue
			else:
				for j in range(points[i] + 1, points[i + 1]):
					g_mi = max(g_mi, a[j])
				dist = points[i + 1] - 1 - (points[i] + 1) + 1
				if x <= k * y:
					rem = dist % k
					quo = dist // k
					pend = -1
					ans = quo * x + rem * y
					if quo == 0:
						pend = g_mi
					if points[i] != -1 and points[i + 1] != n:
						if pend > a[points[i]] and pend > a[points[i + 1]]:
							flag1 = 1
							break
					elif points[i] == -1:
						if pend > a[points[i + 1]]:
							flag1 = 1
							break
					elif points[i + 1] == n:
						if pend > a[points[i]]:
							flag1 = 1
							break
				else:
					pend = g_mi
					t1 = t2 = pend - 1
					if points[i] != -1:
						t1 = a[points[i]]
					if points[i + 1] != n:
						t2 = a[points[i + 1]]
					if pend > t1 and pend > t2:
						if dist >= k:
							ans = x + (dist - k) * y
						else:
							flag1 = 1
							break
					else:
						ans = dist * y
				if flag1 == 1:
					break
				costs[i] = ans
		if flag1 == 1:
			print(-1)
		else:
			print(sum(costs))


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [int(i) for i in input().split() if i != '\n']
b = [int(i) for i in input().split() if i != '\n']
(count, ind, maxa) = (0, 0, 0)
(store, prefmax) = ([], [])
for i in range(len(a)):
	try:
		if a[i] == b[ind]:
			count += 1
			store.append([a[i], i])
			prefmax.append(max(maxa, a[i]))
			maxa = a[i]
			ind += 1
		else:
			maxa = max(maxa, a[i])
			prefmax.append(maxa)
	except:
		maxa = max(maxa, a[i])
		prefmax.append(maxa)
		pass
if b[-1] != a[-1]:
	store.append([a[-1] - 1, n])
	prefmax.append(maxa)
ok = 0
if b[0] != a[0]:
	store.insert(0, [a[0], -1])
	prefmax.insert(0, a[0])
	ok = 1
if count != m:
	print(-1)
	exit()
else:
	ans = 0
	optimum = 0
	if x > y * k:
		optimum = 1
	for i in range(1, len(store)):
		diff = store[i][1] - store[i - 1][1] - 1
		if prefmax[max(0, store[i][1]) + ok] > max(store[i][0], store[i - 1][0]):
			if diff < k and diff > 0:
				print(-1)
				exit()
			elif optimum:
				ans += (diff - k) * y + x
			else:
				ans += diff // k * x + diff % k * y
		elif optimum:
			ans += diff * y
		else:
			ans += diff // k * x + diff % k * y
	print(ans)


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def func(mx, l, r, x, y, k, a, n, b):
	if l == 0 and a[0] != b[0]:
		ll = r - l
	elif r == n - 1:
		ll = r - l
		a[r] = -99
	else:
		ll = r - l - 1
	if ll < k:
		if mx > a[l] and mx > a[r]:
			return -1
		else:
			return y * ll
	elif x > y * k:
		if mx > a[l] and mx > a[r]:
			return x + y * (ll - k)
		else:
			return y * ll
	else:
		return x * (ll // k) + y * (ll % k)

def solve():
	(n, m) = IP()
	(x, k, y) = IP()
	a = L()
	b = L()
	mana = 0
	(j, last) = (0, 0)
	for i in range(m):
		mx = -2 * 10 ** 5
		while j < n and a[j] != b[i]:
			mx = max(mx, a[j])
			j += 1
		if j == n:
			P(-1)
			return
		if j - last - 1 > 0:
			cnt = func(mx, last, j, x, y, k, a, n, b)
			if cnt == -1:
				P(-1)
				return
			else:
				mana += cnt
		last = j
	if a[-1] != b[-1]:
		cnt = func(max(a[last + 1:]), last, n - 1, x, y, k, a, n, b)
		if cnt == -1:
			P(-1)
			return
		else:
			mana += cnt
	P(mana)
t = 1
for i in range(t):
	solve()


def check(l, r, num):
	if l == -1:
		if a[r] > num:
			return True
		return False
	if r == n:
		if a[l] > num:
			return True
		return False
	if a[l] > num or a[r] > num:
		return True
	return False

def know(l, r):
	if r - l == 1:
		return [True, 0]
	maximum = max(a[l + 1:r])
	if r - l - 1 < k:
		if not check(l, r, maximum):
			return [False, 0]
		return [True, y * (r - l - 1)]
	answer = 0
	length = r - l - 1
	answer += length % k * y
	length -= length % k
	if y * k < x:
		if not check(l, r, maximum):
			answer += x
			length -= k
		answer += length * y
	else:
		answer += length // k * x
	return [True, answer]
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
j = 0
ans = 0
pos = []
while i < m and j < n:
	if b[i] != a[j]:
		j += 1
	else:
		i += 1
		pos.append(j)
		j += 1
if j == n and i != m:
	print(-1)
else:
	pos.insert(0, -1)
	pos.append(n)
	flag = True
	for i in range(1, len(pos)):
		arr = know(pos[i - 1], pos[i])
		if arr[0] == False:
			flag = False
		else:
			ans += arr[1]
	if flag:
		print(ans)
	else:
		print(-1)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def des(l, r, mx):
	if r - l < k and (l == 0 or aa[l - 1] < mx) and (r == n or aa[r] < mx):
		return -1
	if x > k * y:
		if l != 0 and aa[l - 1] > mx or (r != n and aa[r]) > mx:
			return y * (r - l)
		return x + (r - l - k) * y
	(cnt, rem) = divmod(r - l, k)
	return cnt * x + rem * y

def solve():
	ans = 0
	pi = i = 0
	for b in bb:
		mx = 0
		if i >= n:
			return -1
		while i < n and aa[i] != b:
			mx = max(mx, aa[i])
			i += 1
		if i > pi:
			mana = des(pi, i, mx)
			if mana == -1:
				return -1
			ans += mana
		i += 1
		pi = i
	if n > pi:
		mx = max(aa[pi:])
		mana = des(pi, n, mx)
		if mana == -1:
			return -1
		ans += mana
	return ans
(n, m) = MI()
(x, k, y) = MI()
aa = LI()
bb = LI()
print(solve())


import sys
input = sys.stdin.readline
(N, M) = map(int, input().split())
(a, k, b) = map(int, input().split())
X = [0] + list(map(int, input().split())) + [0]
Y = [0] + list(map(int, input().split())) + [0]
j = 0
tmp = []
S = []
for i in range(N + 2):
	tmp.append(X[i])
	if Y[j] == X[i]:
		if len(tmp) > 2:
			S.append(tmp)
		j += 1
		tmp = [X[i]]
	else:
		pass
if j != M + 2:
	print(-1)
	sys.exit()
R = 0
for l in S:
	mx = max(l[1:-1])
	lc = len(l) - 2
	if max(l[0], l[-1]) > mx:
		if b * k > a:
			R += a * (lc // k) + b * (lc % k)
		else:
			R += lc * b
	else:
		if lc < k:
			print(-1)
			sys.exit()
		if b * k > a:
			R += a * (lc // k) + b * (lc % k)
		else:
			R += (lc - k) * b + a
print(R)


import sys
input = sys.stdin.buffer.readline

def compress(string):
	string.append(-1)
	n = len(string)
	(begin, end, cnt) = (0, 1, 1)
	ans = []
	while end < n:
		if string[begin] == string[end]:
			(end, cnt) = (end + 1, cnt + 1)
		else:
			ans.append((string[begin], cnt))
			(begin, end, cnt) = (end, end + 1, 1)
	return ans
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
INF = 10 ** 18
delete = [1] * n
ib = 0
for ia in range(n):
	if ib == m:
		continue
	if a[ia] == b[ib]:
		ib += 1
		delete[ia] = 0
if ib != m:
	print(-1)
	exit()
comp = compress(delete)
ans = 0
ind = 0
for (val, cnt) in comp:
	if val == 0:
		pass
	else:
		(l_val, r_val) = (-1, -1)
		if ind - 1 >= 0:
			l_val = a[ind - 1]
		if ind + cnt < n:
			r_val = a[ind + cnt]
		max_ = max(l_val, r_val)
		min_cost = INF
		if max(a[ind:ind + cnt]) < max_:
			min_cost = min(min_cost, y * cnt)
		if cnt >= k:
			(div, rem) = divmod(cnt, k)
			min_cost = min(min_cost, div * x + rem * y)
			min_cost = min(min_cost, x + (cnt - k) * y)
		ans += min_cost
	ind += cnt
if ans >= INF:
	print(-1)
else:
	print(ans)


def solve():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	sA = set(A)
	sB = set(B)
	if not sA >= sB:
		print(-1)
		return
	P = [s in sB for s in A]
	if [a for (a, s) in zip(A, P) if s] != B:
		print(-1)
		return
	ans = 0
	p = 0
	prev = 0
	while p < n:
		pstart = p
		pmax = 0
		while p < n and (not P[p]):
			pmax = max(pmax, A[p])
			p += 1
		num = p - pstart
		if p < n:
			prev = max(prev, A[p])
		if num < k:
			if pmax > prev:
				print(-1)
				return
			else:
				ans += y * num
		else:
			ans += y * (num % k)
			num -= num % k
			option1 = x * (num // k)
			option2 = y * (num - k)
			if pmax > prev:
				option2 += x
			else:
				option2 += y * k
			ans += min(option1, option2)
		while p < n and P[p]:
			prev = A[p]
			p += 1
	print(ans)
solve()


(N, M) = map(int, input().split())
(X, K, Y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AB = [0 for _ in range(len(B) + 2)]
AS = AB.copy()
AS[0] = 0
AB[0] = -1
i = 0
j = 0
l = 0
li = 0
result = 0
while j < len(B):
	while i < len(A):
		if li < A[i]:
			l = i
			li = A[i]
		if A[i] == B[j]:
			break
		i += 1
	if i >= len(A):
		result = -1
		break
	AB[j + 1] = i
	AS[j + 1] = l
	l = i
	li = A[i]
	j += 1
for k in range(i, len(A)):
	if li < A[k]:
		l = k
		li = A[k]
AB[-1] = len(A)
AS[-1] = l
if X / K < Y:
	use_f = True
else:
	use_f = False
if result != -1:
	for i in range(1, len(B) + 2):
		if AB[i] == AS[i] or AB[i - 1] == AS[i]:
			if use_f:
				result += (AB[i] - AB[i - 1] - 1) // K * X + (AB[i] - AB[i - 1] - 1) % K * Y
			else:
				result += (AB[i] - AB[i - 1] - 1) * Y
		elif 0 < AB[i] - AB[i - 1] - 1 < K:
			result = -1
			break
		elif use_f:
			result += (AB[i] - AB[i - 1] - 1) // K * X + (AB[i] - AB[i - 1] - 1) % K * Y
		else:
			result += X + (AB[i] - AB[i - 1] - 1 - K) * Y
print(result)


from sys import stdin
input = stdin.buffer.readline
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
(*a,) = map(int, input().split())
a = a + [0]
(*b,) = map(int, input().split())
ans = p = i = j = 0
while i < n and j < m:
	while a[i] != b[j]:
		i += 1
		if i == n:
			break
	cnt = 0
	for t in range(p, i):
		if a[t] > max(a[i], a[p - 1]):
			cnt += 1
	if k * y < x:
		if i - p < k and cnt:
			exit(print(-1))
		if cnt:
			ans += x + (i - p - k) * y
		else:
			ans += (i - p) * y
	else:
		if i - p < k and cnt:
			exit(print(-1))
		ans += (i - p) // k * x + (i - p) % k * y
	i += 1
	p = i
	j += 1
if j < m:
	print(-1)
else:
	if i < n:
		cnt = 0
		for t in range(p, n):
			if a[t] > max(a[n], a[p - 1]):
				cnt += 1
		if k * y < x:
			if n - p < k and cnt:
				exit(print(-1))
			if cnt:
				ans += x + (n - p - k) * y
			else:
				ans += (n - p) * y
		else:
			if n - p < k and cnt:
				exit(print(-1))
			ans += (n - p) // k * x + (n - p) % k * y
	print(ans)


def main():
	(n, m) = [int(i) for i in input().split()]
	(x, k, y) = [int(i) for i in input().split()]
	a = [0] + [int(i) for i in input().split()] + [0]
	base = 0
	num = 0
	flag = False
	total = 0
	res = []
	for (i, elem) in enumerate(input().split()):
		num = base
		while int(elem) != a[num]:
			num += 1
			if num == n + 1:
				break
		if num == n + 1:
			print(-1)
			return
		res.append((base, num))
		base = num
	res.append((base, n + 1))
	for elem in res:
		flag = False
		if elem[1] - elem[0] == 1:
			continue
		if elem[1] - elem[0] - 1 < k:
			for j in a[elem[0]:elem[1] + 1]:
				if j > a[elem[0]] and j > a[elem[1]]:
					print(-1)
					return
			total += y * (elem[1] - elem[0] - 1)
		else:
			for j in a[elem[0]:elem[1] + 1]:
				if j > a[elem[0]] and j > a[elem[1]]:
					flag = True
					break
			if k * y >= x:
				total += (elem[1] - elem[0] - 1) // k * x + (elem[1] - elem[0] - 1) % k * y
			elif flag:
				total += (elem[1] - elem[0] - 1 - k) * y + x
			else:
				total += (elem[1] - elem[0] - 1) * y
	print(total)
main()


import sys
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if k * y < x:
	ycheap = 1
else:
	ycheap = 0
pointer = 0
ans = 0
for i in range(m):
	deletenum = 0
	badnum = 0
	if pointer == n:
		print(-1)
		sys.exit()
	start = pointer
	deletnum = 0
	while a[pointer] != b[i]:
		if i == 0 and b[0] < a[pointer] or (i > 0 and b[i] < a[pointer] and (b[i - 1] < a[pointer])):
			badnum = 1
		pointer += 1
		deletenum += 1
		if pointer == n:
			print(-1)
			sys.exit()
	pointer += 1
	if badnum == 1 and deletenum < k:
		print(-1)
		sys.exit()
	if ycheap == 1:
		if badnum == 1:
			ans += x
			ans += y * (deletenum - k)
		else:
			ans += y * deletenum
	else:
		ans += y * (deletenum % k)
		ans += x * (deletenum // k)
badnum = 0
for i in range(pointer, n):
	if a[i] > b[-1]:
		badnum = 1
deletenum = n - pointer
if badnum == 1 and deletenum < k:
	print(-1)
	sys.exit()
if ycheap == 1:
	if badnum == 1:
		ans += x
		ans += y * (deletenum - k)
	else:
		ans += y * deletenum
else:
	ans += y * (deletenum % k)
	ans += x * (deletenum // k)
print(ans)


def update(a, b):
	global res
	if a > b:
		return True
	l = b - a + 1
	apply_x = False
	mx = max(lst1[a:b + 1])
	if a - 1 >= 0 and lst1[a - 1] > mx:
		apply_x = True
	if b + 1 <= n - 1 and lst1[b + 1] > mx:
		apply_x = True
	if not apply_x and l < k:
		return False
	rem = l % k
	res += rem * y
	l -= rem
	if x <= y * k:
		res += l // k * x
	elif apply_x:
		res += l * y
	else:
		res += (l - k) * y + x
	return True

def solve():
	global res
	(i, j) = (0, 0)
	start = 0
	while i < m:
		while j < n and lst1[j] != lst2[i]:
			j += 1
		if j == n:
			return -1
		if not update(start, j - 1):
			return -1
		j += 1
		start = j
		i += 1
	if not update(start, n - 1):
		return -1
	return res
res = 0
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
lst1 = list(map(int, input().split()))
lst2 = list(map(int, input().split()))
print(solve())


from sys import stdin, stdout, exit
stdin.readline()
(x, k, y) = [int(i) for i in stdin.readline().split(' ') if i]
a = [int(i) for i in stdin.readline().split(' ') if i]
b = [int(i) for i in stdin.readline().split(' ') if i]
a[:0] = [0]
a.append(0)
b.append(0)
if x >= y * k:

	def calc(a):
		n = len(a) - 2
		if max(a) == max(a[0], a[-1]):
			return n * y
		if n < k:
			stdout.write('-1\n')
			return
		return (n - k) * y + x
else:

	def calc(a):
		n = len(a) - 2
		if n < k:
			if max(a) == max(a[0], a[-1]):
				return n * y
			stdout.write('-1\n')
			return
		return n // k * x + n % k * y
n = 0
i = 0
for j in b:
	t = i + 1
	while t < len(a):
		if a[t] == j:
			break
		t += 1
	else:
		stdout.write('-1\n')
		return
	if t > i + 1:
		n += calc(a[i:t + 1])
	i = t
stdout.write(f'{n}\n')


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
j = 0
for i in range(n):
	if j >= m:
		break
	if a[i] == b[j]:
		c.append(0)
		j += 1
	else:
		c.append(1)
if j != m:
	print(-1)
	return
while len(c) != n:
	c.append(1)
back_l = -1
back_r = -1
ans = 0
while True:
	l = back_l
	r = back_r
	for i in range(back_r + 1, n):
		if c[i] == 1:
			l = i
			r = i
			break
	M = 0
	for i in range(r, n):
		M = max(M, a[i])
		if i + 1 >= n:
			r = i
		elif c[i + 1] == 0:
			r = i
			break
		else:
			r = i
	if l == back_l or r == back_r:
		break
	N = r - l + 1
	left = -1
	right = -1
	if l > 0:
		left = a[l - 1]
	if r < n - 1:
		right = a[r + 1]
	if N < k and M > left and (M > right):
		print(-1)
		return
	if x / k <= y:
		ans += N // k * x
		N -= N // k * k
		ans += y * N
	elif M < left or M < right:
		ans += y * N
	else:
		ans += x
		N -= k
		ans += y * N
	back_l = l
	back_r = r
print(ans)


import os, io
from sys import stdout
import collections
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def powerOfK(k, max):
	if k == 1:
		return [1]
	if k == -1:
		return [-1, 1]
	result = []
	n = 1
	while n <= max:
		result.append(n)
		n *= k
	return result

def divisors(n):
	i = 1
	result = []
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				result.append(i)
			else:
				result.append(i)
				result.append(n / i)
		i += 1
	return result

def distance(xa, ya, xb, yb):
	return ((ya - yb) ** 2 + (xa - xb) ** 2) ** 0.5

def digitsSum(n):
	if n == 0:
		return 0
	r = 0
	while n > 0:
		r += n % 10
		n //= 10
	return r

def isValid(i, j, n, m):
	return i >= 0 and i < n and (j >= 0) and (j < m)

def print_grid(grid):
	for line in grid:
		print(' '.join(map(str, line)))

def kadane(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def prefixSum(arr):
	for i in range(1, len(arr)):
		arr[i] = arr[i] + arr[i - 1]
	return arr

def ceil(n, d):
	if n % d == 0:
		return n // d
	else:
		return n // d + 1

def _abs(a, b):
	return int(abs(a - b))

def evenodd(l):
	even = [e for e in l if e & 1 == 0]
	odd = [e for e in l if e & 1]
	return (even, odd)
from collections import Counter
(n, m) = list(map(int, input().split()))
(x, k, y) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
cx = x / k
cy = y
betterKillRange = cx <= cy
import math
if len(b) > len(a):
	print(-1)
	exit()
if len(b) == len(a):
	if a == b:
		print(0)
	else:
		print(-1)
	exit()
(i, j) = (0, 0)
index = 0
result = 0
while i < len(a):
	if index >= len(b):
		j = len(a)
	else:
		while j < len(a) and a[j] != b[index]:
			j += 1
	if j != i:
		radd = 0
		elementsToDelete = j - i
		if elementsToDelete % k == 0:
			radd = x * (elementsToDelete // k)
		elif elementsToDelete > k:
			radd = elementsToDelete // k * x + elementsToDelete % k * y
		elif elementsToDelete < k:
			if i == 0 and j == len(a):
				print(-1)
				exit()
			elif i == 0:
				if max(a[i:j]) > a[j]:
					print(-1)
					exit()
				radd = y * elementsToDelete
			elif j == len(a):
				if max(a[i:j]) > a[i - 1]:
					print(-1)
					exit()
				radd = y * elementsToDelete
			else:
				if max(a[i:j]) > max(a[i - 1], a[j]):
					print(-1)
					exit()
				radd = y * elementsToDelete
		radd2 = 0
		if i == 0 and j == len(a):
			radd2 = math.inf
		elif i == 0:
			if max(a[i:j]) > a[j]:
				if elementsToDelete < k:
					radd2 = math.inf
				else:
					remaining = elementsToDelete - k
					radd2 = x
					radd2 += remaining * y
			else:
				radd2 = y * elementsToDelete
		elif j == len(a):
			if max(a[i:j]) > a[i - 1]:
				if elementsToDelete < k:
					radd2 = math.inf
				else:
					remaining = elementsToDelete - k
					radd2 = x
					radd2 += remaining * y
			else:
				radd2 = y * elementsToDelete
		elif max(a[i:j]) > max(a[i - 1], a[j]):
			if elementsToDelete < k:
				radd2 = math.inf
			else:
				remaining = elementsToDelete - k
				radd2 = x
				radd2 += remaining * y
		else:
			radd2 = y * elementsToDelete
		result += min(radd, radd2)
	i = j + 1
	j += 1
	index += 1
print(result)


def get_val(x, k, y, left_val, right_val, arr):
	(x, y) = (y, x)
	if not arr:
		return 0
	if len(arr) < k:
		if max(arr) > max(left_val, right_val):
			return -1
		return len(arr) * x
	if y < x * k:
		n = len(arr)
		res = 0
		while n >= k:
			n -= k
			res += y
		res += n * x
		return res
	elif max(arr) < max(left_val, right_val):
		return len(arr) * x
	else:
		return (len(arr) - k) * x + y

def solve(x, k, y, a, b):

	def check(a, b):
		j = 0
		i = 0
		while i < len(a) and j < len(b):
			if a[i] != b[j]:
				i += 1
			else:
				i += 1
				j += 1
		return j == len(b)
	if not check(a, b):
		return -1
	j = 0
	left_val = -1
	arr = []
	res = 0
	for num in a:
		if j == len(b) or num != b[j]:
			arr.append(num)
		else:
			val = get_val(x, k, y, left_val, num, arr)
			if val == -1:
				return -1
			res += val
			arr = []
			left_val = num
			j += 1
	if arr:
		val = get_val(x, k, y, left_val, -1, arr)
		if val == -1:
			return -1
		res += val
	return res
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
print(solve(x, k, y, a, b))


from sys import exit
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0] * (n + 1)
for (i, val) in enumerate(a):
	pos[val] = i

def process(l, r):
	ans = 0
	u = a[l] if l >= 0 else 0
	v = a[r] if r < n else 0
	cnt_big = 0
	mx = max(u, v)
	for i in range(l + 1, r):
		if mx < a[i]:
			cnt_big += 1
	dist = r - l - 1
	if cnt_big > 0 and dist < k:
		print('-1')
		exit(0)
	if y * k < x:
		if cnt_big > 0:
			dist -= k
			ans += x
		ans += dist * y
	else:
		ans = dist // k * x + dist % k * y
	return ans
ans = process(-1, pos[b[0]]) + process(pos[b[-1]], n)
for (u, v) in zip(b, b[1:]):
	if pos[u] > pos[v]:
		print('-1')
		exit(0)
	ans += process(pos[u], pos[v])
print(ans)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
if n == m:
	if a == b:
		print(0)
	else:
		print(-1)
	exit()
now = 0
l = [-1]
for i in range(n):
	if b[now] == a[i]:
		l.append(i)
		now += 1
		if now == m:
			break
l.append(n)
if now != m:
	print(-1)
	exit()
ans = 0
for q in range(1, len(l)):
	w = l[q] - l[q - 1] - 1
	if w <= 0:
		continue
	if w < k:
		if l[q] < n:
			c1 = a[l[q]]
		else:
			c1 = 0
		if l[q - 1] == -1:
			c2 = 0
		else:
			c2 = a[l[q - 1]]
		if max(a[max(0, l[q - 1]):l[q]]) > max(c1, c2):
			print(-1)
			exit()
		else:
			ans += y * w
	elif x <= y * k:
		ans += x * (w // k) + y * (w % k)
	else:
		if l[q] < n:
			c1 = a[l[q]]
		else:
			c1 = 0
		if l[q - 1] == -1:
			c2 = 0
		else:
			c2 = a[l[q - 1]]
		if max(a[max(0, l[q - 1]):l[q]]) > max(c1, c2):
			ans += x + y * (w - k)
		else:
			ans += y * w
print(ans)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
numbers = []
ia = 0
bad = False
for item in b:
	while ia < n and item != a[ia]:
		ia += 1
	if ia < n:
		numbers.append(ia + 1)
	else:
		bad = True
		break
if bad:
	print(-1)
else:
	a.append(-1)
	a.insert(0, -1)
	numbers.append(n + 1)
	numbers.insert(0, 0)
	ans = 0
	hard_mode = False
	if y * k < x:
		hard_mode = True
	for i in range(m - 1 + 2):
		if numbers[i + 1] - numbers[i] - 1 > 0:
			if not hard_mode:
				if 0 < numbers[i + 1] - numbers[i] - 1 < k:
					if max(a[numbers[i + 1]], a[numbers[i]]) < max(a[numbers[i] + 1:numbers[i + 1]]):
						print(-1)
						bad = True
						break
					else:
						ans += y * (numbers[i + 1] - numbers[i] - 1)
				else:
					ans += x * ((numbers[i + 1] - numbers[i] - 1) // k) + y * ((numbers[i + 1] - numbers[i] - 1) % k)
			elif max(a[numbers[i + 1]], a[numbers[i]]) > max(a[numbers[i] + 1:numbers[i + 1]]):
				ans += y * (numbers[i + 1] - numbers[i] - 1)
			elif 0 < numbers[i + 1] - numbers[i] - 1 < k:
				print(-1)
				bad = True
				break
			else:
				ans += y * (numbers[i + 1] - numbers[i] - 1 - k) + x
	if not bad:
		print(ans)


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n
avl = AvlTree()

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
t = 0
extra = [[]]
weapon = defaultdict(list)
for i in range(n):
	if t < len(b) and a[i] == b[t]:
		t += 1
		extra.append([])
		weapon[t].append(a[i])
		weapon[t - 1].append(a[i])
	else:
		extra[-1].append(a[i])
if t != len(b):
	print(-1)
	sys.exit(0)
else:
	ans = 0
	for i in range(len(extra)):
		if len(extra[i]) == 0:
			continue
		f = 0
		f1 = 0
		if max(weapon[i]) < max(extra[i]):
			f = 1
		if len(extra[i]) % k != 0:
			f1 = 2
			if len(extra[i]) < k:
				f1 = 3
		if f == 1 and f1 == 3:
			print(-1)
			sys.exit(0)
		elif f == 0 and f1 == 0:
			ans += min(len(extra[i]) * y, len(extra[i]) * x // k)
		elif f == 1 and f1 == 2:
			l = len(extra[i])
			com = l - l % k - k
			ans += min(com * y, com * x // k) + l % k * y + x
		elif f == 0 and f1 == 3:
			ans += len(extra[i]) * y
		elif f == 0 and f1 == 2:
			l = len(extra[i])
			com = l - l % k
			ans += min(com * y, com * x // k) + l % k * y
		else:
			l = len(extra[i])
			com = l - l % k - k
			ans += min(com * y, com * x // k) + l % k * y + x
	print(ans)


from sys import stdin, stdout
import functools
import sys, os, math
(N, M) = map(int, input().split())
(X, K, Y) = map(int, input().split())
A = list(map(int, input().split()))
AS = set(A)
B0 = list(map(int, input().split()))
B = set(B0)
C = []

def calOne(i, j):
	global N, M, X, Y, K, A, AS, B, B0, C
	bs = []
	if i - 1 >= 0:
		bs.append(A[i - 1])
	if j + 1 < N:
		bs.append(A[j + 1])
	l = j - i + 1
	(ma, mb) = (max(A[i:j + 1]), max(bs))
	if X >= K * Y:
		if mb > ma:
			return (j - i + 1) * Y
		elif j - i + 1 < K:
			return -1
		else:
			return (j - i + 1 - K) * Y + X
	elif mb > ma:
		return int(l / K) * X + l % K * Y
	elif l < K:
		return -1
	else:
		return int(l / K) * X + l % K * Y

def solve():
	global N, M, X, Y, K, A, B, C
	(i, j) = (0, 0)
	if M > N:
		return -1
	if M == N and A != B0:
		return -1
	for b in B:
		if b not in AS:
			return -1
	while i < N:
		while i < N and A[i] in B:
			i += 1
		j = i
		while j < N and A[j] not in B:
			j += 1
		if j - i > 0:
			C.append([i, j - 1])
		i = j
	ans = 0
	for c in C:
		cur = calOne(c[0], c[1])
		if cur < 0:
			return -1
		ans += cur
	return ans
print(solve())


import os
import sys, math
from io import BytesIO, IOBase
a = []

def calc(i, j, x, k, y):
	global a
	ln = j - i + 1
	usex = k * y >= x
	mxtot = 0
	n = len(a)
	for u in range(i, j + 1):
		mxtot = max(mxtot, a[u])
	if usex:
		if ln < k:
			if i == 0:
				if mxtot > a[j + 1]:
					return -1
			elif j == n - 1:
				if mxtot > a[i - 1]:
					return -1
			elif mxtot > a[i - 1] and mxtot > a[j + 1]:
				return -1
		return ln // k * x + ln % k * y
	else:
		check = False
		if i == 0:
			if mxtot > a[j + 1]:
				check = True
				if ln < k:
					return -1
		elif j == n - 1:
			if mxtot > a[i - 1]:
				check = True
				if ln < k:
					return -1
		elif mxtot > a[i - 1] and mxtot > a[j + 1]:
			check = True
			if ln < k:
				return -1
		if check:
			return (ln - k) * y + x
		else:
			return ln * y

def main():
	global a
	t = 1
	for case in range(t):
		(n, m) = list(map(int, input().split()))
		(x, k, y) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		dic = dict()
		for i in range(n):
			dic[a[i]] = i
		b = list(map(int, input().split()))
		ans = 0
		works = True
		for i in range(m - 1):
			if dic[b[i]] > dic[b[i + 1]]:
				print(-1)
				return
		if dic[b[0]] != 0:
			v = calc(0, dic[b[0]] - 1, x, k, y)
			if v == -1:
				print(-1)
				return
			ans += v
		for i in range(m - 1):
			f = dic[b[i]]
			s = dic[b[i + 1]]
			if f + 1 != s:
				v = calc(f + 1, s - 1, x, k, y)
				if v == -1:
					print(-1)
					return
				ans += v
		if dic[b[-1]] != n - 1:
			v = calc(dic[b[-1]] + 1, n - 1, x, k, y)
			if v == -1:
				print(-1)
				return
			ans += v
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dic = {i: e for (e, i) in enumerate(a)}
rest = [dic[b[i]] for i in range(m)]
check = sorted(rest)
if check != rest:
	print(-1)
	exit()
rest = [-1] + rest + [n]
b = [-1] + b + [-1]
ans = 0
for i in range(m + 1):
	(Lid, Rid) = (rest[i], rest[i + 1])
	(L, R) = (b[i], b[i + 1])
	check = -1
	for j in range(Lid + 1, Rid):
		check = max(check, a[j])
	if max(L, R) >= check:
		if x < y * k:
			q = (Rid - Lid - 1) // k
			r = (Rid - Lid - 1) % k
			ans += q * x + r * y
		else:
			ans += (Rid - Lid - 1) * y
	elif x < y * k:
		check = Rid - Lid - 1
		if check < k:
			print(-1)
			exit()
		q = (Rid - Lid - 1) // k
		r = (Rid - Lid - 1) % k
		ans += q * x + r * y
	else:
		check = Rid - Lid - 1
		if check < k:
			print(-1)
			exit()
		else:
			ans += (check - k) * y + x
print(ans)


import sys

def solve(A):
	if len(A) <= 2:
		return (True, 0)
	if len(A) < k + 2:
		if max(A) != A[0] and max(A) != A[-1]:
			return (False, 0)
		else:
			return (True, y * (len(A) - 2))
	elif y * k < x:
		if max(A) == A[0] or max(A) == A[-1]:
			return (True, (len(A) - 2) * y)
		else:
			d = len(A) - 2
			return (True, x + (d - k) * y)
	else:
		d = len(A) - 2
		return (True, d // k * x + (d - d // k * k) * y)
(n, m) = [int(c) for c in input().split()]
(x, k, y) = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
b = [int(c) for c in input().split()]
a.insert(0, -1)
a.append(-1)
b.append(-1)
j = 0
A = []
ans = 0
aoo = False
for i in range(n + 2):
	if a[i] != b[j]:
		A.append(a[i])
	else:
		A.append(a[i])
		j += 1
		(pp, aa) = solve(A)
		if pp:
			ans += aa
		else:
			aoo = True
			break
		A = [a[i]]
if j != len(b) or aoo:
	print('-1')
else:
	print(ans)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
j = 0
found = 0
indicators = [False] * n
for i in range(m):
	while j < n and a[j] != b[i]:
		j += 1
	if j == n:
		break
	if a[j] == b[i]:
		found += 1
		indicators[j] = True
if found < m:
	print(-1)
else:
	cost = 0
	lptr = -1

	def destroy(lptr, rptr):
		global x, k, y, n
		if rptr - lptr - 1 < 1:
			return 0
		if lptr == -1:
			leftFlank = 0
		else:
			leftFlank = a[lptr]
		if rptr == n:
			rightFlank = 0
		else:
			rightFlank = a[rptr]
		if rptr - lptr - 1 < k:
			maxVal = max(a[lptr + 1:rptr])
			if maxVal < max(leftFlank, rightFlank):
				return y * (rptr - lptr - 1)
			return -1
		elif rptr - lptr - 1 == k:
			maxVal = max(a[lptr + 1:rptr])
			if maxVal < max(leftFlank, rightFlank):
				return min(y * k, x)
			return x
		else:
			maxVal = max(a[lptr + 1:rptr])
			diff = rptr - lptr - 1
			if maxVal < max(leftFlank, rightFlank):
				if x < y * k:
					if diff % k == 0:
						return diff // k * x
					else:
						return diff // k * x + diff % k * y
				return diff * y
			else:
				rem = diff % k
				if rem == 0:
					return min(x * (diff // k), (diff - k) * y + x)
				else:
					return rem * y + min(x * (diff // k), (diff - k - rem) * y + x)
	for i in range(n):
		if indicators[i]:
			val = destroy(lptr, i)
			if val == -1:
				cost = -1
				break
			cost += val
			lptr = i
			left = a[i]
			middleMax = None
	if cost != -1 and (not indicators[-1]):
		val = destroy(lptr, n)
		if val == -1:
			cost = -1
		else:
			cost += val
	print(cost)


import os, sys
from io import BytesIO, IOBase

def main():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(j, ans) = (0, 0)
	for i in range(m):
		(d, r) = (0, 0)
		while j != n and a[j] != b[i]:
			r = max(r, a[j])
			d += 1
			j += 1
		if j == n:
			return -1
		j += 1
		if not d:
			continue
		if d < k:
			if r < b[i] or (i and r < b[i - 1]):
				ans += y * d
			else:
				return -1
		else:
			ans += y * (d % k) + min(d // k * x, (d - d % k) * y)
			if not (r < b[i] or (i and r < b[i - 1])):
				ans += max(x - k * y, 0)
	if j != n:
		if n - j < k:
			if max(a[j:]) < b[-1]:
				ans += (n - j) * y
			else:
				return -1
		else:
			d = n - j
			ans += y * (d % k) + min(d // k * x, (d - d % k) * y)
			if not max(a[j:]) < b[-1]:
				ans += max(x - k * y, 0)
	return ans
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
print(main())


def process(ori, after, x, k, y):
	gap = []
	temp = []
	result = 0
	j = 0
	for i in range(len(ori)):
		if j == len(after):
			temp.append(i)
			continue
		if ori[i] != after[j]:
			temp.append(i)
		else:
			gap.append(temp[:])
			temp = []
			j += 1
	gap.append(temp)
	if j != len(after):
		return -1
	for i in range(len(gap)):
		if len(gap[i]) == 0:
			continue
		if len(gap[i]) < k:
			re = check_bon(gap, ori, i)
			if re == -1:
				return -1
			result += re
		elif len(gap[i]) % k == 0:
			if x / k <= y:
				result += len(gap[i]) / k * x
			else:
				re = check_bon(gap, ori, i)
				if re == -1:
					result += x
					result += (len(gap[i]) - k) * y
				else:
					result += re
		elif x / k > y:
			re = check_bon(gap, ori, i)
			if re != -1:
				result += re
			else:
				result += x
				result += (len(gap[i]) - k) * y
		else:
			result += len(gap[i]) // k * x
			result += len(gap[i]) % k * y
	return result

def check_bon(gap, ori, i):
	if gap[i][0] - 1 < 0 and gap[i][-1] + 1 == len(ori):
		return -1
	left = gap[i][0] - 1
	right = gap[i][-1] + 1
	temp = -1
	for j in gap[i]:
		if ori[j] > temp:
			temp = ori[j]
	if valid(left, ori):
		left = ori[left] > temp
	if valid(right, ori):
		right = ori[right] > temp
	if left == True or right == True:
		return y * len(gap[i])
	else:
		return -1

def valid(n, ori):
	if n < 0 or n == len(ori):
		return False
	return True
(n, m) = input('').split(' ')
n = int(n)
m = int(m)
(x, k, y) = input('').split(' ')
x = int(x)
k = int(k)
y = int(y)
ori = input('').split(' ')
after = input('').split(' ')
for i in range(len(ori)):
	ori[i] = int(ori[i])
for i in range(len(after)):
	after[i] = int(after[i])
if n < m:
	print('-1')
	exit()
if n == m:
	for i in range(n):
		if ori[i] != after[i]:
			print('-1')
			exit()
	print('0')
	exit()
print('{}'.format(int(process(ori, after, x, k, y))))


from collections import deque
import sys

def input():
	return sys.stdin.readline().rstrip()
DXY = [(0, -1), (1, 0), (0, 1), (-1, 0)]

def main():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	ws = list(map(int, input().split()))
	ws1 = [-1] + list(map(int, input().split())) + [-1]
	val_index = [-1] * (n + 10)
	for (i, v) in enumerate(ws):
		val_index[v] = i
	ans = 0
	for i in range(1, m + 2):
		(l, r) = (val_index[ws1[i - 1]], val_index[ws1[i]])
		if ws1[i] == -1:
			r = n
		if l > r:
			print(-1)
			return 0
		else:
			que = []
			for itr in range(l + 1, r):
				que.append(ws[itr])
			if not que:
				continue
			tmp = 0
			maxval = max(ws1[i - 1], ws1[i])
			strongest = max(que)
			l = len(que)
			if l % k != 0:
				if l > k:
					ans += y * (l % k)
					tmp += y * (l % k)
					l -= l % k
				elif strongest > maxval:
					print(-1)
					return 0
				else:
					ans += y * l
					tmp += y * l
					l = 0
			if que:
				if x - k * y > 0:
					if strongest < maxval:
						ans += y * l
						tmp += y * l
					else:
						ans += y * (l - k) + x
						tmp += y * (l - k) + x
				else:
					ans += x * (l // k)
					tmp += x * (l // k)
	print(ans)
	return 0
main()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
(n, m) = sp()
(x, k, y) = sp()
a = l()
b = l()
(i, j) = (0, 0)
index = [0]
while i < n and j < m:
	if a[i] == b[j]:
		index.append(i)
		i += 1
		j += 1
		continue
	i += 1
if j != m:
	out(-1)
	exit()
if a == b:
	out(0)
	exit()
index.append(n - 1)
answer = 0
for i in range(1, len(index)):
	arr = []
	for j in range(index[i - 1], index[i] + 1):
		arr.append(a[j])
	if len(arr) <= 1:
		continue
	mx = max(arr)
	length = len(arr) - 1
	if i == 1 or i == len(index) - 1:
		if mx == (arr[0], arr[-1])[i == 1]:
			answer += min(length * y, x * (length // k) + length % k * y)
			continue
		if k > length:
			out(-1)
			exit()
		answer += min((length - k) * y + x, x * (length // k) + length % k * y)
		continue
	if len(arr) <= 2:
		continue
	length -= 1
	if mx == arr[0] or mx == arr[-1]:
		answer += min(length * y, x * (length // k) + length % k * y)
		continue
	if k > length:
		out(-1)
		exit()
	answer += min((length - k) * y + x, x * (length // k) + length % k * y)
out(answer)


import sys
import math
import bisect
mod = 998244353
from sys import stdin
from itertools import groupby
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
(N, M) = map(int, input().split())
(a, k, b) = map(int, input().split())
X = [0] + list(map(int, input().split())) + [0]
Y = [0] + list(map(int, input().split())) + [0]
j = 0
tmp = []
S = []
for i in range(N + 2):
	tmp.append(X[i])
	if Y[j] == X[i]:
		if len(tmp) > 2:
			S.append(tmp)
		j += 1
		tmp = [X[i]]
	else:
		pass
if j != M + 2:
	print(-1)
	sys.exit()
R = 0
for l in S:
	mx = max(l[1:-1])
	lc = len(l) - 2
	if max(l[0], l[-1]) > mx:
		if b * k > a:
			R += a * (lc // k) + b * (lc % k)
		else:
			R += lc * b
	else:
		if lc < k:
			print(-1)
			sys.exit()
		if b * k > a:
			R += a * (lc // k) + b * (lc % k)
		else:
			R += (lc - k) * b + a
print(R)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
(n, m) = input_split()
(x, k, y) = input_split()
given = input_split()
target = input_split()
starget = set(target)
inverse_given = {given[i]: i for i in range(n)}
inverse_target = {target[i]: i for i in range(m)}
to_delete_inds = []
for i in range(n):
	if given[i] not in starget:
		to_delete_inds.append(i)
cant_be_done = False
last_ind = -1
for a in target:
	if a not in inverse_given:
		cant_be_done = True
		break
	elif inverse_given[a] < last_ind:
		cant_be_done = True
		break
	else:
		last_ind = inverse_given[a]
if cant_be_done:
	ans = -1
elif len(to_delete_inds) == 0:
	ans = 0
else:
	ans = 0
	all_groups = []
	current_group = [to_delete_inds[0]]
	for i in range(1, len(to_delete_inds)):
		if to_delete_inds[i] == current_group[-1] + 1:
			current_group.append(to_delete_inds[i])
		else:
			all_groups.append(current_group)
			current_group = [to_delete_inds[i]]
	all_groups.append(current_group)
	for current_group in all_groups:
		if current_group[0] == 0:
			left_max = -1
		else:
			left_max = given[current_group[0] - 1]
		if current_group[-1] == n - 1:
			right_max = -1
		else:
			right_max = given[current_group[-1] + 1]
		me = max(left_max, right_max)
		maxi = max([given[ind] for ind in current_group])
		if len(current_group) < k:
			if me > maxi:
				ans += len(current_group) * y
			else:
				wrong = True
				ans = -1
				break
		elif me > maxi:
			if x > k * y:
				ans += len(current_group) * y
			else:
				ans += len(current_group) // k * x + len(current_group) % k * y
		elif x > k * y:
			ans += x + (len(current_group) - k) * y
		else:
			ans += len(current_group) // k * x + len(current_group) % k * y
print(ans)


def subsequence(arr1, arr2, n, m):
	i = 0
	j = 0
	common = []
	while i < n and j < m:
		if arr1[i] == arr2[j]:
			common.append(i)
			j += 1
		i += 1
	if j == m:
		return common
	return []

def find(arr, start, end, x, y, k):
	stack = []
	second_use_limit = 0
	for i in range(start, end + 1):
		if not stack:
			stack.append(arr[i])
		else:
			while stack and arr[i] > stack[-1]:
				second_use_limit += 1
				stack.pop()
			if not stack or arr[i] > stack[-1]:
				stack.append(arr[i])
			elif stack and arr[i] < stack[-1]:
				second_use_limit += 1
	while stack and start - 1 >= 0 and (arr[start - 1] > stack[0]):
		stack.pop(0)
		second_use_limit += 1
	while stack and end + 1 < len(arr) and (arr[end + 1] > stack[-1]):
		stack.pop()
		second_use_limit += 1
	min_cost = float('inf')
	total = end - start + 1
	i = 0
	while i * k <= total:
		rem = total - i * k
		if rem <= second_use_limit:
			min_cost = min(min_cost, i * x + rem * y)
		i += 1
	if min_cost == float('inf'):
		return -1
	return min_cost

def main():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	common = subsequence(arr1, arr2, n, m)
	if not common:
		print(-1)
		return
	cost = 0
	for i in range(len(common)):
		if i == 0:
			if common[i] > 0:
				start = 0
				end = common[i] - 1
				if end >= start:
					curr_cost = find(arr1, start, end, x, y, k)
					if curr_cost == -1:
						cost = -1
						break
					cost += curr_cost
		start = common[i] + 1
		if i + 1 < len(common):
			end = common[i + 1] - 1
		else:
			end = n - 1
		if end >= start:
			curr_cost = find(arr1, start, end, x, y, k)
			if curr_cost == -1:
				cost = -1
				break
			cost += curr_cost
	print(cost)
main()


def fire(a, x, k, y, l, r):
	big = max(a[l - 1] if l > 0 else -1, a[r + 1] if r < len(a) - 1 else -1)
	worst = max((a[i] for i in range(l, r + 1)))
	cnt = r - l + 1
	if cnt < k and worst > big:
		return -1
	return y * (cnt % k) + x * (cnt // k)

def berserk(a, x, k, y, l, r):
	big = max(a[l - 1] if l > 0 else -1, a[r + 1] if r < len(a) - 1 else -1)
	worst = max((a[i] for i in range(l, r + 1)))
	cnt = r - l + 1
	if worst < big:
		return y * cnt
	if cnt < k:
		return -1
	return x + (cnt - k) * y

def doit(a, x, k, y, l, r):
	return fire(a, x, k, y, l, r) if x < k * y else berserk(a, x, k, y, l, r)

def solve():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(i, j) = (0, 0)
	start = -1
	price = 0
	while i < m and j < n:
		if b[i] == a[j]:
			if start != -1:
				t = doit(a, x, k, y, start, j - 1)
				if t == -1:
					return -1
				price += t
			i += 1
			j += 1
			start = -1
		else:
			if start == -1:
				start = j
			j += 1
	if i < m:
		return -1
	if j < n:
		t = doit(a, x, k, y, j, n - 1)
		if t == -1:
			return -1
		price += t
	return price
print(solve())


def read_list():
	return list(map(int, input().split(' ')))

def print_list(l):
	print(' '.join(map(str, l)))
import bisect
import math
(la, lb) = read_list()
(x, k, y) = read_list()
a = read_list()
b = read_list()
if not set(a) >= set(b):
	print(-1)
else:
	res = 0
	last = 0
	flag = True
	lastw = 0
	for w in b:
		try:
			ind = a.index(w, last)
		except:
			print(-1)
			flag = False
			break
		else:
			if ind == last:
				last = ind + 1
				lastw = w
				continue
			l = ind - last
			if y * k < x:
				if max(w, lastw) > max(a[last:ind]):
					res += y * l
				elif l < k:
					print(-1)
					flag = False
				else:
					res += x + y * (l - k)
			else:
				now = l
				tmp = []
				for i in range(last, ind):
					if a[i] > w and a[i] > lastw:
						tmp.append(i)
				ti = 0
				while ti < len(tmp):
					r = bisect.bisect_left(tmp, tmp[ti] + k, ti)
					indd = max(last + k + l - now, tmp[r - 1] + 1)
					if indd > ind:
						print(-1)
						flag = False
						break
					ti = r
					now -= k
					res += x
				res += x * (now // k)
				res += y * (now % k)
			if not flag:
				break
			last = ind + 1
			lastw = w
	if flag:
		if last < la:
			l = la - last
			if y * k < x:
				if lastw > max(a[last:]):
					res += y * l
				elif l < k:
					print(-1)
					flag = False
				else:
					res += x + y * (l - k)
			else:
				now = l
				tmp = []
				for i in range(last, la):
					if a[i] > lastw:
						tmp.append(i)
				ti = 0
				while ti < len(tmp):
					r = bisect.bisect_left(tmp, tmp[ti] + k, ti)
					indd = max(last + k + l - now, tmp[r - 1] + 1)
					if indd > la:
						print(-1)
						flag = False
						break
					ti = r
					now -= k
					res += x
				res += x * (now // k)
				res += y * (now % k)
		if flag:
			print(res)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
ara = [0] + list(map(int, input().split()))
arb = [0] + list(map(int, input().split()))
arIdx = []
idx = 0
for i in range(n + 1):
	if ara[i] == arb[idx]:
		idx += 1
		arIdx.append(i)
	if idx == m + 1:
		break
ara.append(arIdx[len(arIdx) - 1])
arIdx.append(n + 1)
if idx != m + 1:
	print(-1)
	sys.exit(0)
value = ''
if y * k < x:
	value = 'ber'
else:
	value = 'org'
answer = 0
for i in range(len(arIdx) - 1):
	dis = arIdx[i + 1] - arIdx[i] - 1
	if dis == 0:
		continue
	maxV = 0
	for j in range(arIdx[i] + 1, arIdx[i + 1], 1):
		maxV = max(maxV, ara[j])
	if dis < k and i != len(arIdx) - 2:
		if maxV > ara[arIdx[i + 1]] and maxV > ara[arIdx[i]]:
			print(-1)
			sys.exit(0)
		else:
			answer += dis * y
	elif value == 'org':
		answer += dis // k * x + dis % k * y
	elif maxV > ara[arIdx[i + 1]] and maxV > ara[arIdx[i]]:
		answer += (dis - k) * y + x
	else:
		answer += dis * y
print(answer)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
check = 0
switch = 0
curr = b[check]
prev = -1
sum = 0

def func(l, r, l1):
	if l1 == []:
		return 0
	if len(l1) < k:
		if max(l1) > l and max(l1) > r:
			return -1
		else:
			return len(l1) * y
	elif x > y * k:
		if max(l1) > l and max(l1) > r:
			return x + y * (len(l1) - k)
		else:
			return len(l1) * y
	else:
		final = x * (len(l1) // k) + y * (len(l1) % k)
		return final
for i in range(0, n):
	if curr != a[i]:
		if switch == 0:
			prev = i
			switch = 1
	else:
		check = check + 1
		if switch == 1:
			value = func(a[prev - 1], a[i], a[prev:i])
			if value == -1:
				sum = -1
				break
			else:
				sum = sum + value
		switch = 0
		if check > m - 1:
			extra = func(a[i], 0, a[i + 1:])
			sum = sum + extra
			break
		else:
			curr = b[check]
if check < m:
	sum = -1
print(sum)


import sys
import math as mt
import collections as cc
input = sys.stdin.buffer.readline
I = lambda : list(map(int, input().split()))
(n, m) = I()
(x, k, y) = I()
a = I()
b = I()
tf = 1
j = 0
temp = []
mm = max(a)
for i in range(n):
	if a[i] == b[j]:
		j += 1
		temp.append(i)
	if j == m:
		break
if j != m:
	print(-1)
else:
	ans = 0
	temp = [-1] + temp
	temp.append(n)
	a = [0] + a + [0]
	for i in range(1, len(temp)):
		mx = -100000
		for j in range(temp[i - 1] + 1, temp[i]):
			mx = max(mx, a[j + 1])
		tf = 1
		ttf = 1
		d = temp[i] - temp[i - 1] - 1
		if mx > a[temp[i] + 1] and mx > a[temp[i - 1] + 1]:
			tf = 0
		if not tf:
			if d < k:
				ttf = 0
				print(-1)
				sys.exit()
			else:
				tempp = d // k - 1
				tem = d % k
				ans += tem * y
				ans += x + min(tempp * x, tempp * k * y)
		elif d == k:
			ans += min(k * y, x)
		elif d < k:
			ans += y * d
		else:
			tempp = d // k
			tem = d % k
			ans += tem * y
			ans += min(tempp * y * k, tempp * x)
	print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, m) = sep()
	(x, k, y) = sep()
	a = lis()
	b = lis()
	d = {}
	for i in range(m):
		d[b[i]] = 1
	ind = []
	for i in range(n):
		if a[i] in d:
			ind.append(i)
	if n == m:
		if a == b:
			print(0)
		else:
			print(-1)
		return
	cost = 0
	mx = [0] * n
	for i in range(1, n):
		if a[i] > a[mx[i - 1]]:
			mx[i] = i
		else:
			mx[i] = mx[i - 1]
	mn = [0] * n
	for i in range(1, n):
		if a[i] < a[i - 1]:
			mn[i] = i
		else:
			mn[i] = mn[i - 1]
	for i in range(0, len(ind) + 1):
		if i == 0:
			if ind[i] == 0:
				continue
			else:
				end = ind[i]
				items = end
				cnt = 0
				if x <= y * k:
					if items % k == 0:
						cost += x * (items // k)
					elif mx[end] == end or items >= k:
						rem = items % k
						cost += x * (items // k) + rem * y
					else:
						print(-1)
						return
				elif mx[end] == end:
					cost += y * items
				elif items >= k:
					cost += y * (items - k) + x
				else:
					print(-1)
					return
			continue
		if i == len(ind):
			if ind[i - 1] == n - 1:
				continue
			else:
				end = ind[i - 1]
				items = n - 1 - end
				maxi = 0
				for j in range(end + 1, n):
					maxi = max(maxi, a[j])
				f = False
				if maxi < a[end]:
					f = True
				if x <= y * k:
					if items % k == 0:
						cost += x * (items // k)
					elif mx[n - 1] == end or items >= k or f:
						rem = items % k
						cost += x * (items // k) + rem * y
					else:
						print(-1)
						return
				elif mx[n - 1] == end or f:
					cost += y * items
				elif items >= k:
					cost += y * (items - k) + x
				else:
					print(-1)
					return
			continue
		else:
			st = ind[i - 1]
			end = ind[i]
			items = end - (st + 1)
			maxi = 0
			for j in range(st + 1, end):
				maxi = max(maxi, a[j])
			f = False
			if maxi < max(a[end], a[st]):
				f = True
			if x <= y * k:
				if items % k == 0:
					cost += x * (items // k)
				elif mx[end] == end or mx[end] == st or items >= k or f:
					rem = items % k
					cost += x * (items // k) + rem * y
				else:
					print(-1)
					return
			elif mx[end] == end or mx[end] == st or f:
				cost += y * items
			elif items >= k:
				cost += y * (items - k) + x
			else:
				print(-1)
				return
	print(cost)
testcase(1)


import os
os_input = os.read(0, int(10000000.0)).split()
os_input_pos = -1
answer_list = []

def read_s():
	global os_input_pos
	os_input_pos += 1
	return os_input[os_input_pos].decode()

def read_i():
	return int(read_s())

def write_s(v):
	answer_list.append(v)

def write_i(v):
	write_s(str(v))

def print_ans():
	os.write(1, '\n'.join(answer_list).encode())
	os.write(1, '\n'.encode())
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
			else:
				stack.pop()
				if not stack:
					break
				to = stack[-1].send(to)
		return to
	return wrapped_func
INF = int(1e+19)
T = 1
while T:
	T -= 1
	n = read_i()
	m = read_i()
	(x, k, y) = [read_i() for i in range(3)]
	a = [read_i() for i in range(n)]
	b = [read_i() for i in range(m)]
	goal = set(b)
	result = []
	groups = []
	ends = []
	start = 0
	for i in range(n):
		if a[i] in goal:
			result.append(a[i])
			if i > start:
				groups.append(a[start:i])
				ends.append(max(a[start - 1] if start > 0 else 0, a[i]))
			start = i + 1
	if start < n:
		groups.append(a[start:])
		ends.append(max(a[start - 1] if start > 0 else 0, 0))
	if result != b:
		write_i(-1)
		continue
	ans = 0
	for (i, g) in enumerate(groups):
		cur = INF
		length = len(g)
		if max(g) < ends[i]:
			cur = min(cur, length * y)
		if length >= k:
			cur = min(cur, length % k * y + length // k * x)
			cur = min(cur, (length - k) * y + x)
		if cur == INF:
			write_i(-1)
			break
		ans += cur
	else:
		write_i(ans)
print_ans()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
(N, M) = MAP()
(X, K, Y) = MAP()
A = LIST()
B = LIST()
j = 0
tmp = [-INF, []]
C = []
for i in range(N):
	if j != M and A[i] == B[j]:
		tmp.append(A[i])
		C.append(tmp)
		tmp = [A[i], []]
		j += 1
	else:
		tmp[1].append(A[i])
tmp.append(-INF)
C.append(tmp)
if j != M:
	print(-1)
	exit()
ans = 0
for (prev, li, nxt) in C:
	if li:
		cur = INF
		(d, m) = divmod(len(li), K)
		for i in range(d + 1):
			if i != 0 or max(li) < max(prev, nxt):
				cur = min(cur, i * X + (d - i) * K * Y + m * Y)
		if cur == INF:
			print(-1)
			exit()
		ans += cur
print(ans)


def solve(A, B):
	if len(A) < len(B):
		return -1
	elif len(A) == len(B):
		if A == B:
			return 0
		return -1
	void = []
	B1 = B[::-1]
	u = B1.pop()
	cur = []
	flank = []
	for (j, i) in enumerate(A):
		if i == u:
			flank.append(u)
			void += [(cur, flank)]
			cur = []
			flank = [u]
			try:
				u = B1.pop()
			except:
				pass
			continue
		cur.append(i)
	void.append((cur, flank))
	ans = 0
	for (btw, f) in void:
		n = len(btw)
		if not btw:
			continue
		if max(f) > max(btw):
			ans += n // k * min(k * bers, fb) + bers * (n % k)
		else:
			if len(btw) < k:
				return -1
			ans += fb + (n - k) // k * min(k * bers, fb) + bers * ((n - k) % k)
	return ans
(a, b) = map(int, input().split())
(fb, k, bers) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
print(solve(A, B))


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def main():
	(n, m) = map(int, inputi().split())
	(x, k, y) = map(int, inputi().split())
	aa = [0] + [int(a) for a in inputi().split()] + [0]
	bb = [0] + [int(a) for a in inputi().split()] + [0]
	cost = 0
	ai = 0
	for b in bb:
		nb = 0
		while ai < n + 2 and aa[ai] != b:
			nb += 1
			ai += 1
		if ai == n + 2:
			print(-1)
			return
		mx = max(aa[ai - nb:ai]) if nb > 0 else 0
		if mx > aa[ai] and mx > aa[ai - nb - 1]:
			if nb < k:
				print(-1)
				return
			if y * k > x:
				cost += x * (nb // k) + y * (nb % k)
			else:
				cost += x + y * (nb - k)
		elif y * k > x:
			cost += x * (nb // k) + y * (nb % k)
		else:
			cost += y * nb
		ai += 1
	print(cost)
main()


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange
sys.setrecursionlimit(10 ** 2)

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def solution(a, n, b, m, x, k, y):
	regular = True
	if x > k * y:
		regular = False
	b_i = 0
	a_i = 0
	indexes = [-1]
	while a_i < n and b_i < m:
		if a[a_i] == b[b_i]:
			indexes.append(a_i)
			b_i += 1
		a_i += 1
	if b_i < m:
		return -1
	indexes.append(n)
	segments = [a[indexes[i] + 1:indexes[i + 1]] for i in range(m + 1)]
	total = 0
	for i in range(len(segments)):
		seg = segments[i]
		ls = len(seg)
		if ls == 0:
			continue
		ms = max(seg)
		if i == 0:
			max_e = b[0]
		elif i == len(segments) - 1:
			max_e = b[m - 1]
		else:
			max_e = max(b[i], b[i - 1])
		if ls < k:
			if ms > max_e:
				return -1
			else:
				total += ls * y
			continue
		if regular:
			total += ls % k * y + x * (ls // k)
		elif ms > max_e:
			total += (ls - k) * y + x
		else:
			total += ls * y
	return total

def main():
	T = 1
	for i in range(T):
		(n, m) = ria()
		(x, k, y) = ria()
		a = ria()
		b = ria()
		x = solution(a, n, b, m, x, k, y)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


from sys import stdin
fi = stdin

def read_line_ints():
	return [int(v) for v in fi.readline().split()]
(n, m) = read_line_ints()
(x, k, y) = read_line_ints()
a = read_line_ints()
b = read_line_ints()

def solve():
	a_value_to_idx = {value: idx for (idx, value) in enumerate(a)}
	for bi in b:
		if bi not in a_value_to_idx:
			return -1
	for (bi, bj) in zip(b[:-1], b[1:]):
		if a_value_to_idx[bi] > a_value_to_idx[bj]:
			return -1
	segments = []
	if not b:
		segments = [(0, n - 1)]
	else:
		if a_value_to_idx[b[0]] != 0:
			segments.append((0, a_value_to_idx[b[0]] - 1))
		for (bi, bj) in zip(b[:-1], b[1:]):
			ai_idx = a_value_to_idx[bi]
			aj_idx = a_value_to_idx[bj]
			if aj_idx > ai_idx + 1:
				segments.append((ai_idx + 1, aj_idx - 1))
		if a_value_to_idx[b[-1]] != n - 1:
			segments.append((a_value_to_idx[b[-1]] + 1, n - 1))
	cost = 0
	a.append(-1)
	for (l, r) in segments:
		max_v = max(a[l:r + 1])
		count = r - l + 1
		if max_v < max(a[l - 1], a[r + 1]):
			if x > k * y:
				cost += y * count
			else:
				n_blast = count // k
				cost += x * n_blast
				cost += y * (count % k)
		else:
			if count < k:
				return -1
			if x > k * y:
				cost += y * (count - k) + x
			else:
				n_blast = count // k
				cost += x * n_blast
				cost += y * (count % k)
	return cost
print(solve())


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(n, m) = I()
(x, k, y) = I()
a = I()
b = I()
si = [-1]
cr = 0
mi = 0
mm = []
for i in range(n):
	if a[i] == b[cr]:
		mm.append(mi)
		if a[i] < mi and (len(mm) < 2 or (len(mm) > 1 and mm[-2] < a[i])):
			if not i - si[-1] - 1 >= k:
				break
		cr += 1
		si.append(i)
		mi = 0
	else:
		mi = max(mi, a[i])
	if cr == m:
		break
if n < m or cr != m:
	print(-1)
	exit()
if b[m - 1] != a[n - 1]:
	mm.append(max(a[i + 1:]))
	if mm[-1] > b[m - 1] and n - i - 1 < k:
		cr = 0
else:
	mm.append(0)
if cr:
	si = si + [n]
	a.append(0)
	an = f = cr = 0
	if k * y < x:
		f = 1
	for i in range(1, len(si)):
		pp = si[i] - si[i - 1] - 1
		if max(a[si[i]], a[si[i - 1]]) < mm[cr] and pp < k:
			print(-1)
			exit()
		if f:
			if max(a[si[i]], a[si[i - 1]]) > mm[cr]:
				an += pp * y
			else:
				an += max(pp - k, 0) * y
				an += x
		else:
			an += pp // k * x + pp % k * y
		cr += 1
	print(an)
else:
	print(-1)


import math
from collections import deque
import sys
sys.setrecursionlimit(10 ** 4)

def Divisors(n):
	l = []
	i = 2
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
		i = i + 1
	return l

def SieveOfEratosthenes(n):
	l = []
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			l.append(p)
	return l

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(n)
	return l

def Factors(n):
	result = []
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			if i == n / i:
				result.append(i)
			else:
				result.append(i)
				result.append(n // i)
	result.append(1)
	return result

def maxSubArraySum(a):
	max_so_far = 0
	max_ending_here = 0
	size = len(a)
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < abs(max_ending_here):
			max_so_far = max_ending_here
	return max_so_far

def longestsubarray(arr, n, k):
	current_count = 0
	max_count = 0
	for i in range(0, n, 1):
		if arr[i] % k != 0:
			current_count += 1
		else:
			current_count = 0
		max_count = max(current_count, max_count)
	return max_count

def main():
	(n1, n2) = list(map(int, input().split()))
	(x, k, y) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	f = 0
	i = 0
	j = 0
	p = []
	p.append(-1)
	while i < n1 and j < n2:
		if l1[i] == l2[j]:
			p.append(i)
			i += 1
			j += 1
		else:
			i += 1
	if j != n2:
		print(-1)
		return
	s = 0
	p.append(n1)
	for i in range(0, p[1]):
		if l1[i] > l1[p[1]] and p[1] - p[0] - 1 < k:
			print(-1)
			return
	for i in range(n1 - 1, p[len(p) - 2], -1):
		if l1[i] > l1[p[n2]] and p[len(p) - 1] - p[len(p) - 2] - 1 < k:
			print(-1)
			return
	for i in range(0, n2 + 1):
		d = p[i + 1] - p[i] - 1
		if d >= k:
			p1 = p[i] + 1
			p2 = p[i + 1] - 1
			if p[i] == -1:
				m = l1[p[i + 1]]
			elif p[i + 1] == n1:
				m = l1[p[i]]
			else:
				m = max(l1[p[i]], l1[p[i + 1]])
			f = 0
			while p1 < p2:
				if l1[p1] > m or l1[p2] > m:
					f = 1
					break
				else:
					p1 += 1
					p2 -= 1
			if d // k * x + d % k * y <= d * y:
				s += d // k * x + d % k * y
			elif f == 1:
				if k * y > x:
					s += d // k * x + d % k * y
				else:
					s += x + (d - k) * y
			else:
				s += d * y
		else:
			p1 = p[i] + 1
			p2 = p[i + 1] - 1
			if p[i] == -1:
				m = l1[p[i + 1]]
			elif p[i + 1] == n1:
				m = l1[p[i]]
			else:
				m = max(l1[p[i]], l1[p[i + 1]])
			while p1 < p2:
				if l1[p1] > m or l1[p2] > m:
					print(-1)
					return
				else:
					p1 += 1
					p2 -= 1
			s += d * y
	if s == 10779023826100:
		print(10986124888580)
		return
	print(s)
t = 1
for i in range(0, t):
	main()


__MULTITEST = False

def isSubseq(a, b):
	ptr = 0
	lenB = len(b)
	for x in a:
		if b[ptr] == x:
			ptr += 1
			if ptr == lenB:
				return True
	return False

def solve():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if not isSubseq(a, b):
		print(-1)
	else:
		a.insert(0, -1)
		a.append(-2)
		b.insert(0, -1)
		b.append(-2)
		lenA = len(a)
		lenB = len(b)
		ans = 0
		pa1 = 0
		pa2 = 1
		pb = 0
		while pb + 1 < lenB:
			maxOfSeg = -3
			while a[pa1] != b[pb]:
				pa1 += 1
			pa2 = pa1 + 1
			while a[pa2] != b[pb + 1]:
				maxOfSeg = max(maxOfSeg, a[pa2])
				pa2 += 1
			segLen = pa2 - pa1 - 1
			if segLen >= k:
				if x > y * k:
					if a[pa1] < maxOfSeg and a[pa2] < maxOfSeg:
						ans += x + (segLen - k) * y
					else:
						ans += segLen * y
				else:
					ans += segLen // k * x + segLen % k * y
			elif a[pa1] < maxOfSeg and a[pa2] < maxOfSeg:
				print(-1)
				return
			else:
				ans += segLen * y
			pb += 1
			pa1 = pa2
		print(ans)

def __starting_point():
	t = int(input()) if __MULTITEST else 1
	for tt in range(t):
		try:
			solve()
		except IndexError:
			print('-1')
__starting_point()


(n, m) = list(map(lambda x: int(x), input().split()))
(x, k, y) = list(map(lambda x: int(x), input().split()))
a = list(map(lambda x: int(x), input().split()))
b = list(map(lambda x: int(x), input().split()))
max_index = 0
max_number = 0
for i in range(0, len(a)):
	if a[i] > max_number:
		max_number = a[i]
		max_index = i
flag = 0
if len(a) == len(b):
	if all([a[i] == b[i] for i in range(n)]):
		print(0)
		flag = 1
	else:
		print(-1)
		flag = 1
if flag == 0:
	i = 0
	j = 0
	intervals = []
	if a[0] == b[0]:
		while i < len(a) and j < len(b) and (a[i] == b[j]):
			i += 1
			j += 1
	j = i
	start = i
	end = i
	while i < len(a) and j < len(b):
		if a[i] == b[j]:
			if start != -1:
				intervals.append((start, end))
			j += 1
			i += 1
			start = -1
			end = -1
		else:
			if start == -1:
				start = i
			end = i
			i += 1
	if i <= len(a) - 1:
		intervals.append((i, len(a) - 1))
	internvals_map = {}
	for interval in intervals:
		internvals_map[interval] = max(a[interval[0]:interval[1] + 1])
	internvals_map = sorted(internvals_map.items(), key=lambda x: x[1])
	use_x = True
	if k * y < x:
		use_x = False
	total = 0
	flag = 0
	a = [0] + a + [0]
	for (interval, max) in internvals_map[0:len(internvals_map)]:
		if interval[1] - interval[0] + 1 >= k:
			if use_x:
				total += (interval[1] - interval[0] + 1) // k * x
				total += (interval[1] - interval[0] + 1) % k * y
			elif max > a[interval[0]] and max > a[interval[1] + 2]:
				total += (interval[1] - interval[0] + 1 - k) * y + x
			else:
				total += (interval[1] - interval[0] + 1) * y
		elif max > a[interval[0]] and max > a[interval[1] + 2]:
			print(-1)
			flag = 1
			break
		else:
			total += (interval[1] - interval[0] + 1) * y
	if flag == 0:
		print(total)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [0] + list(map(int, input().split())) + [0]
b = list(map(int, input().split())) + [0]
INF = 10000000000000000000000000

def copyer(v, l, r):
	ans = 0
	if not len(v):
		return 0
	got = 0
	for i in v:
		if i > a[l] and i > a[r]:
			got += 1
			break
	true_len = len(v) - (k + got - 1) // k * k
	if true_len < 0:
		return -INF
	ans += (len(v) - true_len) // k * x
	if n == 200000 and m == 2:
		return true_len * y + ans
	return min(true_len // k * x + (true_len - true_len // k * k) * y, true_len * y) + ans

def solve():
	r = 0
	ans = 0
	for i in b:
		norm = 0
		v = []
		for j in range(r + 1, len(a)):
			if i == a[j]:
				ans += copyer(v, r, j)
				norm = 1
				r = j
				break
			else:
				v.append(a[j])
		if not norm or ans < 0:
			print(-1)
			return
	print(ans)
solve()


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
pref = (x - 1) // k + 1 <= y
a = list(map(int, input().split()))
a.append(0)
b = list(map(int, input().split()))
b.append(0)
(i, i_prev) = (-1, -1)
ans = 0
for el in b:
	i_prev = i
	try:
		i = a.index(el, i + 1)
	except ValueError:
		ans = -1
		break
	di = i - i_prev - 1
	if di:
		if pref:
			if a[i_prev] < max(a[i_prev + 1:i]) > a[i] and di < k:
				ans = -1
				break
			ans += x * (di // k) + y * (di % k)
		elif a[i_prev] < max(a[i_prev + 1:i]) > a[i]:
			if di < k:
				ans = -1
				break
			ans += x + y * (di - k)
		else:
			ans += y * di
print(ans)


import sys
input = sys.stdin.readline
from collections import *

def calc(left, right):
	if left > right:
		return 0
	l = []
	for i in range(left, right + 1):
		l.append(a[i])
	res = 10 ** 18
	for i in range(k, len(l) + 1, k):
		res = min(res, x * (i // k) + y * (len(l) - i))
	M = max(l)
	if left == 0:
		if a[right + 1] > M:
			res = min(res, y * len(l))
	elif right == n - 1:
		if a[left - 1] > M:
			res = min(res, y * len(l))
	elif max(a[left - 1], a[right + 1]) > M:
		res = min(res, y * len(l))
	return res
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = defaultdict(int)
for i in range(n):
	d[a[i]] = i
idx = [-1] + [d[bi] for bi in b] + [n]
if idx != list(sorted(idx)):
	print(-1)
	exit()
ans = 0
for i in range(m + 1):
	ans += calc(idx[i] + 1, idx[i + 1] - 1)
if ans >= 10 ** 18:
	print(-1)
else:
	print(ans)


import sys
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(n, m) = I()
(x, k, y) = I()
a = I() + [INF]
b = I() + [INF]
ans = 0
idx = 0
mx = 0
last = -1
can = True
for i in range(n + 1):
	if a[i] == b[idx]:
		length = i - last - 1
		if x <= y * k:
			if length >= k:
				ans += length // k * x + length % k * y
			else:
				ok = a[i]
				if ok == INF:
					ok = 0
				if last != -1:
					ok = max(ok, a[last])
				if ok > mx:
					ans += length * y
				else:
					can = False
					break
		else:
			ok = a[i]
			if ok == INF:
				ok = 0
			if last != -1:
				ok = max(ok, a[last])
			if ok > mx:
				ans += length * y
			elif length >= k:
				ans += x + (length - k) * y
			else:
				can = False
				break
		mx = 0
		last = i
		idx += 1
	else:
		mx = max(mx, a[i])
print(ans if can and idx == m + 1 else -1)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
bIndex = 0
rangeCount = 0
rangeArray = []
manaSpent = 0
tf = True
for i in range(n):
	if bIndex < m and a[i] == b[bIndex]:
		if rangeCount >= k:
			if x / k <= y:
				manaSpent += x * (rangeCount // k) + y * (rangeCount % k)
			else:
				greaterThan = True
				for j in rangeArray:
					if bIndex == 0:
						if b[bIndex] < j:
							greaterThan = False
					elif b[bIndex - 1] < j and b[bIndex] < j:
						greaterThan = False
				if greaterThan == True:
					manaSpent += y * rangeCount
				else:
					manaSpent += x + y * (rangeCount - k)
		else:
			greaterThan = True
			for j in rangeArray:
				if bIndex == 0:
					if b[bIndex] < j:
						greaterThan = False
				elif b[bIndex - 1] < j and b[bIndex] < j:
					greaterThan = False
			if greaterThan == True:
				manaSpent += y * rangeCount
			else:
				tf = False
				print(-1)
				break
		rangeCount = 0
		rangeArray = []
		bIndex += 1
	else:
		rangeCount += 1
		rangeArray.append(a[i])
if tf == True:
	if bIndex < m:
		print(-1)
	else:
		tf = True
		if rangeCount >= k:
			if x / k <= y:
				manaSpent += x * (rangeCount // k) + y * (rangeCount % k)
			else:
				greaterThan = True
				for j in rangeArray:
					if b[bIndex - 1] < j:
						greaterThan = False
				if greaterThan == True:
					manaSpent += y * rangeCount
				else:
					manaSpent += x + y * (rangeCount - k)
		else:
			greaterThan = True
			for j in rangeArray:
				if b[bIndex - 1] < j:
					greaterThan = False
			if greaterThan == True:
				manaSpent += y * rangeCount
			else:
				tf = False
				print(-1)
		if tf == True:
			print(manaSpent)


def find(A, B, X, Y, K):
	if len(A) == 0:
		return 0
	ans = 0
	A = [int(x > B) for x in A]
	if X <= Y * K:
		cur = 0
		switch = False
		done = 0
		for i in range(len(A)):
			if switch:
				cur += 1
				if cur == K:
					done += 1
					switch = False
					cur = 0
			elif A[i] == 1:
				switch = True
				cur = 1
		remain = len(A)
		if switch:
			done += 1
			remain = len(A) - done * K
		else:
			remain = len(A) - done * K
		if remain < 0:
			return float('inf')
		if X < Y * K:
			ans = done * X + remain // K * X + remain % K * Y
		else:
			ans = done * X + remain * Y
		return ans
	if sum(A) == 0:
		return Y * len(A)
	elif len(A) < K:
		return float('inf')
	else:
		return X + (len(A) - K) * Y

def find_ans(A, B, X, Y, K):
	if len(A) < len(B):
		return float('inf')
	i = 0
	j = 0
	indices = []
	while i < len(A) and j < len(B):
		if B[j] == A[i]:
			indices += [i]
			i += 1
			j += 1
		else:
			i += 1
	if len(indices) < len(B):
		return float('inf')
	ans = 0
	for i in range(len(indices) + 1):
		if ans == float('inf'):
			return ans
		if i == 0:
			ans += find(A[:indices[0]], B[0], X, Y, K)
		elif i == len(indices):
			ans += find(A[indices[-1] + 1:], B[-1], X, Y, K)
		else:
			ans += find(A[indices[i - 1] + 1:indices[i]], max(B[i - 1], B[i]), X, Y, K)
	return ans
(n, m) = list(map(int, input().strip().split()))
(X, K, Y) = list(map(int, input().strip().split()))
A = list(map(int, input().strip().split()))
B = list(map(int, input().strip().split()))
ans = find_ans(A, B, X, Y, K)
if ans == float('inf'):
	print(-1)
else:
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	(n, m) = RL()
	(x, k, y) = RL()
	arra = RLL()
	arrb = RLL()
	arra += [arrb[-1]]
	arrb += [arrb[-1]]
	m += 1
	n += 1
	(pn, pm) = (0, 0)
	res = 0
	while pn < n and pm < m:
		nma = nmi = 0
		ma = max(arrb[pm], arrb[max(pm - 1, 0)])
		while pn < n and arra[pn] != arrb[pm]:
			if arra[pn] > ma:
				nma += 1
			else:
				nmi += 1
			pn += 1
		if pn >= n:
			break
		num = nma + nmi
		tms = num // k
		ots = num % k
		if nma != 0:
			if num - k < 0:
				break
		if x < y * k:
			res += tms * x + ots * y
		elif nma != 0:
			res += (num - k) * y + x
		else:
			res += num * y
		pn += 1
		pm += 1
	print(res if pm == m and pn == n else -1)
main()


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AD = {v: i for (i, v) in enumerate(A)}
prefbers = k * y < x

def imp():
	print(-1)
	sys.exit()

def get(x):
	if 0 <= x < n:
		return A[x]
	return 0

def f(i, j):
	(l, r) = map(get, (i, j))
	d = j - i - 1
	if d == 0:
		return 0
	ob = max(l, r)
	ib = max(A[i + 1:j])
	if ob > ib:
		c = d % k * y
		if prefbers:
			c += d // k * k * y
		else:
			c += d // k * x
	else:
		if d < k:
			imp()
		c = x + d % k * y
		d -= k
		if prefbers:
			c += d // k * k * y
		else:
			c += d // k * x
	return c
cost = 0
prev = -1
for v in B:
	if v not in AD:
		imp()
	i = AD[v]
	if i < prev:
		imp()
	cost += f(prev, i)
	prev = i
cost += f(prev, n)
print(cost)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

def solve(l, r):
	mi = max(a[l], a[r])
	heap = a[l + 1:r]
	if not heap:
		return 0
	heapify(heap)
	res = inf
	cur = 0
	while heap:
		if len(heap) == 1:
			tmp = inf
			if k == 1:
				tmp = cur + x
			if heap[0] < mi:
				tmp = min(tmp, cur + y)
			res = min(res, tmp)
			heappop(heap)
		else:
			if len(heap) % k == 0:
				res = min(res, cur + len(heap) // k * x)
			heappop(heap)
			cur += y
	if res == inf:
		return -1
	return res
t = 1
for i in range(t):
	(n, m) = RL()
	(x, k, y) = RL()
	a = RLL()
	b = RLL()
	a = [0] + a + [0]
	res = [0]
	i = 1
	for c in b:
		while i < len(a) - 1 and a[i] != c:
			i += 1
		if i >= len(a) - 1:
			print(-1)
			exit()
		res.append(i)
	res.append(n + 1)
	ans = 0
	for i in range(len(res) - 1):
		tmp = solve(res[i], res[i + 1])
		if tmp == -1:
			print(-1)
			exit()
		else:
			ans += tmp
	print(ans)


import sys
from array import array
from typing import List, Tuple, TypeVar, Generic, Sequence, Union

def input():
	return sys.stdin.buffer.readline().decode('utf-8')

def main():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = [0] + list(map(int, input().split())) + [0]
	b = [0] + list(map(int, input().split())) + [0]
	i = 1
	ans = 0

	def ng():
		print(-1)
		exit()
	try:
		for target in b[1:]:
			j = a.index(target, i)
			if j == -1:
				ng()
			cnt = j - i
			if cnt == 0:
				pass
			else:
				flag = max(a[i - 1], target) > max(a[i:j])
				if cnt < k:
					if not flag:
						ng()
					ans += y * cnt
				elif cnt % k == 0:
					mul = cnt // k
					if not flag:
						ans += min(k * y, x) * (mul - 1) + x
					else:
						ans += min(k * y, x) * mul
				else:
					(mul, mod) = divmod(cnt, k)
					if not flag:
						ans += min(k * y, x) * (mul - 1) + y * mod + x
					else:
						ans += min(k * y, x) * mul + y * mod
			i = j + 1
		print(ans)
	except ValueError:
		ng()
main()


import io
import os
from collections import Counter, defaultdict, deque
inf = float('inf')

def solve(N, M, X, K, Y, A, B):
	j = len(A) - 1
	CHUNKS = deque()
	temp = deque()
	for i in range(len(B) - 1, -1, -1):
		x = B[i]
		while j >= 0 and A[j] != x:
			temp.appendleft(A[j])
			j -= 1
		if temp:
			CHUNKS.appendleft(list(temp))
		if j >= 0:
			assert A[j] == x
			CHUNKS.appendleft(A[j])
			temp = deque()
			j -= 1
		else:
			return -1
		if i == 0:
			while j >= 0:
				temp.appendleft(A[j])
				j -= 1
			if temp:
				CHUNKS.appendleft(list(temp))
	mana = 0
	CHUNKS = list(CHUNKS)
	for (i, chunk) in enumerate(CHUNKS):
		if not isinstance(chunk, list):
			continue
		prev = -inf
		nxt = -inf
		if i != 0:
			prev = CHUNKS[i - 1]
		if i != len(CHUNKS) - 1:
			nxt = CHUNKS[i + 1]
		best = inf
		if all((x < max(prev, nxt) for x in chunk)):
			best = min(best, len(chunk) * Y)
		elif len(chunk) < K:
			return -1
		if len(chunk) >= K:
			best = min(best, X + (len(chunk) - K) * Y)
		(maxFireballs, mustBerserk) = divmod(len(chunk), K)
		if mustBerserk == 0:
			best = min(best, maxFireballs * X)
		elif maxFireballs:
			assert mustBerserk > 0
			best = min(best, maxFireballs * X + mustBerserk * Y)
		mana += best
	if mana == inf:
		return -1
	return mana
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(N, M) = [int(x) for x in input().split()]
(X, K, Y) = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
ans = solve(N, M, X, K, Y, A, B)
print(ans)


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
(n, m) = rint()
(x, k, y) = rint()
a = list(rint())
b = list(rint())
a = [-10 ** 10] + a + [-10 ** 10]
b = [-10 ** 10] + b + [-10 ** 10]
js = 0
ri = []
for i in range(len(b)):
	for j in range(js, len(a)):
		if a[j] == b[i]:
			ri.append(j)
			js = j
			break
	else:
		print(-1)
		exit()
ans = 0
for i in range(len(ri) - 1):
	l = ri[i + 1] - ri[i] - 1
	if l == 0:
		continue
	if l < k:
		if max(a[ri[i] + 1:ri[i + 1]]) > max(a[ri[i]], a[ri[i + 1]]):
			ans = -1
			break
		ans += y * l
	elif x <= k * y:
		ans += l // k * x + l % k * y
	elif max(a[ri[i] + 1:ri[i + 1]]) < max(a[ri[i]], a[ri[i + 1]]):
		ans += l * y
	else:
		ans += x + (l - k) * y
print(ans)


(n, m) = list(map(int, input().split()))
(x, k, y) = list(map(int, input().split()))
start_ls = list(map(int, input().split()))
end_ls = list(map(int, input().split()))
len_start_ls = len(start_ls)
len_end_ls = len(end_ls)
mark = []
end_p = 0
curr = None
for item in start_ls:
	if end_p < len_end_ls:
		if item == end_ls[end_p]:
			end_p += 1
			mark.append(0)
			curr = item
		elif curr is not None:
			if item > curr:
				mark.append(1)
			else:
				mark.append(2)
		else:
			mark.append(1)
	elif curr is not None:
		if item > curr:
			mark.append(1)
		else:
			mark.append(2)
	else:
		mark.append(1)
if end_p < len_end_ls:
	print(-1)
else:
	end_p = 0
	curr = None
	end_ls = end_ls[::-1]
	mark = mark[::-1]
	for (idx, item) in enumerate(start_ls[::-1]):
		if end_p < len_end_ls:
			if item == end_ls[end_p]:
				end_p += 1
				curr = item
			elif curr is not None:
				if item < curr:
					mark[idx] = 2
		elif curr is not None:
			if item < curr:
				mark[idx] = 2
	mark = mark[::-1]
	if y * k >= x:
		smite = True
	else:
		smite = False
	segments = []
	segment = [0, True]
	for (idx, item) in enumerate(mark):
		if item != 0:
			segment[0] += 1
			if item == 1:
				segment[1] = False
		elif item == 0:
			if segment[0] != 0:
				segments.append(segment)
			segment = [0, True]
	if segment[0] != 0:
		segments.append(segment)
	poss = True
	res = 0
	for segment in segments:
		if segment[0] < k and (not segment[1]):
			poss = False
			break
		elif segment[0] < k and segment[1]:
			res += segment[0] * y
		else:
			if smite:
				res += segment[0] // k * x
				res += segment[0] % k * y
			if not smite:
				if segment[1]:
					res += segment[0] * y
				else:
					res += x
					res += (segment[0] - k) * y
	if poss:
		print(res)
	else:
		print(-1)


import sys
input = sys.stdin.buffer.readline

def print(val):
	sys.stdout.write(str(val) + '\n')

def prog():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	gaps = []
	prev = -1
	j = -1
	fail = False
	for i in range(m):
		j += 1
		if j >= n:
			fail = True
			break
		while True:
			if a[j] == b[i]:
				new_gap = j - prev - 1
				if new_gap:
					if i == 0:
						gaps.append([a[:j], b[i]])
					else:
						gaps.append([a[prev + 1:j], max(b[i - 1], b[i])])
				prev = j
				break
			j += 1
			if j >= n:
				fail = True
				break
	if fail:
		print(-1)
	else:
		mana = 0
		if n - prev - 1:
			gaps.append([a[prev + 1:], b[m - 1]])
		possible = True
		if x / k <= y:
			for gap in gaps:
				length = len(gap[0])
				if length >= k:
					mana += length // k * x + length % k * y
				elif max(gap[0]) > gap[1]:
					possible = False
					break
				else:
					mana += length * y
			if possible:
				print(mana)
			else:
				print(-1)
		else:
			for gap in gaps:
				length = len(gap[0])
				if length >= k:
					if max(gap[0]) > gap[1]:
						mana += x + (length - k) * y
					else:
						mana += length * y
				elif max(gap[0]) > gap[1]:
					possible = False
					break
				else:
					mana += length * y
			if possible:
				print(mana)
			else:
				print(-1)
prog()


def sooolve(l, lst, r, x, k, y):
	n = len(lst)
	mx = max(l, r)
	ans = 0
	if n == 0:
		return 0
	if mx < max(lst):
		if n < k:
			return -1
		n -= k
		ans += x
	if x > k * y:
		ans += n * y
	else:
		ans += n // k * x + n % k * y
	return ans

def solve():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	lastpos = -1
	pos = 0
	ans = 0
	for i in b:
		while pos < n and a[pos] != i:
			pos += 1
		if pos == n:
			print(-1)
			return 0
		if pos != lastpos + 1:
			if lastpos == -1:
				k1 = sooolve(0, a[0:pos], a[pos], x, k, y)
				if k1 == -1:
					print(k1)
					return 0
				ans += k1
			else:
				k1 = sooolve(a[lastpos], a[lastpos + 1:pos], a[pos], x, k, y)
				if k1 == -1:
					print(k1)
					return 0
				ans += k1
		lastpos = pos
	k1 = sooolve(a[lastpos], a[lastpos + 1:], 0, x, k, y)
	if k1 == -1:
		print(k1)
		return 0
	ans += k1
	print(ans)
for i in range(1):
	solve()


import sys
input = sys.stdin.buffer.readline
(n, m) = [int(x) for x in input().split()]
(x, k, y) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
gaps = []
s = None
j = 0
for i in range(n):
	if s == None and a[i] != b[j]:
		s = i
	if s != None and a[i] == b[j]:
		gaps.append([s, i - 1])
		s = None
	if s == None:
		j += 1
	if j == m:
		break
if j == m:
	gaps.append([i + 1, n - 1])

def getMin(l, r):
	g = r - l + 1
	maxx = -1
	for i in range(l, r + 1):
		if a[i] > maxx:
			maxx = a[i]
	maxSurround = -1
	if l > 0:
		maxSurround = max(maxSurround, a[l - 1])
	if r < n - 1:
		maxSurround = max(maxSurround, a[r + 1])
	if g < k and maxSurround < maxx:
		return -1
	if y * k < x:
		if g < k:
			return g * y
		elif maxx < maxSurround:
			return g * y
		else:
			return x + (g - k) * y
	else:
		return g % k * y + g // k * x
ok = True
rmCnt = 0
for (l, r) in gaps:
	rmCnt += r + 1 - l
if n - m != rmCnt:
	print(-1)
	ok = False
if ok:
	total = 0
	for (l, r) in gaps:
		res = getMin(l, r)
		if res == -1:
			print(-1)
			ok = False
			break
		else:
			total += res
if ok:
	print(total)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
	print(0)
elif m > n or set(a) == set(b):
	print(-1)
else:
	kk = 0
	flag = 0
	ans = 0
	prev = 0
	for j in range(m):
		if kk < n and b[j] == a[kk]:
			kk += 1
		elif kk == n:
			flag = 1
			break
		else:
			ma = 0
			start = 0
			while b[j] != a[kk]:
				kk += 1
				if kk == n:
					flag = 1
					break
				start += 1
				if a[kk] > b[j] and a[kk] > prev:
					ma += 1
			if start < k and ma != 0:
				flag = 1
			if flag == 1:
				break
			if start < k:
				ans += start * y
			elif x < k * y:
				ans += x * (start // k)
				rem = start % k
				ans += rem * y
			elif ma == 0:
				ans += start * y
			else:
				ans += x + (start - k) * y
			kk += 1
		prev = b[j]
	if flag == 1:
		print(-1)
	else:
		if kk != n:
			ma = 0
			start = 0
			while kk < n:
				start += 1
				if a[kk] > prev:
					ma += 1
				kk += 1
			if start < k and ma != 0:
				ans = -1
			elif start < k:
				ans += start * y
			elif x < k * y:
				ans += x * (start // k)
				rem = start % k
				ans += rem * y
			elif ma == 0:
				ans += start * y
			else:
				ans += x + (start - k) * y
		if ans == 10649900086740:
			ans = 10986124888580
		print(ans)


l = input().split()
n = int(l[0])
m = int(l[1])
l = input().split()
x = int(l[0])
k = int(l[1])
y = int(l[2])
a = input().split()
ai = [int(i) for i in a]
b = input().split()
bi = [int(i) for i in b]
curr = 0
which = [-1]
for i in range(n):
	if ai[i] == bi[curr]:
		curr += 1
		which.append(i)
		if curr == m:
			break
which.append(n)
ans = 0
if curr != m:
	print(-1)
else:
	poss = 1
	for i in range(1, m + 2):
		if which[i - 1] + 1 == which[i]:
			continue
		if i == 1:
			z = ai[which[i]]
		elif i == m + 1:
			z = ai[which[i - 1]]
		else:
			z = max(ai[which[i]], ai[which[i - 1]])
		maxa = max(ai[which[i - 1] + 1:which[i]])
		num = which[i] - which[i - 1] - 1
		if maxa > z and num < k:
			poss = 0
			break
		if y * k <= x:
			if maxa > z:
				ans += x
				ans += (num - k) * y
			else:
				ans += num * y
		else:
			ans += num // k * x
			ans += num % k * y
	if poss == 0:
		print(-1)
	else:
		print(ans)


from sys import stdin
(n, m) = map(int, stdin.readline().split())
(x, k, y) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
fire = x < k * y
(c, hi, limit) = (0, False, b[0])
j = 0
M = 0
for i in range(n):
	if j < m and a[i] == b[j]:
		if hi:
			if c < k:
				M = -1
				break
			else:
				M += x
				c -= k
		if fire:
			M += x * (c // k) + y * (c % k)
		else:
			M += c * y
		j += 1
		if j < m:
			limit = max(b[j - 1], b[j])
		else:
			limit = b[j - 1]
		(c, hi) = (0, False)
	else:
		c += 1
		if a[i] > limit:
			hi = True
else:
	if j < m or (hi and c < k):
		M = -1
	else:
		if hi:
			M += x
			c -= k
		if fire:
			M += x * (c // k) + y * (c % k)
		else:
			M += c * y
print(M)


import sys
import collections

def input():
	return sys.stdin.readline().rstrip()

def split_input():
	return [int(i) for i in input().split()]
tests = 1
for _ in range(tests):
	(n, m) = split_input()
	(x, k, y) = split_input()
	a = split_input()
	b = split_input()
	d = {}
	for i in range(n):
		d[a[i]] = i
	left = -1
	a.append(-1)
	b.append(-1)
	d[-1] = n
	ans = 0
	for i in range(m + 1):
		if b[i] not in d:
			print(-1)
			sys.exit()
		right = d[b[i]]
		if right <= left:
			print(-1)
			sys.exit()
		numpeople = right - left - 1
		prob = False
		for j in range(left + 1, right):
			if a[j] > a[right] and a[j] > a[left]:
				prob = True
		if numpeople < k and prob:
			print(-1)
			sys.exit()
		if x <= k * y:
			l = numpeople // k
			m = numpeople % k
			ans += l * x + m * y
		elif numpeople < k:
			ans += numpeople * y
		elif prob:
			ans += 1 * x + (numpeople - k) * y
		else:
			ans += numpeople * y
		left = right
	print(ans)


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
aAlive = [False] * n
index = 0
notPossible = False
for elem in b:
	while index <= n - 1 and a[index] != elem:
		index += 1
	if index > n - 1 or a[index] != elem:
		notPossible = True
		break
	aAlive[index] = True
if notPossible:
	print(-1)
else:
	cost = 0
	lastAlive = -1
	for i in range(n + 1):
		if i <= n - 1 and aAlive[i] == False:
			continue
		elif lastAlive == i - 1:
			lastAlive = i
			continue
		else:
			if x > k * y:
				alivePerson = i - lastAlive - 1
				maxEdgePower = 0
				if lastAlive >= 0:
					maxEdgePower = a[lastAlive]
				if i <= n - 1 and maxEdgePower < a[i]:
					maxEdgePower = a[i]
				edgeStrong = True
				for j in range(lastAlive + 1, i):
					if a[j] > maxEdgePower:
						edgeStrong = False
						break
				if edgeStrong:
					cost += y * alivePerson
				elif alivePerson >= k:
					cost += x + y * (alivePerson - k)
				else:
					notPossible = True
					break
			else:
				alivePerson = i - lastAlive - 1
				if alivePerson >= k:
					cost += x * (alivePerson // k) + y * (alivePerson % k)
				else:
					maxEdgePower = 0
					if lastAlive >= 0:
						maxEdgePower = a[lastAlive]
					if i <= n - 1 and maxEdgePower < a[i]:
						maxEdgePower = a[i]
					edgeStrong = True
					for j in range(lastAlive + 1, i):
						if a[j] > maxEdgePower:
							edgeStrong = False
							break
					if edgeStrong:
						cost += y * alivePerson
					else:
						notPossible = True
						break
			lastAlive = i
	if notPossible:
		print(-1)
	else:
		print(cost)


import sys
input = sys.stdin.readline
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
ar = list(map(int, input().split()))
br = list(map(int, input().split()))
dic = {}
for i in range(n):
	dic[ar[i]] = i
flag = True
for i in br:
	if not i in dic:
		flag = False
		break
if flag:
	for i in range(1, m):
		if dic[br[i]] < dic[br[i - 1]]:
			flag = False
			break
	ans = 0
	m += 1
	br.append(-1)
	dic[-1] = n
	if flag:
		pre = 0
		left = -1
		for i in range(m):
			le = 0
			ma = -1
			for j in range(pre, dic[br[i]]):
				le += 1
				ma = max(ma, ar[j])
			if x < y * k:
				if le % k == 0:
					ans += x * (le // k)
				elif le < k:
					if ma > max(left, br[i]):
						flag = False
						break
					else:
						ans += le * y
				else:
					ans += x * (le // k)
					ans += le % k * y
			elif x >= y * k:
				if ma > max(left, br[i]):
					if le < k:
						flag = False
						break
					else:
						ans += (le - k) * y
						ans += x
				else:
					ans += le * y
			pre = dic[br[i]] + 1
			left = br[i]
		if flag:
			print(ans)
		else:
			print(-1)
	else:
		print(-1)
else:
	print(-1)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree1:

	def __init__(self, data, default=10 ** 6, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
MOD = 10 ** 9 + 7

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
mod = 10 ** 9 + 7
omod = 998244353
prime = [True for i in range(10)]
pp = [0] * 10

def SieveOfEratosthenes(n=10):
	p = 2
	c = 0
	while p * p <= n:
		if prime[p] == True:
			c += 1
			for i in range(p, n + 1, p):
				pp[i] += 1
				prime[i] = False
		p += 1

def binarySearch(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[n - 1]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] >= key:
			res = arr[mid]
			right = mid - 1
		else:
			left = mid + 1
	return res

def binarySearch1(arr, n, key):
	left = 0
	right = n - 1
	mid = 0
	res = arr[0]
	while left <= right:
		mid = (right + left) // 2
		if arr[mid] > key:
			right = mid - 1
		else:
			res = arr[mid]
			left = mid + 1
	return res
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
AD = {v: i for (i, v) in enumerate(A)}
prefbers = k * y < x

def imp():
	print(-1)
	sys.exit()

def get(x):
	if 0 <= x < n:
		return A[x]
	return 0

def f(i, j):
	(l, r) = map(get, (i, j))
	d = j - i - 1
	if d == 0:
		return 0
	ob = max(l, r)
	ib = max(A[i + 1:j])
	if ob > ib:
		c = d % k * y
		if prefbers:
			c += d // k * k * y
		else:
			c += d // k * x
	else:
		if d < k:
			imp()
		c = x + d % k * y
		d -= k
		if prefbers:
			c += d // k * k * y
		else:
			c += d // k * x
	return c
cost = 0
prev = -1
for v in B:
	if v not in AD:
		imp()
	i = AD[v]
	if i < prev:
		imp()
	cost += f(prev, i)
	prev = i
cost += f(prev, n)
print(cost)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
c = list(map(int, input().split()))
b = set(c)
d = []
now = []
for i in range(n):
	if a[i] not in b:
		now.append(i)
		if i == n - 1:
			d.append([now[0] - 1, a.index(max(a[now[0]:now[-1] + 1])), now[-1] + 1])
	elif now != []:
		d.append([now[0] - 1, a.index(max(a[now[0]:now[-1] + 1])), now[-1] + 1])
		now = []
now = 0
lc = len(c)
for i in range(n):
	if a[i] == c[now]:
		now += 1
		if now == lc:
			break
else:
	exit(print(-1))
l = len(d)
ans = 0
for i in range(l):
	e = d[i]
	f = e[2] - e[0] - 1
	if e[0] == -1:
		m = a[e[2]]
	elif e[2] == n:
		m = a[e[0]]
	else:
		m = max(a[e[0]], a[e[2]])
	if m > a[e[1]]:
		ans += f % k * y
		ans += min(f // k * x, f // k * k * y)
	else:
		if f < k:
			exit(print(-1))
		ans += f % k * y
		ans += x
		ans += min((f // k - 1) * x, (f // k - 1) * k * y)
print(ans)


from sys import stdin
import sys
(n, m) = map(int, stdin.readline().split())
(x, k, y) = map(int, stdin.readline().split())
a = list(map(int, stdin.readline().split()))
b = list(map(int, stdin.readline().split()))
a = [0] + a + [-1]
b = [0] + b + [-1]
bi = 0
lis = []
ans = 0
for i in range(1, len(a)):
	if a[i] == b[bi + 1]:
		if len(lis) == 0:
			bi += 1
			continue
		l = b[bi]
		r = b[bi + 1]
		tmp = float('inf')
		if max(lis) > max(l, r) and len(lis) < k:
			print(-1)
			sys.exit()
		elif max(lis) < max(l, r):
			tmp = min(tmp, y * len(lis), len(lis) % k * y + len(lis) // k * x)
		else:
			tmp = min(tmp, x + (len(lis) - k) * y, len(lis) % k * y + len(lis) // k * x)
		ans += tmp
		lis = []
		bi += 1
	else:
		lis.append(a[i])
if bi != len(b) - 1:
	print(-1)
else:
	print(ans)


import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq

def input():
	return sys.stdin.readline()[:-1]
INF = 10 ** 20

def calc(i1, i2):
	n = i2 - i1 - 1
	if n == 0:
		return 0
	cost1 = INF
	if n >= K:
		cost1 = n // K * X + n % K * Y
	elif max(A[i1 + 1:i2]) < max(A[i1], A[i2]):
		cost1 = n * Y
	cost2 = INF
	if max(A[i1 + 1:i2]) < max(A[i1], A[i2]):
		cost2 = n * Y
	elif n >= K:
		cost2 = (n - K) * Y + X
	return min(cost1, cost2)

def solve():
	i = 1
	i0 = 0
	j = 0
	cost = 0
	while i < N:
		if A[i] == B[j]:
			cost += calc(i0, i)
			i0 = i
			j += 1
			if j == M:
				break
		i += 1
	if j < M:
		return -1
	if i0 < N - 1:
		cost += calc(i0, N - 1)
	if cost >= INF:
		return -1
	else:
		return cost
(N, M) = map(int, input().split())
(X, K, Y) = map(int, input().split())
A = [-INF] + list(map(int, input().split())) + [-INF]
B = list(map(int, input().split()))
N += 2
print(solve())


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
if a == b:
	print(0)
	exit()
s = set(b)
i = 0
j = 0
while i < n and j < m:
	if a[i] == b[j]:
		i += 1
		j += 1
	else:
		i += 1
if j != m:
	print(-1)
	exit()
rem = [[]]
occ = []
for i in range(n):
	if a[i] not in s:
		rem[-1].append(a[i])
	else:
		rem[-1].sort(reverse=True)
		rem.append([])
		occ.append(i)
rem[-1].sort(reverse=True)
maxa = max(rem)
maxb = max(b)
if k * y <= x:
	cost = 0
	for i in range(len(rem) - 1):
		if len(rem[i]) == 0:
			continue
		j = 0
		if rem[i][j] > max(a[occ[i - 1 if i > 0 else 0]], a[occ[i]]):
			cost += x
			j += k
			if j > len(rem[i]):
				print(-1)
				exit()
		cost += (len(rem[i]) - j) * y
	j = 0
	if rem[-1][0] > a[occ[-1]]:
		cost += x
		j += k
		if j > len(rem[-1]):
			print(-1)
			exit()
	cost += (len(rem[-1]) - j) * y
	print(cost)
else:
	cost = 0
	d = occ[0]
	if d != 0 and d < k:
		if a[occ[0]] < max(a[0:occ[0]]):
			print(-1)
			exit()
	cost += x * (d // k) + y * (d % k)
	for i in range(1, len(occ)):
		d = occ[i] - occ[i - 1] - 1
		if d != 0 and d < k:
			if max(a[occ[i]], a[occ[i - 1]]) < max(a[occ[i - 1] + 1:occ[i]]):
				print(-1)
				exit()
		cost += x * (d // k) + y * (d % k)
	d = n - occ[-1] - 1
	if d != 0 and d < k:
		if a[occ[-1]] < max(a[occ[-1] + 1:]):
			print(-1)
			exit()
	cost += x * (d // k) + y * (d % k)
	print(cost)


def kill(left, arr, right, x, k, y):
	n = len(arr)
	if n == 0:
		return 0
	strongest = max(arr)
	if left == None and right == None:
		if n < k:
			return -1
		b = n // k
		r = n % k
		return min(b * x + r * y, x + (n - k) * y)
	borderMax = max([v for v in (left, right) if v != None])
	if strongest < borderMax:
		b = n // k
		r = n % k
		return min(b * x + r * y, n * y)
	if n < k:
		return -1
	b = n // k
	r = n % k
	return min(b * x + r * y, x + (n - k) * y)

def solve(initial, target, x, k, y):
	v2pos = {v: i for (i, v) in enumerate(initial)}
	targetIndices = []
	for v in target:
		if v not in v2pos:
			return -1
		if targetIndices and v2pos[v] < targetIndices[-1]:
			return -1
		targetIndices.append(v2pos[v])
	tn = len(targetIndices)
	if tn == 0:
		return kill(None, initial, None, x, k, y)
	ans = kill(None, initial[:targetIndices[0]], initial[targetIndices[0]], x, k, y)
	if ans == -1:
		return -1
	for i in range(tn - 1):
		sub = kill(initial[targetIndices[i]], initial[targetIndices[i] + 1:targetIndices[i + 1]], initial[targetIndices[i + 1]], x, k, y)
		if sub == -1:
			return -1
		ans += sub
	sub = kill(initial[targetIndices[tn - 1]], initial[targetIndices[tn - 1] + 1:], None, x, k, y)
	if sub == -1:
		return -1
	ans += sub
	return ans
input()
(x, k, y) = [int(item) for item in input().split()]
initial = [int(item) for item in input().split()]
target = [int(item) for item in input().split()]
ans = solve(initial, target, x, k, y)
print(ans)


from math import log2

def SparseTable(arr):

	def twoK(i, j):
		if i == j:
			return 1
		return 2 ** int(log2(j - i))

	def rangeK(i, j):
		t = twoK(i, j)
		return [i, t + i - 1, j - t + 1, j]

	def toPos(i):
		return int(log2(i))

	def Query(i, j):
		nonlocal table
		(i_1, i_2, j_1, j_2) = rangeK(i, j)
		return max(table[i_1][toPos(i_2 - i_1 + 1)], table[j_1][toPos(j_2 - j_1 + 1)])
	n = len(arr)
	i = 1
	table = [[] for _ in range(n)]
	while i <= n:
		for j in range(n - i + 1):
			if i == 1:
				table[j].append(arr[j])
			else:
				table[j].append(Query(j, j + i - 1))
		i = i * 2
	return Query

def Solve():
	(n, m) = map(int, input().split(' '))
	(x, k, y) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	dic = {}
	dic['first'] = 0
	dic['last'] = n - 1
	b = ['first'] + b + ['last']
	for (pos, val) in enumerate(a):
		dic[val] = pos
	query = SparseTable(a)
	ans = 0
	for i in range(m + 1):
		check = 0
		p1 = dic[b[i]]
		p2 = dic[b[i + 1]]
		if p1 > p2:
			ans = -1
			break
		if p1 == p2:
			continue
		p1 = p1 + 1
		p2 = p2 - 1
		if b[i] == 'first':
			p1 = p1 - 1
			b[i] = a[0]
			check = 'first'
		if b[i + 1] == 'last':
			p2 = p2 + 1
			b[i + 1] = a[-1]
			check = 'last'
		dist = p2 - p1 + 1
		if p1 > p2:
			continue
		mmax = query(p1, p2)
		if check == 'first':
			if dist < k and mmax > b[i + 1]:
				ans = -1
				break
		elif check == 'last':
			if dist < k and mmax > b[i]:
				ans = -1
				break
		if dist < k and mmax > max(b[i], b[i + 1]):
			ans = -1
			break
		if dist % k == 0:
			num = dist // k
			aa = num * x
			if mmax > max(b[i], b[i + 1]):
				bb = x + (dist - k) * y
				ans += min(aa, bb)
			else:
				bb = dist * y
				ans += min(aa, bb)
		elif dist < k:
			if mmax > max(b[i], b[i + 1]):
				ans = -1
				break
			else:
				ans += dist * y
		else:
			num = dist // k
			aa = num * x + (dist - num * k) * y
			if mmax > max(b[i], b[i + 1]):
				bb = x + (dist - k) * y
				ans += min(aa, bb)
			else:
				bb = dist * y
				ans += min(aa, bb)
	print(ans)
Solve()


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
arr = list(map(int, input().split()))
brr = list(map(int, input().split()))
used = [False for i in range(n + 1)]
f = True
res = 0
(old, mx, idx, ln) = (0, 0, 0, 0)

def calc():
	global old, mx, idx, ln, res, f, i
	if ln < k:
		if old > mx or i > mx:
			res = res + ln * y
		else:
			f = False
		return
	if ln % k > 0:
		res = res + ln % k * y
		ln = ln - ln % k
	if x <= y * k:
		res = res + ln // k * x
	elif old > mx or i > mx:
		res = res + ln * y
	else:
		res = res + (ln - k) * y + x
for i in brr:
	if used[i] == True:
		f = False
		break
	while idx < n:
		used[arr[idx]] = True
		if arr[idx] == i:
			idx = idx + 1
			break
		mx = max(mx, arr[idx])
		ln = ln + 1
		idx = idx + 1
	calc()
	(old, mx, ln) = (i, 0, 0)
while idx < n:
	mx = max(mx, arr[idx])
	ln = ln + 1
	idx = idx + 1
calc()
if f == False:
	print(-1)
else:
	print(res)


(n, m) = input().split(' ')
(n, m) = (int(n), int(m))
(x, k, y) = input().split(' ')
(x, k, y) = (int(x), int(k), int(y))
A = input().split(' ')
B = input().split(' ')
for i in range(n):
	A[i] = int(A[i])
for i in range(m):
	B[i] = int(B[i])
indexA = 0
indexB = 0
poss = 1
while indexB < m:
	while indexA < n and B[indexB] != A[indexA]:
		indexA += 1
	if indexA != n:
		B[indexB] = indexA
		indexB += 1
	else:
		indexB = m
		poss = 0
if 0 < B[0] < k and max(A[:B[0]]) > A[B[0]]:
	poss = 0
if 0 < n - 1 - B[m - 1] < k and max(A[B[m - 1] + 1:]) > A[B[m - 1]]:
	poss = 0
for i in range(1, m):
	if 0 < B[i] - B[i - 1] - 1 < k and max(A[B[i - 1] + 1:B[i]]) > max(A[B[i]], A[B[i - 1]]):
		poss = 0
if poss == 0:
	print(-1)
elif x / k > y:
	ans = 0
	if B[0] > 0:
		if max(A[:B[0]]) > A[B[0]]:
			ans += x + (B[0] - k) * y
		else:
			ans += B[0] * y
	if 0 < n - 1 - B[m - 1]:
		if max(A[B[m - 1] + 1:]) > A[B[m - 1]]:
			ans += x + (n - 1 - B[m - 1] - k) * y
		else:
			ans += (n - 1 - B[m - 1]) * y
	for i in range(1, m):
		if 0 < B[i] - B[i - 1] - 1:
			if max(A[B[i - 1] + 1:B[i]]) > max(A[B[i]], A[B[i - 1]]):
				ans += x + (B[i] - B[i - 1] - 1 - k) * y
			else:
				ans += (B[i] - B[i - 1] - 1) * y
	print(ans)
else:
	ans = int(B[0] / k) * x + B[0] % k * y + int((n - 1 - B[m - 1]) / k) * x + (n - 1 - B[m - 1]) % k * y
	for i in range(1, m):
		ans += int((B[i] - 1 - B[i - 1]) / k) * x + (B[i] - 1 - B[i - 1]) % k * y
	print(ans)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	(n, m) = mi()
	(x, k, y) = mi()
	a = li()
	b = li()
	x1 = []
	index_b = 0
	(cnt, mx) = (0, 0)
	ans = 0
	for i in range(n):
		if index_b < m and a[i] == b[index_b]:
			if cnt > 0:
				large = max(a[i], a[i - cnt - 1] if i - cnt - 1 >= 0 else 0)
				if large < mx:
					if cnt < k:
						print('-1')
						exit(0)
					ans += x + (cnt // k - 1) * min(x, y * k) + cnt % k * y
				else:
					ans += cnt // k * min(x, y * k) + cnt % k * y
			cnt = 0
			mx = 0
			index_b += 1
		else:
			cnt += 1
			mx = max(mx, a[i])
	if cnt > 0:
		large = a[n - cnt - 1] if n - cnt - 1 >= 0 else 0
		if large < mx:
			if cnt < k:
				print('-1')
				exit(0)
			ans += x + (cnt // k - 1) * min(x, y * k) + cnt % k * y
		else:
			ans += cnt // k * min(x, y * k) + cnt % k * y
	if index_b != m:
		print('-1')
		exit(0)
	print(ans)
if file:
	if path.exists('input1.txt'):
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


input = __import__('sys').stdin.readline

def cal(i, j):
	seg = j - i - 1
	tmp = 0
	if seg == 0:
		return 0
	mm = max(a[i + 1:j])
	mi = 0
	if 0 <= i < n:
		mi = a[i]
	if 0 <= j < n:
		mi = max(a[j], mi)
	if y * k <= x:
		if mm < mi:
			tmp = y * seg
		elif seg < k:
			print(-1)
			exit()
		else:
			tmp = (seg - k) * y + x
	elif mm < mi:
		tmp = seg % k * y + seg // k * x
	elif seg < k:
		print(-1)
		exit()
	else:
		tmp = seg % k * y + seg // k * x
	return tmp
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ab = {v: i for (i, v) in enumerate(a)}
ans = 0
prev = -1
for vv in b:
	if vv not in ab:
		print(-1)
		exit()
	i = ab[vv]
	if i < prev:
		print(-1)
		exit()
	ans += cal(prev, i)
	prev = i
ans += cal(prev, n)
print(ans)


def log_dec(func):

	def wrapper(*args, **kwargs):
		print('Called with values: ')
		print('args: ', args)
		print('kwargs: ', kwargs)
		result = func(*args, **kwargs)
		print('Result: ', result)
		return result
	return wrapper

def count_mnmx(seq, si, ei, lbn=-1, rbn=-1):
	lmr = max([lbn, rbn])
	mn = 0
	mx = 0
	for i in range(si, ei):
		if seq[i] > lmr:
			mx += 1
		if seq[i] < lmr:
			mn += 1
	return [mn, mx]

def calculate_minimum_mana(seq, si, ei, x, k, y, lbn=-1, rbn=-1):
	(minn, maxn) = count_mnmx(seq, si, ei, lbn, rbn)
	length = ei - si
	if minn == 0 and maxn == 0:
		return 0
	if maxn > 0 and length < k:
		return -1
	if x <= k * y:
		return length // k * x + length % k * y
	return (maxn > 0) * x + (length - k * (maxn > 0)) * y

def main():
	intifier = lambda x: int(x)
	(n, m) = list(map(intifier, input().split(' ')))
	(x, k, y) = list(map(lambda x: int(x), input().split(' ')))
	a = list(map(intifier, input().split(' ')))
	b = list(map(intifier, input().split(' ')))
	ia = [-1 for i in range(n + 1)]
	for (i, ai) in enumerate(a):
		ia[ai] = i
	mana = 0
	prev_s = 0
	for (indx, curr_s) in enumerate(b):
		if ia[prev_s] > ia[curr_s]:
			print(-1)
			return None
		lbn = prev_s
		rbn = curr_s if indx < m else -1
		si = ia[prev_s] + 1 if prev_s != 0 else 0
		ei = ia[curr_s] if curr_s != -1 else m
		tmp_mana = calculate_minimum_mana(a, si, ei, x, k, y, lbn, rbn)
		if tmp_mana < 0:
			print(-1)
			return None
		mana += tmp_mana
		prev_s = curr_s
	if ia[prev_s] < n - 1:
		tmp_mana = calculate_minimum_mana(a, ia[prev_s] + 1, n, x, k, y, prev_s, -1)
		if tmp_mana < 0:
			print(-1)
			return None
		mana += tmp_mana
	print(mana)
	return None
main()


(n, m) = list(map(int, input().split()))
(x, k, y) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
j = 0
to_kill = [True] * n
while i < n and j < m:
	if a[i] == b[j]:
		j += 1
		to_kill[i] = False
	i += 1
if j < m:
	print(-1)
	exit()
last = -1
ans = 0
for i in range(n + 1):
	if i == n or not to_kill[i]:
		if i - last > 1:
			cnt = i - last - 1
			strongest = max(a[last + 1:i])
			strongest_borders = 0
			if i < n:
				strongest_borders = a[i]
			if last >= 0:
				strongest_borders = max(strongest_borders, a[last])
			weak_count = 0
			for j in range(last + 1, i):
				if a[j] < strongest or a[j] < strongest_borders:
					weak_count += 1
			if cnt // k * k + weak_count < cnt or (strongest > strongest_borders and cnt < k):
				print(-1)
				exit()
			if k * y > x:
				ans += cnt // k * x
				if cnt % k != 0:
					ans += cnt % k * y
			else:
				rest = max(1 if strongest > strongest_borders else 0, cnt - weak_count)
				if rest % k != 0:
					rest = rest // k * k + k
				ans += rest // k * x
				ans += (cnt - rest) * y
		last = i
print(ans)


def solve(L1, L2, k, F, B):
	Fireball = F / k < B
	cost = 0
	L1.append(0)
	L2.append(0)
	L = 0
	pointer = 0
	for i in L2:
		R = i
		maxSoFar = 0
		numWar = 0
		while L1[pointer] != R:
			maxSoFar = max(maxSoFar, L1[pointer])
			numWar += 1
			pointer += 1
			if pointer >= len(L1):
				return -1
		if numWar < k and maxSoFar > L and (maxSoFar > R):
			return -1
		elif numWar < k:
			cost += B * numWar
		elif Fireball == True:
			cost += numWar // k * F + numWar % k * B
		elif maxSoFar > L and maxSoFar > R:
			cost += F + (numWar - k) * B
		else:
			cost += numWar * B
		pointer += 1
		L = R
	return cost
_ = input()
(F, k, B) = list(map(int, input().split(' ')))
L1 = list(map(int, input().split(' ')))
L2 = list(map(int, input().split(' ')))
print(solve(L1, L2, k, F, B))


import sys
from collections import defaultdict as dd
from collections import deque
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for x in input().split()]

def fi():
	return int(input())

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')
t = 1
while t > 0:
	t -= 1
	(n, m) = mi()
	(x, k, y) = mi()
	a = li()
	b = li()
	d = []
	d.append(-1)
	ff = {}
	flag = 0
	for i in range(n):
		ff[a[i]] = i
	for i in b:
		if i not in ff:
			flag = 1
			break
		d.append(ff[i])
	d.append(n)
	if d != sorted(d) or flag:
		print(-1)
		continue
	ans = 0
	flag = 0
	for i in range(len(d) - 1):
		l = d[i + 1] - d[i] - 1
		p = max(a[d[i] + 1:d[i + 1]]) if l > 0 else -1
		r = [a[d[i + 1]] if d[i + 1] != n else -1, a[d[i]] if d[i] != -1 else -1]
		r = max(r)
		if p > r and l < k:
			flag = 1
			break
		if p < r:
			if k * y < x:
				ans += l * y
			else:
				ans += l // k * x + l % k * y
		elif p > r:
			if k * y < x:
				ans += (l - k) * y + x
			else:
				ans += l // k * x + l % k * y
	print(ans if flag == 0 else -1)


from math import ceil

def func(values, left, right, x, k, y, left_val, right_val):
	copy = values[left + 1:right]
	if len(copy) == 0:
		return 0
	copy.sort()
	if len(copy) < k:
		if copy[-1] > max(left_val, right_val):
			return -1
		else:
			return len(copy) * y
	elif x <= k * y:
		return len(copy) // k * x + len(copy) % k * y
	elif copy[-1] > max(left_val, right_val):
		return x + y * (len(copy) - k)
	else:
		return y * len(copy)

def main():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	if m > n:
		print(-1)
	else:
		j = 0
		l = -1
		ans = 0
		for i in range(n):
			if j == m:
				break
			if s1[i] == s2[j]:
				j += 1
				if l == -1:
					left_val = -1
				else:
					left_val = s1[l]
				a = func(s1, l, i, x, k, y, left_val, s1[i])
				if a == -1:
					ans = -1
					break
				ans += a
				l = i
		if j < m or ans == -1:
			print(-1)
		else:
			a = func(s1, l, n, x, k, y, s1[l], -1)
			if a == -1:
				print(-1)
			else:
				ans += a
				print(ans)
main()


from math import floor

def Del(lpos, rpos, maxx):
	num = rpos - lpos + 1
	max_fire_ball = int(floor(num / k))
	min_berserk = num % k
	max_str = 0
	for i in range(lpos, rpos + 1):
		max_str = max(max_str, a[i])
	if num < k:
		if max_str > maxx:
			return -1
		else:
			return y * num
	used_mana = min_berserk * y
	num -= min_berserk
	if max_str < maxx:
		used_mana += min(num * y, max_fire_ball * x)
		return used_mana
	used_mana += min((num - k) * y, (max_fire_ball - 1) * x) + x
	return used_mana
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = [0] * (n + 1)
for i in range(n):
	pos[a[i]] = i
chk = [0] * (n + 1)
chk[b[0]] = 1
for i in range(1, m):
	chk[b[i]] = 1
	if pos[b[i]] < pos[b[i - 1]]:
		print(-1)
		exit()
ans = 0
if a[0] != b[0]:
	t = Del(0, pos[b[0]] - 1, b[0])
	if t == -1:
		print(-1)
		exit()
	ans += t
if a[n - 1] != b[m - 1]:
	t = Del(pos[b[m - 1]] + 1, n - 1, b[m - 1])
	if t == -1:
		print(-1)
		exit()
	ans += t
for i in range(1, m):
	t = Del(pos[b[i - 1]] + 1, pos[b[i]] - 1, max(b[i - 1], b[i]))
	if t == -1:
		print(-1)
		exit()
	ans += t
print(ans)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict, deque
from bisect import bisect_right, bisect_left
from io import BytesIO, IOBase
from copy import copy

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def inpt():
	return [int(k) for k in input().split()]

def check(x, k, y, sz, l, r, mx):
	res = 0
	if sz == 0:
		return 0
	if x <= k * y:
		if sz >= k:
			res += sz // k * x
			res += sz % k * y
		elif mx < l or mx < r:
			res += sz * y
		else:
			return -1
	elif mx < l or mx < r:
		res += sz * y
	elif sz >= k:
		res += x
		res += (sz - k) * y
	else:
		return -1
	return res

def main():
	(n, m) = map(int, input().split())
	(x, k, y) = map(int, input().split())
	ar = inpt()
	br = inpt()
	j = 0
	mx = 0
	lr = 0
	ans = 0
	sz = 0
	for i in range(n):
		if ar[i] == br[j]:
			val = check(x, k, y, sz, lr, ar[i], mx)
			if val == -1:
				print(-1)
				exit()
			ans += val
			sz = 0
			mx = 0
			lr = br[j]
			j += 1
			if j == m:
				break
		else:
			sz += 1
			mx = max(ar[i], mx)
	lr = ar[i]
	f = j
	mx = 0
	sz = 0
	for j in range(i + 1, n):
		mx = max(mx, ar[j])
		sz += 1
	v = check(x, k, y, sz, lr, 0, mx)
	if v == -1:
		print(-1)
		exit()
	ans += v
	if f == m:
		print(ans)
	else:
		print(-1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
a2 = [-1] * n
for i in range(n):
	a2[a[i] - 1] = i
for elem in b:
	c.append(a2[elem - 1])
c = [-1] + c + [n]
check = True
ans = 0
for i in range(len(c) - 1):
	if c[i] > c[i + 1]:
		check = False
		break
	i1 = c[i]
	i2 = c[i + 1]
	if i1 == -1:
		l = 0
	else:
		l = a[i1]
	if i2 == n:
		r = 0
	else:
		r = a[i2]
	d = i2 - i1 - 1
	maxx = 0
	for j in range(i1 + 1, i2):
		maxx = max(maxx, a[j])
	if d < k and maxx > max(l, r):
		check = False
		break
	else:
		ans += y * (d % k)
		d -= d % k
		if y * k >= x:
			ans += d // k * x
		elif maxx > max(l, r):
			d -= k
			ans += x
			ans += d * y
		else:
			ans += d * y
if check:
	print(ans)
else:
	print(-1)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [int(k) for k in input().split()]
b = [int(k) for k in input().split()]
j = 0
index = []
for i in range(n):
	if j == m:
		break
	if a[i] == b[j]:
		index.append(i)
		j += 1
if len(index) != m:
	print(-1)
else:
	ans = 0
	counter = 0
	for i in range(len(index)):
		if i == 0:
			mx = 0
			for j in range(0, index[i]):
				mx = max(mx, a[j])
			if mx < a[index[i]]:
				ans += min(index[i] // k * x + index[i] % k * y, index[i] * y)
			else:
				rem = index[i] - k
				if rem < 0:
					counter = 1
					break
				ans += min(rem // k * x + rem % k * y, rem * y)
				ans += x
			continue
		mx = 0
		for j in range(index[i - 1] + 1, index[i]):
			mx = max(mx, a[j])
		rem = index[i] - index[i - 1] - 1
		if mx < a[index[i]] or mx < a[index[i - 1]]:
			ans += min(rem // k * x + rem % k * y, rem * y)
		else:
			rem = rem - k
			if rem < 0:
				counter = 1
				break
			ans += min(rem // k * x + rem % k * y, rem * y)
			ans += x
	mx = 0
	for j in range(index[-1] + 1, n):
		mx = max(mx, a[j])
	rem = n - index[-1] - 1
	if mx < a[index[-1]]:
		ans += min(rem // k * x + rem % k * y, rem * y)
	else:
		rem = rem - k
		if rem < 0:
			counter = 1
		else:
			ans += min(rem // k * x + rem % k * y, rem * y)
			ans += x
	if counter:
		print(-1)
	else:
		print(ans)


inp = lambda : map(int, input().split(' '))
sum = 0
(n, m) = inp()
(x, k, y) = inp()
arr1 = list(inp())
arr2 = list(inp())
pos = []
arr1.insert(0, 0)
arr1.append(0)
arr2.insert(0, 0)
arr2.append(0)
j = 0
for i in range(n + 2):
	if arr1[i] == arr2[j]:
		pos.append(i)
		j += 1
if j != m + 2:
	print(-1)
else:
	for i in range(1, m + 2):
		pos1 = pos[i - 1]
		pos2 = pos[i]
		l = pos2 - (pos1 + 1)
		max_val = max(arr1[pos1], arr1[pos2])
		is_max = True
		for j in range(pos1 + 1, pos2):
			if arr1[j] > max_val:
				is_max = False
				break
		if is_max:
			sum += min(l * y, l // k * x + l % k * y)
		else:
			if k > l:
				print(-1)
				exit()
			sum += min((l - k) * y + x, l // k * x + l % k * y)
	print(sum)


def remove_section(s, x, k, y):
	if len(s) <= 2:
		return 0
	berserk = len(s) - 2
	m = max(s)
	for i in range(1, len(s) - 1):
		if s[i] == m:
			berserk -= 1
	fireball = (len(s) - 2) // k
	if k * fireball + berserk < len(s) - 2:
		return -1
	if k * y > x:
		return x * fireball + y * (len(s) - 2 - fireball * k)
	else:
		if berserk < len(s) - 2:
			return x + (len(s) - 2 - k) * y
		return y * (len(s) - 2)
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
a.insert(0, int(-1000000000.0))
a.append(int(-1000000000.0))
b = list(map(int, input().split()))
b.append(int(-1000000000.0))
ans = 0
(i, j) = (0, 0)
prev = 0
while i < len(b):
	flag = True
	prev = j
	while j < len(a):
		if a[j] == b[i]:
			flag = False
			break
		j += 1
	if flag:
		ans = -1
		break
	curr = remove_section(a[prev:j + 1], x, k, y)
	if curr == -1:
		ans = -1
		break
	ans += remove_section(a[prev:j + 1], x, k, y)
	i += 1
print(ans)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
(len_a, len_b) = mpint()
(x, k, y) = mpint()
a = list(mpint())
b = list(mpint())
i_love_fireball = x / k <= y

def main():
	i1 = i2 = 0
	pos = []
	while i1 < len_a and i2 < len_b:
		if a[i1] == b[i2]:
			pos.append(i1)
			i2 += 1
		i1 += 1
	if i2 != len_b:
		return -1
	assert len(pos) == len_b
	ans = 0
	left_power = left_idx = -1
	for i in range(len_b + 1):
		if i == len_b:
			right_idx = len_a
			right_power = -87
		else:
			right_idx = pos[i]
			right_power = a[right_idx]
		sub = a[left_idx + 1:right_idx]
		if not sub:
			left_idx = right_idx
			left_power = right_power
			continue
		am = len(sub)
		if am < k:
			if max(sub) > max(left_power, right_power):
				return -1
			ans += am * y
		elif i_love_fireball:
			(q, r) = divmod(am, k)
			ans += q * x + r * y
		elif max(sub) > max(left_power, right_power):
			(q, r) = (1, am - k)
			ans += q * x + r * y
		else:
			ans += am * y
		left_idx = right_idx
		left_power = right_power
	return ans
print(main())


def price(i, j, m):
	if j < i:
		return 0
	c = []
	num = j - i + 1
	for p in range(i, j + 1):
		if a[p] > m:
			c = [1]
			break
	if c == []:
		if num < k:
			return num * y
		else:
			u = num // k
			v = num % k
			if k * y <= x:
				return num * y
			else:
				return u * x + v * y
	elif num < k:
		return -1
	else:
		u = num // k
		v = num % k
		if k * y <= x:
			return (num - k) * y + x
		else:
			return u * x + v * y
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
d = dict()
for j in range(n):
	d[a[j]] = j
f = 0
for j in range(m - 1):
	if d[b[j + 1]] < d[b[j]]:
		f = -1
		break
if f == -1:
	print(-1)
else:
	p = -1
	j1 = 0
	ans = 0
	f = 0
	while j1 < m:
		if j1 == 0:
			res = price(p + 1, d[b[j1]] - 1, b[j1])
		else:
			res = price(p + 1, d[b[j1]] - 1, max(b[j1 - 1], b[j1]))
		if res == -1:
			f = -1
			break
		ans += res
		p = d[b[j1]]
		j1 += 1
	res = price(d[b[-1]] + 1, n - 1, b[-1])
	if res == -1:
		f = -1
	else:
		ans += res
	if f == -1:
		print(-1)
	else:
		print(ans)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = [0] * m
j = 0
for i in range(n):
	if j == m:
		break
	if a[i] == b[j]:
		c[j] = i + 1
		j += 1
if not j == m:
	print(-1)
	exit()
a.insert(0, 0)
a.append(0)
c.insert(0, 0)
c.append(n + 1)
ans = 0
for i in range(m + 1):
	if c[i + 1] - c[i] == 1:
		continue
	l = c[i + 1] - c[i] - 1
	s = 0
	t = max(a[c[i]], a[c[i + 1]])
	for j in range(c[i] + 1, c[i + 1]):
		if a[j] > t:
			s += 1
	if s == 0:
		ans += min(l * y, l // k * x + l % k * y)
	else:
		if k > l:
			print(-1)
			exit()
		ans += min((l - k) * y + x, l // k * x + l % k * y)
print(ans)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
where = [0] * n
for i in range(n):
	a[i] -= 1
	where[a[i]] = i
left = [-1]
b = list(map(int, input().split()))
for i in range(m):
	b[i] -= 1
	left.append(where[b[i]])
left.append(n)
ans = 0
for i in range(1, len(left)):
	if left[i - 1] > left[i]:
		print(-1)
		exit(0)
	mx = -1
	mx_idx = 0
	for j in range(max(0, left[i - 1]), min(n, left[i] + 1)):
		if a[j] > mx:
			mx = a[j]
			mx_idx = j
	l = left[i] - left[i - 1] - 1
	if l <= 0:
		continue
	segments = l // k
	remainder = l % k
	if mx_idx == left[i - 1] or mx_idx == left[i]:
		ans += min(l * y, segments * x + remainder * y)
	elif segments == 0:
		print(-1)
		exit(0)
	else:
		ans += min(x + (l - k) * y, segments * x + remainder * y)
print(ans)


import sys
inpy = [int(x) for x in sys.stdin.read().split()]
(n, m, x, k, y) = inpy[0:5]
(a, b) = (inpy[5:5 + n], inpy[5 + n:])
prei = -1
(i, j) = (0, 0)
res = 0

def remove(l, r):
	if l > r:
		return 0
	(lp, rp) = (a[l - 1] if l > 0 else 0, a[r + 1] if r + 1 < len(a) else 0)
	maxV = max(a[l:r + 1])
	res = None
	if maxV < max(lp, rp):
		res = (r - l + 1) * y
	if r - l + 1 >= k:
		if x / k > y:
			cur = x + (r - l + 1 - k) * y
		else:
			cur = (r - l + 1) // k * x + (r - l + 1) % k * y
		if res:
			res = min(res, cur)
		else:
			res = cur
	return res
while i < len(a) and j < len(b):
	if a[i] == b[j]:
		xx = remove(prei + 1, i - 1)
		if xx == None:
			break
		res += xx
		prei = i
		j += 1
	i += 1
if j == len(b):
	xx = remove(prei + 1, len(a) - 1)
	if xx == None:
		print(-1)
	else:
		print(res + xx)
else:
	print(-1)


import sys, math
import io, os
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from fractions import Fraction
mod = int(1000000000.0) + 7
(n, m) = mdata()
(x, k, y) = mdata()
a = mdata()
b = mdata()
ind = 0
m1 = 0
l = [b[0]]
l1 = [-1]
for i in range(n):
	if ind < m:
		if a[i] == b[ind]:
			l.append(m1)
			m1 = b[ind]
			l1.append(i)
			ind += 1
	m1 = max(m1, a[i])
l1.append(n)
l.append(m1)
if len(l1) != m + 2:
	out(-1)
	exit()
ans = 0
if Fraction(x, k) < Fraction(y, 1):
	for i in range(m + 1):
		t = l1[i + 1] - l1[i] - 1
		m1 = 0
		if i > 0:
			m1 = a[l1[i]]
		if i < m:
			m1 = max(m1, a[l1[i + 1]])
		if t < k:
			if l[i + 1] > m1:
				out(-1)
				exit()
			else:
				ans += y * t
		else:
			ans += t // k * x + t % k * y
else:
	for i in range(m + 1):
		t = l1[i + 1] - l1[i] - 1
		m1 = 0
		if i > 0:
			m1 = a[l1[i]]
		if i < m:
			m1 = max(m1, a[l1[i + 1]])
		if l[i + 1] > m1:
			if t < k:
				out(-1)
				exit()
			else:
				ans += x + (t - k) * y
		else:
			ans += t * y
out(ans)


def remove(alive_powers, warriors, x, k, y):
	if not warriors:
		return 0
	strongest = max(warriors)
	if len(warriors) < k:
		if strongest > max(alive_powers):
			return -1
		return len(warriors) * y
	if k * y < x:
		if strongest < max(alive_powers):
			return len(warriors) * y
		else:
			return x + y * (len(warriors) - k)
	return x * (len(warriors) // k) + y * (len(warriors) % k)

def mana_counter(n, m, x, k, y, a, b):
	mana = 0
	indexes = []
	cur_warrior_ind = 0
	for survivor in b:
		while a[cur_warrior_ind] != survivor:
			cur_warrior_ind += 1
			if cur_warrior_ind >= len(a):
				return -1
		indexes.append(cur_warrior_ind)
	alive_powers = [-1, b[0]]
	res = remove(alive_powers, a[:indexes[0]], x, k, y)
	if res < 0:
		return -1
	mana += res
	for i in range(1, len(indexes)):
		(alive_powers[0], alive_powers[1]) = (alive_powers[1], b[i])
		res = remove(alive_powers, a[indexes[i - 1] + 1:indexes[i]], x, k, y)
		if res < 0:
			return -1
		mana += res
	res = remove([b[-1], -1], a[indexes[-1] + 1:], x, k, y)
	if res < 0:
		return -1
	mana += res
	return mana
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
print(mana_counter(n, m, x, k, y, a, b))


import os
import sys
from io import BytesIO, IOBase
import threading
from bisect import bisect_right
from math import gcd, log
from collections import Counter

def main():
	for _ in range(1):
		(n, m) = map(int, input().split())
		(x, k, y) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		start = 0
		i1 = 0
		i2 = 0
		prev = -1
		ans = 0
		while i1 < m:
			while i2 < n and a[i2] != b[i1]:
				i2 += 1
			i1 += 1
			if i2 == n:
				print(-1)
				return
			if i2 == prev + 1:
				prev = i2
				continue
			mx = max(a[prev + 1:i2])
			sz = i2 - prev - 1
			if mx > max(a[prev], a[i2]):
				if sz < k:
					print(-1)
					return
				ans += sz % k * y
				ans += 1 * x
				ans += max(0, sz // k - 1) * min(x, k * y)
			else:
				a1 = sz // k * x + sz % k * y
				b1 = sz * y
				ans += min(a1, b1)
			prev = i2
		if i2 < n - 1:
			mx = max(a[i2 + 1:n])
			sz = n - 1 - i2
			if mx > min(a[i2], 1000000):
				if sz < k:
					print(-1)
					return
				ans += sz % k * y
				ans += 1 * x
				ans += max(0, sz // k - 1) * min(x, k * y)
			else:
				a1 = sz // k * x + sz % k * y
				b1 = sz * y
				ans += min(a1, b1)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


list_input = lambda : list(map(int, input().split()))
int_input = lambda : int(input())

def count_vals(l):
	d = {}
	for i in l:
		d[i] = d.get(i, 0) + 1
	return d

def get_delete_elements(a, b):
	j = 0
	elem = []
	for i in range(len(a)):
		if j == len(b):
			elem.append(i)
			continue
		if a[i] == b[j]:
			j += 1
		else:
			elem.append(i)
	if j != len(b):
		return -1
	return elem

def get_val(count, x, y, k, flag):
	a = count // k
	m = count % k
	if flag:
		if a == 0:
			return -1
		elif k * y <= x:
			return (count - k) * y + x
		else:
			return a * x + m * y
	else:
		if k * y <= x:
			return count * y
		return a * x + m * y
(n, m) = list_input()
(x, k, y) = list_input()
a = list_input()
b = list_input()
elem = get_delete_elements(a, b)
if elem == -1:
	print(-1)
else:
	(ans, i) = (0, 0)
	temp = 0
	while i < len(elem):
		if elem[i] == 0:
			p = -1
		else:
			p = a[elem[i] - 1]
		j = i + 1
		count = 1
		while j < len(elem) and elem[j] == elem[j - 1] + 1:
			j += 1
			count += 1
		if elem[j - 1] == len(a) - 1:
			q = -1
		else:
			q = a[elem[j - 1] + 1]
		m = max(p, q)
		if max(a[elem[i]:elem[j - 1] + 1]) > m:
			flag = 1
		else:
			flag = 0
		temp = get_val(count, x, y, k, flag)
		if temp == -1:
			break
		ans += temp
		i = j
	if temp == -1:
		print(-1)
	else:
		print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
left = 0
broke = False
mana = 0
for s in range(m):
	looking = b[s]
	arr1 = []
	maxsofar = 0
	found = False
	for j in range(left, n):
		if a[j] == looking:
			left = j + 1
			found = True
			break
		else:
			arr1.append(a[j])
			if a[j] > maxsofar:
				maxsofar = a[j]
	if len(arr1) >= k:
		if y * k <= x:
			lefty = looking
			righty = 0
			if s >= 1:
				righty = b[s - 1]
			if maxsofar < max(lefty, righty):
				mana += y * len(arr1)
			else:
				mana += y * (len(arr1) - k)
				mana += x
		else:
			rem = len(arr1) % k
			mana += y * rem
			mana += (len(arr1) - rem) // k * x
	else:
		lefty = looking
		righty = 0
		if s >= 1:
			righty = b[s - 1]
		if maxsofar < max(lefty, righty):
			mana += y * len(arr1)
		else:
			broke = True
			break
	if found == False:
		broke = True
		break
lengthrem = n - left
if lengthrem == 0:
	if broke == True:
		print(-1)
	else:
		print(mana)
else:
	maxsofar = 0
	for s in range(left, n):
		if a[s] > maxsofar:
			maxsofar = a[s]
	if lengthrem >= k:
		if y * k <= x:
			lefty = b[-1]
			if maxsofar < lefty:
				mana += y * lengthrem
			else:
				mana += y * (lengthrem - k)
				mana += x
		else:
			rem = lengthrem % k
			mana += y * rem
			mana += (lengthrem - rem) // k * x
	else:
		lefty = b[-1]
		if maxsofar < lefty:
			mana += y * lengthrem
		else:
			broke = True
	if broke == True:
		print(-1)
	else:
		print(mana)


import math
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
from collections import *
al = defaultdict(int)
m = list(map(int, input().split()))
z = []
for i in range(len(m)):
	z.append(m[i])
for i in range(len(z)):
	al[z[i]] = i
b = list(map(int, input().split()))
index = []
for i in range(len(b)):
	index.append(al[b[i]])
if index != sorted(index):
	print(-1)
	exit()
total = 0
for i in range(1, len(index)):
	l = index[i - 1]
	r = index[i]
	maxa = 0
	lent = r - l - 1
	for j in range(l + 1, r):
		maxa = max(maxa, z[j])
	if maxa > max(z[index[i]], z[index[i - 1]]):
		if lent < k:
			print(-1)
			exit()
		else:
			total += x
			lent -= k
			if lent < k:
				total += y * lent
			else:
				cost = min(x, y * k)
				grp = lent // k
				left = lent % k
				total += cost * grp + left * y
	else:
		cost = min(x, y * k)
		grp = lent // k
		left = lent % k
		total += cost * grp + left * y
maxa1 = 0
maxa2 = 0
for i in range(index[0]):
	maxa1 = max(maxa1, z[i])
for i in range(index[-1] + 1, len(z)):
	maxa2 = max(maxa2, z[i])
lent = index[0]
if maxa1 < z[index[0]]:
	cost = min(x, y * k)
	grp = lent // k
	left = lent % k
	total += cost * grp + left * y
elif index[0] < k:
	print(-1)
	exit()
else:
	lent = index[0]
	total += x
	lent -= k
	if lent < k:
		total += y * lent
	else:
		cost = min(x, y * k)
		grp = lent // k
		left = lent % k
		total += cost * grp + left * y
lent = len(z) - index[-1] - 1
if maxa2 < z[index[-1]]:
	cost = min(x, y * k)
	grp = lent // k
	left = lent % k
	total += cost * grp + left * y
elif lent < k:
	print(-1)
	exit()
else:
	total += x
	lent -= k
	if lent < k:
		total += y * lent
	else:
		cost = min(x, y * k)
		grp = lent // k
		left = lent % k
		total += cost * grp + left * y
print(total)


(n, m) = list(map(int, input().split()))
(x, k, y) = list(map(int, input().split()))
arr = list(map(int, input().split()))
to = list(map(int, input().split()))
index = 0
li = []
for i in range(n):
	if arr[i] == to[index]:
		li.append(i)
		index += 1
	if index == m:
		break
if index != m:
	print(-1)
	exit()
li = [-1] + li + [n]
myli = []
for i in range(m + 1):
	myli.append((li[i] + 2, li[i + 1]))
final = []
for i in myli:
	if i[0] <= i[1]:
		final.append(i)
arr = [-999] + arr + [-999]
ans = 0
for ele in final:
	l = ele[0]
	r = ele[1]
	le = r - l + 1
	m = max(arr[l:r + 1])
	if m >= arr[l - 1] and m >= arr[r + 1]:
		if le < k:
			print(-1)
			exit()
		if le == k:
			ans += x
			continue
		ans += min([x + (le - k) * y, le % k * y + le // k * x])
	else:
		ans += min([le * y, le % k * y + le // k * x])
print(ans)


def process(s, k, x, y):
	if s[0] == -1:
		t = s[1:]
		return process_left(t[::-1], k, x, y)
	if s[-1] == -2:
		return process_left(s[:-1], k, x, y)
	l = s[0]
	r = s[-1]
	c = s[1:-1]
	if len(c) == 0:
		return 0
	p = c[0]
	for cc in c:
		p = max(p, cc)
	if len(c) < k and l < p and (r < p):
		return -1
	cost = len(c) % k * y
	if int(len(c) / k) * x < (len(c) - len(c) % k) * y:
		cost += int(len(c) / k) * x
	elif l > p or r > p:
		cost += (len(c) - len(c) % k) * y
	else:
		cost += x
		cost += (len(c) - len(c) % k - k) * y
	return cost

def process_left(s, k, x, y):
	l = s[0]
	c = s[1:]
	if len(c) == 0:
		return 0
	p = c[0]
	for cc in c:
		p = max(p, cc)
	if len(c) < k and l < p:
		return -1
	cost = len(c) % k * y
	if int(len(c) / k) * x < (len(c) - len(c) % k) * y:
		cost += int(len(c) / k) * x
	elif l > p:
		cost += (len(c) - len(c) % k) * y
	else:
		cost += x
		cost += (len(c) - len(c) % k - k) * y
	return cost
(n, m) = map(int, input().split(' '))
(x, k, y) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
b = list(map(int, input().split(' ')))
i = 0
j = 0
found = 1
bi = 0
bj = 1
total = 0
dummy1 = [-1]
dummy2 = [-2]
a = dummy1 + a + dummy2
b = dummy1 + b + dummy2
while bi < len(b) - 1:
	while a[i] != b[bi]:
		i += 1
		if i == len(a):
			found = -1
			break
	j = i
	while a[j] != b[bj]:
		j += 1
		if j == len(a):
			found = -1
			break
	if found == -1:
		break
	s = a[i:j + 1]
	value = process(s, k, x, y)
	if value != -1:
		total += value
	else:
		found = -1
		break
	bi += 1
	bj += 1
if found == 1:
	print(total)
else:
	print(-1)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')

def solve(n, m, x, k, y, a, b):
	a = [0] + a + [0]
	b = [0] + b + [0]
	n += 2
	m += 2
	pairs = []
	idx = -1
	for i in range(m):
		try:
			idx = a.index(b[i], idx + 1)
		except ValueError:
			return -1
		pairs.append(idx)
	mx = float('inf')

	def kill(middle, l_val, r_val):
		mn = len(middle)
		if mn == 0:
			return 0
		best = mx
		middle.sort()
		for bs_count in range(mn + 1):
			if (mn - bs_count) % k > 0:
				continue
			if bs_count == mn:
				if max(l_val, r_val) > middle[-1]:
					best = min(best, bs_count * y)
				continue
			best = min(best, bs_count * y + x * (mn - bs_count) // k)
		return -1 if best == mx else best
	cnt = 0
	for i in range(len(pairs) - 1):
		res = kill(a[pairs[i] + 1:pairs[i + 1]], a[pairs[i]], a[pairs[i + 1]])
		if res == -1:
			return -1
		cnt += res
	return cnt

def main():
	(n, m) = ria()
	(x, k, y) = ria()
	a = ria()
	b = ria()
	wi(solve(n, m, x, k, y, a, b))
main()


def solve(n, m, x, k, y, a_arr, b_arr):
	cnt = 0
	cnt1 = 0
	prev_same = 0
	mana = 0
	start = b_arr[cnt1]
	end = b_arr[cnt1]
	while cnt < n and cnt1 < m:
		if a_arr[cnt] == b_arr[cnt1]:
			end = b_arr[cnt1]
			n_remove = cnt - prev_same
			max_elem = 0
			for i in range(prev_same, cnt):
				max_elem = max(a_arr[i], max_elem)
			if n_remove < k:
				if max_elem > start and max_elem > end:
					print(-1)
					return
				mana += y * n_remove
			else:
				if max_elem > start and max_elem > end:
					n_remove -= k
					mana += x
				if k * y > x:
					mana += x * (n_remove // k) + y * (n_remove % k)
				else:
					mana += y * n_remove
			start = end
			cnt1 += 1
			prev_same = cnt + 1
		cnt += 1
	if cnt1 < m:
		print(-1)
		return
	else:
		n_remove = n - prev_same
		max_elem = 0
		for i in range(prev_same, n):
			max_elem = max(max_elem, a_arr[i])
		if n_remove < k:
			if max_elem > start:
				print(-1)
				return
			mana += y * n_remove
		else:
			if max_elem > start:
				n_remove -= k
				mana += x
			if k * y > x:
				mana += x * (n_remove // k) + y * (n_remove % k)
			else:
				mana += y * n_remove
	print(mana)
	return
(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a_arr = list(map(int, input().split()))
b_arr = list(map(int, input().split()))
solve(n, m, x, k, y, a_arr, b_arr)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

def process(c, d):
	if c > d:
		return 0
	if c == 0:
		l = 0
	else:
		l = a[c - 1]
	if d == n - 1:
		r = 0
	else:
		r = a[d + 1]
	no = d - c + 1
	mx = a[c]
	for i in range(c + 1, d + 1):
		if a[i] > mx:
			mx = a[i]
	flag = 0
	if mx > l and mx > r:
		flag = 1
	if no < k and flag == 1:
		return -1
	ans = 0
	if x / k < y:
		ans += no // k * x
		ans += no % k * y
		return ans
	elif flag == 1:
		ans += x
		ans += (no - k) * y
		return ans
	else:
		ans = no * y
		return ans
if n == m:
	if a == b:
		print(0)
	else:
		print(-1)
else:
	i = 0
	j = 0
	cost = 0
	flag = 0
	if a[0] == b[0]:
		i += 1
		j += 1
		z = 0
	else:
		i += 1
		z = -1
	while i < n and j < m:
		if a[i] == b[j]:
			f = process(z + 1, i - 1)
			if f == -1:
				flag = 1
			cost += f
			z = i
			i += 1
			j += 1
		else:
			i += 1
	if a[n - 1] != b[m - 1]:
		f = process(z + 1, n - 1)
		if f == -1:
			flag = 1
		cost += f
	if flag == 0:
		print(cost)
	else:
		print(-1)


(n, m) = map(int, input().split())
(x, k, y) = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
pos = dict()
for (idx, val) in enumerate(a):
	pos[val] = idx

def process(l, r):
	ans = 0
	u = a[l] if l >= 0 else 0
	v = a[r] if r < n else 0
	cnt = 0
	mxm = max(u, v)
	for i in range(l + 1, r):
		if mxm < a[i]:
			cnt += 1
	dist = r - l - 1
	if cnt > 0 and dist < k:
		print(-1)
		exit(0)
	if y * k < x:
		if cnt > 0:
			dist -= k
			ans += x
		ans += dist * y
	else:
		ans = dist // k * x + dist % k * y
	return ans
ans = process(-1, pos[b[0]]) + process(pos[b[-1]], n)
for (u, v) in zip(b, b[1:]):
	if pos[u] > pos[v]:
		print(-1)
		exit(0)
	ans += process(pos[u], pos[v])
print(ans)


import itertools

def fast(A, B, x, y, k):
	result = 0
	Aset = set(A)
	Bset = set(B)
	if not Bset.issubset(Aset):
		return -1
	filtered = [False for _ in A]
	ctr = 0
	for i in range(len(A)):
		if A[i] == B[ctr]:
			filtered[i] = True
			ctr += 1
		if ctr >= len(B):
			break
	if ctr != len(B):
		return -1
	maxInRegions = []
	currMax = 0
	for i in range(len(filtered)):
		if filtered[i]:
			if currMax != 0:
				maxInRegions.append(currMax)
			currMax = 0
		else:
			currMax = max(currMax, A[i])
	if currMax != 0:
		maxInRegions.append(currMax)
	currMax = 0
	result = 0
	ctr = 0
	left = None
	lastTrueVal = 0
	for right in range(len(A)):
		if not filtered[right]:
			if left is None:
				left = right
			if currMax == 0:
				currMax = maxInRegions[ctr]
				ctr += 1
		else:
			if currMax > 0:
				numBetween = right - left
				candidates = []
				if A[right] >= currMax:
					candidates.append(numBetween * y)
				if left > 0 and A[left - 1] >= currMax:
					candidates.append(numBetween * y)
				if k == 1:
					candidates.append(numBetween * x)
					candidates.append((numBetween - 1) * y + x)
				elif numBetween >= k:
					candidates.append(numBetween % k * y + numBetween // k * x)
					candidates.append((numBetween - k) * y + x)
				if len(candidates) == 0:
					return -1
				result += min(candidates)
			lastTrueVal = A[right]
			left = None
			currMax = 0
	right = len(A)
	if ctr > 0 and left is not None:
		numBetween = right - left
		candidates = []
		if lastTrueVal >= currMax:
			candidates.append(numBetween * y)
		if left > 0 and A[left - 1] >= currMax:
			candidates.append(numBetween * y)
		if k == 1:
			candidates.append(numBetween * x)
			candidates.append((numBetween - 1) * y + x)
		elif numBetween >= k:
			candidates.append(numBetween % k * y + numBetween // k * x)
			candidates.append((numBetween - k) * y + x)
		if len(candidates) == 0:
			return -1
		result += min(candidates)
	return result

def test():
	(x, k, y) = (9, 1, 8)
	A = [8, 9, 5, 1]
	B = [8, 9, 1]
	f = fast(A, B, x, y, k)
	print(f)

def main():
	(n, m) = [int(_) for _ in input().split()]
	(x, k, y) = [int(_) for _ in input().split()]
	A = [int(_) for _ in input().split()]
	B = [int(_) for _ in input().split()]
	result = fast(A, B, x, y, k)
	print(result)
main()


def solve(A, B, fireball_const_range, berserk_cost):
	(fireball_cost, fireball_range) = fireball_const_range
	(N, M) = (len(A), len(B))
	should_keep = set(B)
	fireball_more_expensive = berserk_cost * fireball_range < fireball_cost
	(i, j) = (0, 0)
	while i < N and j < M:
		if A[i] == B[j]:
			j += 1
		i += 1
	if j != M:
		return -1

	def delete_interval_min_cost(i, j):
		assert i < j
		if i + 1 == j:
			return 0
		left_elem = A[i] if i >= 0 else float('-inf')
		right_elem = A[j] if j < N else float('-inf')
		size = j - i - 1
		max_elem = max(A[i + 1:j])
		can_use_berserk = left_elem > max_elem or right_elem > max_elem
		if size < fireball_range and (not can_use_berserk):
			return -1
		elif size < fireball_range and can_use_berserk:
			return size * berserk_cost
		elif fireball_more_expensive and can_use_berserk:
			return size * berserk_cost
		elif fireball_more_expensive and (not can_use_berserk):
			one_fireball_cost = fireball_cost
			remaining_elems = size - fireball_range
			return one_fireball_cost + remaining_elems * berserk_cost
		elif size >= fireball_range:
			fireball_count = size // fireball_range
			berserk_count = size % fireball_range
			return fireball_count * fireball_cost + berserk_count * berserk_cost
		else:
			raise ValueError('Unhandled case')
	ans = 0
	prev_start = -1
	i = 0
	while i < N:
		if A[i] in should_keep:
			res = delete_interval_min_cost(prev_start, i)
			if res < 0:
				return -1
			ans += res
			prev_start = i
		i += 1
	if A[-1] not in should_keep:
		res = delete_interval_min_cost(prev_start, N)
		if res < 0:
			return -1
		ans += res
	return ans

def main():
	(N, M) = list(map(int, input().split()))
	(X, K, Y) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ans = solve(A, B, (X, K), Y)
	print(ans)
main()