Problem: Training is indispensable for achieving good results at ICPC. Rabbit wants to win at ICPC, so he decided to practice today as well.

Today's training is to improve reflexes and memory by performing whac-a-mole many times. I want to hit the moles that come out one after another and get as many points as possible.

The places where moles may appear are lined up in a straight line, and the coordinates are determined by the distance from the reference point. As the rabbit continued his training for a while, he noticed that the place and time when the moles appeared were always the same. Rabbit decided to record all the information and analyze it with a computer.

In order to hit the mole, after moving the hand to the position where the mole appears, it is necessary to hit the mole exactly at the timing when the mole appears. If you hit the mole well, you can get points according to the mole. The action of hitting the mole can be done in an instant, but there is a limit to the speed at which the hand can be moved. Rabbits can use both their left and right hands to hit the moles. The left and right hands can be moved independently, but the left hand must always be in a position with smaller coordinates than the right hand. I would like to find out how many points can be obtained at the maximum under such conditions.



Input


NV X Left X Right
X1 T1 P1
...
XN TN PN


N is the number of moles that come out, V is the maximum speed at which the hand can be moved, and XLeft and XRight are the coordinates of the initial positions of the left and right hands, respectively. Xi, Ti, and Pi are the coordinates of the position where the mole appears, the time from the start of the game to the appearance, and the points obtained when hitting, respectively.

1 ≤ N ≤ 3,000, 1 ≤ V ≤ 10,000, 1 ≤ XLeft <XRight ≤ 100,000, 1 ≤ X1 ≤ X2 ≤ ... ≤ XN ≤ 100,000, 1 ≤ Ti ≤ 100,000, 1 ≤ Pi ≤ 100,000. The same set as (Xi, Ti) does not appear multiple times.

Output

Output the maximum point at which the rabbit can be obtained on one line.

Examples

Input

3 10 150 250
100 20 123
201 10 67
202 10 45


Output

190


Input

1 7 20 90
55 5 73


Output

73


Input

10 2 1000 2000
400 300 1
600 200 1
700 800 1
700 500 1
900 600 1
1000 700 1
1300 900 1
1400 400 1
1500 1000 1
2000 100 1


Output

10

Solution (in CPP):

Solution:
#define NDEBUG
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;


template<class T> struct PrimalDual {
  struct Edge {
    int to, rev;
    T cap, cost;
  };
  const int n;
  const T inf = numeric_limits<T>::max();
  VV<Edge> g;
  V<T> pot, dist;
  V<> pv, pe;
  PrimalDual(int n) : n(n), g(n), pot(n), dist(n), pv(n), pe(n) {}
  void add_edge(int from, int to, T cap, T cost) {
    assert(from != to);
    assert(cap >= 0);
    assert(cost >= 0);
    g[from].emplace_back(Edge{to, (int) g[to].size(), cap, cost});
    g[to].emplace_back(Edge{from, (int) g[from].size() - 1, 0, -cost});
  }
  void dijkstra(int s) {
    using P = pair<T, int>;
    priority_queue< P, V<P>, greater<P> > pque;
    fill(begin(dist), end(dist), inf);
    pque.emplace(dist[s] = 0, s);
    while (!pque.empty()) {
      T d; int v;
      tie(d, v) = pque.top(); pque.pop();
      if (d > dist[v]) continue;
      for (int i = 0; i < g[v].size(); ++i) {
        const Edge& e = g[v][i];
        if (e.cap <= 0 or dist[e.to] <= dist[v] + e.cost - (pot[e.to] - pot[v])) continue;
        pv[e.to] = v;
        pe[e.to] = i;
        pque.emplace(dist[e.to] = dist[v] + e.cost - (pot[e.to] - pot[v]), e.to);
      }
    }
  }
  T min_cost_flow(int s, int t, T f) {
    assert(s != t);
    assert(f >= 0);
    T res = 0;
    // fill(begin(pot), end(pot), 0);
    while (f > 0) {
      dijkstra(s);
      if (dist[t] == inf) return -1;
      for (int v = 0; v < n; ++v) pot[v] += dist[v];
      T d = f;
      for (int v = t; v != s; v = pv[v]) {
        d = min(d, g[pv[v]][pe[v]].cap);
      }
      f -= d;
      res += d * pot[t];
      for (int v = t; v != s; v = pv[v]) {
        Edge& e = g[pv[v]][pe[v]];
        e.cap -= d;
        g[v][e.rev].cap += d;
      }
    }
    return res;
  }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, v, xl, xr; cin >> n >> v >> xl >> xr;
  PrimalDual<int> g(2 * n + 4);
  int sl = 2 * n, sr = 2 * n + 1, S = 2 * n + 2, T = 2 * n + 3;
  g.add_edge(S, sl, 1, 0);
  g.add_edge(sl, T, 1, 0);
  g.add_edge(S, sr, 1, 0);
  g.add_edge(sr, T, 1, 0);
  V<> x(n), t(n), p(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> t[i] >> p[i];
    if (abs(x[i] - xl) <= v * t[i]) {
      g.add_edge(sl, 2 * i, 1, 0);
    }
    if (abs(x[i] - xr) <= v * t[i]) {
      g.add_edge(sr, 2 * i, 1, 0);
    }
    g.add_edge(2 * i + 1, T, 1, 0);
    g.add_edge(2 * i, 2 * i + 1, 1, -p[i]);
  }
  for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) if (t[i] < t[j]) {
    if (abs(x[j] - x[i]) <= v * (t[j] - t[i])) {
      g.add_edge(2 * i + 1, 2 * j, 1, 0);
    }
  }
  V<> idx{S, sl, sr};
  {
    V<> ii(n);
    iota(begin(ii), end(ii), 0);
    sort(begin(ii), end(ii), [&](int i, int j) { return t[i] < t[j]; });
    for (int i : ii) {
      idx.push_back(2 * i);
      idx.push_back(2 * i + 1);
    }
    idx.push_back(T);
    assert(idx.size() == g.size());
  }
  g.pot[S] = 0;
  for (int i : idx) {
    for (const auto& e : g.g[i]) if (e.cap > 0) {
      g.pot[e.to] = min(g.pot[e.to], g.pot[i] + e.cost);
    }
  }
  cout << -g.min_cost_flow(S, T, 2) << '\n';
}