Problem: Little W and Little P decided to send letters to each other regarding the most important events during a day. There are n events during a day: at time moment t_i something happens to the person p_i (p_i is either W or P, denoting Little W and Little P, respectively), so he needs to immediately send a letter to the other person. They can send a letter using one of the two ways:

  * Ask Friendly O to deliver the letter directly. Friendly O takes d acorns for each letter.
  * Leave the letter at Wise R's den. Wise R values free space, so he takes c ⋅ T acorns for storing a letter for a time segment of length T. The recipient can take a letter from Wise R either when he leaves his own letter at Wise R's den, or at time moment t_{n + 1}, when everybody comes to Wise R for a tea. It is not possible to take a letter from Wise R's den at other time moments. The friends can store as many letters at Wise R's den as they want, paying for each one separately. 



Help the friends determine the minimum possible total cost of sending all letters.

Input

The first line contains three integers n, c, d (1 ≤ n ≤ 10^5, 1 ≤ c ≤ 10^2, 1 ≤ d ≤ 10^8) — the number of letters, the cost of storing a letter for one time unit at Wise R's den and the cost of delivering a letter via Friendly O.

The next n describe the events. The i-th of them contains an integer t_i and a character p_i (0 ≤ t_i ≤ 10^6, p_i is either W or P) — the time the i-th event happens and the person the event happens to.

The last line contains a single integer t_{n + 1} (0 ≤ t_{n+1} ≤ 10^6) — the time when everybody comes to Wise R for a tea and takes all remaining letters. 

It is guaranteed that t_i < t_{i + 1} for all i from 1 to n.

Output

Print a single integer — the minimum possible cost of delivery of all letters.

Examples

Input


5 1 4
0 P
1 W
3 P
5 P
8 P
10


Output


16


Input


10 10 94
17 W
20 W
28 W
48 W
51 P
52 W
56 W
62 P
75 P
78 P
87


Output


916

Note

One of optimal solutions in the first example:

  * At time moment 0 Little P leaves the letter at Wise R's den.
  * At time moment 1 Little W leaves his letter at Wise R's den and takes Little P's letter. This letter is at the den from time moment 0 to time moment 1, it costs 1 acorn.
  * At time moment 3 Little P sends his letter via Friendly O, it costs 4 acorns.
  * At time moment 5 Little P leaves his letter at the den, receiving Little W's letter which storage costs 4 acorns.
  * At time moment 8 Little P leaves one more letter at the den.
  * At time moment 10 Little W comes to the den for a tea and receives the two letters, paying 5 and 2 acorns.



The total cost of delivery is thus 1 + 4 + 4 + 5 + 2 = 16 acorns.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int maxn = 100002;
struct vec {
  long long x, y;
  vec() {}
  vec(long long x, long long y) : x(x), y(y) {}
  vec operator-(const vec &v) const { return vec(x - v.x, y - v.y); }
  long long operator*(const vec &v) const { return x * v.y - y * v.x; }
};
int p[maxn];
int t[maxn];
long long sum[maxn][2];
int cnt[maxn][2];
long long dp[maxn];
long long mindp[maxn][2];
vec ord[maxn][2];
int top[2], cur[2];
int n, c, d;
int main() {
  scanf("%d%d%d", &n, &c, &d);
  for (int i = 1; i <= n; i++) {
    char c;
    scanf("%d %c", &t[i], &c);
    if (c == 'P') p[i] = 1;
  }
  scanf("%d", &t[n + 1]);
  for (int i = n; i >= 1; i--) {
    cnt[i][0] = cnt[i + 1][0];
    cnt[i][1] = cnt[i + 1][1];
    sum[i][0] = sum[i + 1][0];
    sum[i][1] = sum[i + 1][1];
    cnt[i][p[i]]++;
    sum[i][p[i]] += t[n + 1] - t[i];
  }
  int pos = n + 1;
  while (pos - 1 >= 1 && c * (t[n + 1] - t[pos - 1]) < d) pos--;
  for (int i = 1; i <= n; i++) {
    if (i >= pos)
      dp[i] = c * sum[i][p[i]] + (long long)d * cnt[i][!p[i]];
    else
      dp[i] = c * sum[pos][p[i]] + c * (t[n + 1] - t[i]) +
              (long long)d * (cnt[i + 1][p[i]] - cnt[pos][p[i]]) +
              (long long)d * cnt[i][!p[i]];
  }
  for (int i = 1; i <= n + 1; i++) {
    mindp[i][0] = mindp[i][1] = 1e18;
  }
  cur[0] = cur[1] = top[0] = top[1] = 1;
  long long ans = (long long)n * d;
  for (int i = n; i >= 1; i--) {
    mindp[i][0] = min(mindp[i][0], mindp[i + 1][0]);
    mindp[i][1] = min(mindp[i][1], mindp[i + 1][1]);
    dp[i] = min(dp[i], mindp[i][!p[i]] - c * t[i] +
                           (long long)d * (cnt[i + 1][p[i]] + cnt[i][!p[i]]));
    vec v(1, c * cnt[i][p[i]]);
    while (cur[!p[i]] < top[!p[i]] &&
           v * ord[cur[!p[i]] + 1][!p[i]] < v * ord[cur[!p[i]]][!p[i]])
      cur[!p[i]]++;
    dp[i] = min(dp[i], v * ord[cur[!p[i]]][!p[i]] + c * sum[i][p[i]] +
                           (long long)d * cnt[i][!p[i]]);
    ans = min(ans, (long long)(i - 1) * d + dp[i]);
    v = vec(t[n + 1] - t[i],
            dp[i] - c * sum[i][!p[i]] +
                (long long)c * cnt[i][!p[i]] * (t[n + 1] - t[i]) -
                (long long)d * cnt[i][p[i]]);
    while (top[p[i]] > 1 && (ord[top[p[i]]][p[i]] - ord[top[p[i]] - 1][p[i]]) *
                                    (v - ord[top[p[i]]][p[i]]) <
                                0)
      top[p[i]]--;
    ord[++top[p[i]]][p[i]] = v;
    cur[p[i]] = min(cur[p[i]], top[p[i]]);
    while (pos - 1 >= 1 && c * (t[i] - t[pos - 1]) < d) pos--;
    mindp[pos - 1][p[i]] =
        min(mindp[pos - 1][p[i]],
            dp[i] +
                c * (sum[pos][!p[i]] - sum[i][!p[i]] -
                     (long long)(cnt[pos][!p[i]] - cnt[i][!p[i]]) *
                         (t[n + 1] - t[i]) +
                     t[i]) +
                (long long)d * (-cnt[pos][!p[i]] - cnt[i][p[i]]));
  }
  printf("%lld", ans);
  return 0;
}