#include <bits/stdc++.h>
using namespace std;
long long zero = 0;
long long one = 1;
long long MAX_SIZE_5 = 100005;
long long MAX_SIZE_6 = 1000005;
long long max_ll = LLONG_MAX;
long long min_ll = LLONG_MIN;
int max_int = INT_MAX;
int min_int = INT_MIN;
long long mod = 1000000007;
long long my_pow(long long a, long long b, long long m = mod) {
  if (b == 0) {
    return 1 % m;
  }
  if (b == 1) {
    return a % m;
  }
  long long temp = my_pow(a, b / 2, m);
  if (b % 2 == 0) {
    return (temp * temp) % m;
  } else {
    return (((temp * temp) % m) * a) % m;
  }
}
long long mod_inv(long long x, long long m = mod) {
  return my_pow(x, m - 2, m);
}
long long n, m;
long long x, k, y;
vector<long long> a;
vector<long long> b;
vector<long long> where_a;
vector<bool> done;
long long get_cost(long long i1, long long i2) {
  if (i1 > i2) return 0;
  long long ans = -1;
  long long num = i2 - i1 + 1;
  long long maxi = 0;
  for (int i = i1; i <= i2; i++) maxi = max(a[i], maxi);
  long long prev = -max_ll;
  long long next = -max_ll;
  if (i1 > 0) prev = a[i1 - 1];
  if (i2 < n - 1) next = a[i2 + 1];
  if (maxi < prev || maxi < next) {
    long long temp1 = num / k;
    long long temp2 = num % k;
    ans = temp1 * (min(x, y * k)) + temp2 * y;
  } else {
    if (num < k)
      ans = -1;
    else {
      ans = x;
      num -= k;
      long long temp1 = num / k;
      long long temp2 = num % k;
      ans += temp1 * (min(x, y * k)) + temp2 * y;
    }
  }
  return ans;
}
void solve() {
  cin >> n >> m;
  cin >> x >> k >> y;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  b.resize(m);
  for (int i = 0; i < m; i++) cin >> b[i];
  where_a.resize(n + 1);
  for (int i = 0; i < n; i++) {
    where_a[a[i]] = i;
  }
  done.resize(n + 1, false);
  bool ok = true;
  long long ans = 0;
  long long start_index = where_a[b[0]];
  for (int i = 0; i <= start_index; i++) {
    if (done[a[i]]) {
      ok = false;
      break;
    } else {
      done[a[i]] = true;
    }
  }
  long long temp1 = -1, temp2 = -1;
  if (ok) temp1 = get_cost(0, start_index - 1);
  if (temp1 == -1)
    ok = false;
  else
    ans += temp1;
  if (ok) {
    for (int i = 1; i < m; i++) {
      long long index1 = where_a[b[i - 1]];
      long long index2 = where_a[b[i]];
      if (index2 <= index1) {
        ok = false;
        break;
      } else {
        for (int i = index1 + 1; i <= index2; i++) {
          if (done[a[i]]) {
            ok = false;
            break;
          } else {
            done[a[i]] = true;
          }
        }
        if (!ok) break;
        long long temp = get_cost(index1 + 1, index2 - 1);
        if (temp == -1) {
          ok = false;
          break;
        } else {
          ans += temp;
        }
      }
    }
  }
  long long end_index = where_a[b[m - 1]];
  for (int i = end_index + 1; i < n; i++) {
    if (done[a[i]]) {
      ok = false;
      break;
    } else {
      done[a[i]] = true;
    }
  }
  if (ok) temp2 = get_cost(end_index + 1, n - 1);
  if (temp2 == -1)
    ok = false;
  else
    ans += temp2;
  if (ok)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

### Prompt

Please create a solution in cpp to the following problem:

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: 

  1. Fireball: you spend x mana and destroy exactly k consecutive warriors; 
  2. 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, ..., a_n into b_1, b_2, ..., 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 ≤ n, m ≤ 2 ⋅ 10^5) — the length of sequence a and the length of sequence b respectively.

The second line contains three integers x, k, y (1 ≤ x, y, ≤ 10^9; 1 ≤ k ≤ 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, ..., a_n (1 ≤ a_i ≤ n). It is guaranteed that all integers a_i are pairwise distinct.

The fourth line contains m integers b_1, b_2, ..., b_m (1 ≤ b_i ≤ 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, ..., a_n into b_1, b_2, ..., 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

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long zero = 0;
long long one = 1;
long long MAX_SIZE_5 = 100005;
long long MAX_SIZE_6 = 1000005;
long long max_ll = LLONG_MAX;
long long min_ll = LLONG_MIN;
int max_int = INT_MAX;
int min_int = INT_MIN;
long long mod = 1000000007;
long long my_pow(long long a, long long b, long long m = mod) {
  if (b == 0) {
    return 1 % m;
  }
  if (b == 1) {
    return a % m;
  }
  long long temp = my_pow(a, b / 2, m);
  if (b % 2 == 0) {
    return (temp * temp) % m;
  } else {
    return (((temp * temp) % m) * a) % m;
  }
}
long long mod_inv(long long x, long long m = mod) {
  return my_pow(x, m - 2, m);
}
long long n, m;
long long x, k, y;
vector<long long> a;
vector<long long> b;
vector<long long> where_a;
vector<bool> done;
long long get_cost(long long i1, long long i2) {
  if (i1 > i2) return 0;
  long long ans = -1;
  long long num = i2 - i1 + 1;
  long long maxi = 0;
  for (int i = i1; i <= i2; i++) maxi = max(a[i], maxi);
  long long prev = -max_ll;
  long long next = -max_ll;
  if (i1 > 0) prev = a[i1 - 1];
  if (i2 < n - 1) next = a[i2 + 1];
  if (maxi < prev || maxi < next) {
    long long temp1 = num / k;
    long long temp2 = num % k;
    ans = temp1 * (min(x, y * k)) + temp2 * y;
  } else {
    if (num < k)
      ans = -1;
    else {
      ans = x;
      num -= k;
      long long temp1 = num / k;
      long long temp2 = num % k;
      ans += temp1 * (min(x, y * k)) + temp2 * y;
    }
  }
  return ans;
}
void solve() {
  cin >> n >> m;
  cin >> x >> k >> y;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  b.resize(m);
  for (int i = 0; i < m; i++) cin >> b[i];
  where_a.resize(n + 1);
  for (int i = 0; i < n; i++) {
    where_a[a[i]] = i;
  }
  done.resize(n + 1, false);
  bool ok = true;
  long long ans = 0;
  long long start_index = where_a[b[0]];
  for (int i = 0; i <= start_index; i++) {
    if (done[a[i]]) {
      ok = false;
      break;
    } else {
      done[a[i]] = true;
    }
  }
  long long temp1 = -1, temp2 = -1;
  if (ok) temp1 = get_cost(0, start_index - 1);
  if (temp1 == -1)
    ok = false;
  else
    ans += temp1;
  if (ok) {
    for (int i = 1; i < m; i++) {
      long long index1 = where_a[b[i - 1]];
      long long index2 = where_a[b[i]];
      if (index2 <= index1) {
        ok = false;
        break;
      } else {
        for (int i = index1 + 1; i <= index2; i++) {
          if (done[a[i]]) {
            ok = false;
            break;
          } else {
            done[a[i]] = true;
          }
        }
        if (!ok) break;
        long long temp = get_cost(index1 + 1, index2 - 1);
        if (temp == -1) {
          ok = false;
          break;
        } else {
          ans += temp;
        }
      }
    }
  }
  long long end_index = where_a[b[m - 1]];
  for (int i = end_index + 1; i < n; i++) {
    if (done[a[i]]) {
      ok = false;
      break;
    } else {
      done[a[i]] = true;
    }
  }
  if (ok) temp2 = get_cost(end_index + 1, n - 1);
  if (temp2 == -1)
    ok = false;
  else
    ans += temp2;
  if (ok)
    cout << ans << endl;
  else
    cout << -1 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}

```