#include <bits/stdc++.h>
using namespace std;
namespace cp {
const long long INF = 9223372036854775807;
const int MOD = 1e9 + 7;
string ts(int n) { return to_string(n); }
string ts(double n) { return to_string(n); }
string ts(long double n) { return to_string(n); }
string ts(long long n) { return to_string(n); }
string ts(char c) { return to_string(c); }
string ts(bool b) { return b ? "true" : "false"; }
string ts(string s) { return s; }
template <typename T, typename V>
string ts(pair<T, V> p) {
  return "{" + ts(p.first) + ", " + ts(p.second) + "}";
}
template <typename T>
string ts(T arr[], int len) {
  ostringstream oss;
  oss << "[";
  string delim = "";
  for (int i = 0; i < len; i++) {
    oss << delim << ts(arr[i]);
    delim = ", ";
  }
  oss << "]";
  return oss.str();
}
template <typename Container>
string ts(const Container &v) {
  ostringstream oss;
  oss << "[";
  string delim = "";
  for (const auto &x : v) {
    oss << delim << ts(x);
    delim = ", ";
  }
  oss << "]";
  return oss.str();
}
template <typename T, typename V>
string ts(map<T, V> m) {
  ostringstream oss;
  oss << "[";
  string delim = "";
  for (pair<T, V> p : m) {
    oss << delim;
    oss << "{" << p.first << ": " << p.second << "}";
    delim = ", ";
  }
  oss << "]";
  return oss.str();
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
  size_t operator()(pair<uint64_t, uint64_t> &x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM) ^
           (splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};
void setI(string s) { freopen(s.c_str(), "r", stdin); }
void setO(string s) { freopen(s.c_str(), "w", stdout); }
void setIO(string s1, string s2) {
  setI(s1);
  setO(s2);
}
void setUsacoIO(string s) { setIO(s + ".in", s + ".out"); }
}  // namespace cp
using namespace cp;
vector<int> a;
long long x, y, range;
long long getCost2(int l, int r) {
  int n = a.size();
  long long k = range;
  long long res = 0;
  bool canDel = false;
  int mx = *max_element(a.begin() + l, a.begin() + r + 1);
  int len = r - l + 1;
  if (l - 1 >= 0 && a[l - 1] > mx) canDel = true;
  if (r + 1 < n && a[r + 1] > mx) canDel = true;
  if (len < k && !canDel) return -1;
  int need = len % k;
  res += need * y;
  len -= need;
  if (y * k >= x) {
    res += len / k * x;
  } else if (canDel) {
    res += len * y;
  } else {
    res += (len - k) * y + x;
  }
  return res;
}
long long getCost1(int l, int r) {
  int n = a.size();
  long long cost = INF;
  int maxOnSeg = -1;
  for (int i = l; i <= r; i++) maxOnSeg = max(maxOnSeg, a[i]);
  long long numKilled = (r - l + 1) - range;
  if (numKilled > 0) {
    cost = min(cost, numKilled * y + x);
  }
  if ((l - 1 >= 0 && a[l - 1] > maxOnSeg) ||
      (r + 1 < n && a[r + 1] > maxOnSeg)) {
    cost = min(cost, (long long)(r - l + 1) * y);
    long long fireCost = (r - l + 1) / range * x;
    long long killCost = (r - l + 1) % range * y;
    cost = min(cost, (long long)fireCost + killCost);
  } else {
    if ((r - l + 1) % range == 0) {
      cost = min(cost, (long long)(r - l + 1) / range * x);
    }
  }
  if (cost == INF) {
    return -1;
  }
  return cost;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  cin >> x >> range >> y;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int b[m];
  for (int i = 0; i < m; i++) cin >> b[i];
  bool keep[n];
  memset(keep, 0, sizeof(keep));
  int i = 0;
  int j = 0;
  while (i < n && j < m) {
    while (a[i] != b[j] && i + 1 < n) {
      i++;
    }
    if (a[i] == b[j]) {
      keep[i] = 1;
      i++;
      j++;
    } else {
      cout << "-1\n";
      return 0;
    }
  }
  if (j != m) {
    cout << "-1\n";
    return 0;
  }
  long long totalCost = 0;
  for (int l = 0; l < n; l++) {
    while (l < n && keep[l]) {
      l++;
    }
    if (l == n) {
      break;
    }
    int r = l;
    while (r + 1 < n && !keep[r + 1]) {
      r++;
    }
    long long cost = getCost2(l, r);
    if (cost == -1) {
      cout << "-1\n";
      return 0;
    }
    totalCost += cost;
    l = r;
  }
  cout << totalCost << endl;
  return 0;
}

### Prompt

Develop a solution in cpp to the problem described below:

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;
namespace cp {
const long long INF = 9223372036854775807;
const int MOD = 1e9 + 7;
string ts(int n) { return to_string(n); }
string ts(double n) { return to_string(n); }
string ts(long double n) { return to_string(n); }
string ts(long long n) { return to_string(n); }
string ts(char c) { return to_string(c); }
string ts(bool b) { return b ? "true" : "false"; }
string ts(string s) { return s; }
template <typename T, typename V>
string ts(pair<T, V> p) {
  return "{" + ts(p.first) + ", " + ts(p.second) + "}";
}
template <typename T>
string ts(T arr[], int len) {
  ostringstream oss;
  oss << "[";
  string delim = "";
  for (int i = 0; i < len; i++) {
    oss << delim << ts(arr[i]);
    delim = ", ";
  }
  oss << "]";
  return oss.str();
}
template <typename Container>
string ts(const Container &v) {
  ostringstream oss;
  oss << "[";
  string delim = "";
  for (const auto &x : v) {
    oss << delim << ts(x);
    delim = ", ";
  }
  oss << "]";
  return oss.str();
}
template <typename T, typename V>
string ts(map<T, V> m) {
  ostringstream oss;
  oss << "[";
  string delim = "";
  for (pair<T, V> p : m) {
    oss << delim;
    oss << "{" << p.first << ": " << p.second << "}";
    delim = ", ";
  }
  oss << "]";
  return oss.str();
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
  size_t operator()(pair<uint64_t, uint64_t> &x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x.first + FIXED_RANDOM) ^
           (splitmix64(x.second + FIXED_RANDOM) >> 1);
  }
};
void setI(string s) { freopen(s.c_str(), "r", stdin); }
void setO(string s) { freopen(s.c_str(), "w", stdout); }
void setIO(string s1, string s2) {
  setI(s1);
  setO(s2);
}
void setUsacoIO(string s) { setIO(s + ".in", s + ".out"); }
}  // namespace cp
using namespace cp;
vector<int> a;
long long x, y, range;
long long getCost2(int l, int r) {
  int n = a.size();
  long long k = range;
  long long res = 0;
  bool canDel = false;
  int mx = *max_element(a.begin() + l, a.begin() + r + 1);
  int len = r - l + 1;
  if (l - 1 >= 0 && a[l - 1] > mx) canDel = true;
  if (r + 1 < n && a[r + 1] > mx) canDel = true;
  if (len < k && !canDel) return -1;
  int need = len % k;
  res += need * y;
  len -= need;
  if (y * k >= x) {
    res += len / k * x;
  } else if (canDel) {
    res += len * y;
  } else {
    res += (len - k) * y + x;
  }
  return res;
}
long long getCost1(int l, int r) {
  int n = a.size();
  long long cost = INF;
  int maxOnSeg = -1;
  for (int i = l; i <= r; i++) maxOnSeg = max(maxOnSeg, a[i]);
  long long numKilled = (r - l + 1) - range;
  if (numKilled > 0) {
    cost = min(cost, numKilled * y + x);
  }
  if ((l - 1 >= 0 && a[l - 1] > maxOnSeg) ||
      (r + 1 < n && a[r + 1] > maxOnSeg)) {
    cost = min(cost, (long long)(r - l + 1) * y);
    long long fireCost = (r - l + 1) / range * x;
    long long killCost = (r - l + 1) % range * y;
    cost = min(cost, (long long)fireCost + killCost);
  } else {
    if ((r - l + 1) % range == 0) {
      cost = min(cost, (long long)(r - l + 1) / range * x);
    }
  }
  if (cost == INF) {
    return -1;
  }
  return cost;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  cin >> x >> range >> y;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int b[m];
  for (int i = 0; i < m; i++) cin >> b[i];
  bool keep[n];
  memset(keep, 0, sizeof(keep));
  int i = 0;
  int j = 0;
  while (i < n && j < m) {
    while (a[i] != b[j] && i + 1 < n) {
      i++;
    }
    if (a[i] == b[j]) {
      keep[i] = 1;
      i++;
      j++;
    } else {
      cout << "-1\n";
      return 0;
    }
  }
  if (j != m) {
    cout << "-1\n";
    return 0;
  }
  long long totalCost = 0;
  for (int l = 0; l < n; l++) {
    while (l < n && keep[l]) {
      l++;
    }
    if (l == n) {
      break;
    }
    int r = l;
    while (r + 1 < n && !keep[r + 1]) {
      r++;
    }
    long long cost = getCost2(l, r);
    if (cost == -1) {
      cout << "-1\n";
      return 0;
    }
    totalCost += cost;
    l = r;
  }
  cout << totalCost << endl;
  return 0;
}

```