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:
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <limits>
#include <queue>

using namespace std;
using ll = long long;
template <typename T>
T INF = numeric_limits<T>::max() / 2;

class CostFlow
{
public:
    using Cost = int;
    using Ind = short;
    using Capacity = char;
    using T = int;
    // using Cost = ll;
    // using Ind = int;
    // using Capacity = ll;
    // using T = ll;

    struct Edge {
        Edge(const Ind from_, const Ind to_, const Ind reverse_, const Capacity capacity_, const Cost cost_, const bool is_reverse_ = false) : from{from_}, to{to_}, reverse{reverse_}, capacity{capacity_}, flow{0}, cost{cost_}, is_reverse{is_reverse_} {}
        Ind from;
        Ind to;
        Ind reverse;
        Capacity capacity;
        Capacity flow;
        Cost cost;
        bool is_reverse;
    };

    CostFlow(const Ind v) : V{v}
    {
        edge.resize(v);
        m_dist.resize(v);
        m_potential.resize(v);
        m_prev_v.resize(v);
        m_prev_e.resize(v);
    }

    void addEdge(const Ind from, const Ind to, const Capacity capacity, const Cost cost)
    {
        edge[from].push_back(Edge{from, to, (Ind)edge[to].size(), (Capacity)capacity, (Cost)cost, false});
        edge[to].push_back(Edge{to, from, (Ind)(edge[from].size() - 1), (Capacity)0, (Cost)(-cost), true});
    }

    T minCostFlow(const Ind s, const Ind t, T f)
    {
        using P = pair<Cost, Ind>;
        T res = 0;
        fill(m_potential.begin(), m_potential.end(), INF<Cost>);
        m_potential[s] = 0;
        for (int i = 0; i < V; i++) {
            if (m_potential[i] != INF<Cost>) {
                for (const auto& e : edge[i]) {
                    if (not e.is_reverse) {
                        m_potential[e.to] = min(m_potential[e.to], m_potential[i] + e.cost);
                    }
                }
            }
        }

        while (f > 0) {
            // Dijkstra
            priority_queue<P, vector<P>, greater<P>> q;
            fill(m_dist.begin(), m_dist.end(), INF<Cost>);
            m_dist[s] = 0;
            q.push(make_pair(0, s));
            while (not q.empty()) {
                const P p = q.top();
                q.pop();
                const Ind v = p.second;
                if (m_dist[v] < p.first) {
                    continue;
                }
                for (Ind i = 0; i < edge[v].size(); i++) {
                    const auto& e = edge[v][i];
                    if (e.capacity > e.flow and m_dist[e.to] > m_dist[v] + e.cost + m_potential[v] - m_potential[e.to]) {
                        m_dist[e.to] = m_dist[v] + e.cost + m_potential[v] - m_potential[e.to];
                        m_prev_v[e.to] = v;
                        m_prev_e[e.to] = i;
                        q.push(make_pair(m_dist[e.to], e.to));
                    }
                }
            }

            if (m_dist[t] == INF<Cost>) {
                return res;
            }
            for (Ind v = 0; v < V; v++) {
                m_potential[v] += m_dist[v];
            }

            Capacity d = f;
            for (Ind v = t; v != s; v = m_prev_v[v]) {
                const auto& e = edge[m_prev_v[v]][m_prev_e[v]];
                d = min(d, (Capacity)(e.capacity - e.flow));
            }
            f -= d;
            res += (Cost)d * m_potential[t];
            for (Ind v = t; v != s; v = m_prev_v[v]) {
                auto& e = edge[m_prev_v[v]][m_prev_e[v]];
                e.flow += d;
                edge[v][e.reverse].flow -= d;
            }
        }
        return res;
    }

    const Ind V;
    vector<vector<Edge>> edge;

private:
    vector<Cost> m_dist;
    vector<Cost> m_potential;
    vector<Ind> m_prev_v;
    vector<Ind> m_prev_e;
};

struct Point {
    int X;
    int T;
    int P;
    bool operator<(const Point& p) const
    {
        return T < p.T;
    }
};

int main()
{
    CostFlow::Ind N;
    cin >> N;
    int V, L, R;
    cin >> V >> L >> R;
    vector<Point> point(N);
    for (CostFlow::Ind i = 0; i < N; i++) {
        cin >> point[i].X >> point[i].T >> point[i].P;
    }
    sort(point.begin(), point.end());
    CostFlow flow(2 * N + 4);
    const CostFlow::Ind s = 0;
    const CostFlow::Ind t = 2 * N + 3;
    const CostFlow::Ind l = 1;
    const CostFlow::Ind r = 2;
    flow.addEdge(s, l, 1, 0);
    flow.addEdge(s, r, 1, 0);
    for (CostFlow::Ind i = 0; i < N; i++) {
        flow.addEdge(2 * i + 3, 2 * i + 4, 1, 0);
        flow.addEdge(2 * i + 4, t, 1, -point[i].P);
        if (abs(point[i].X - L) <= V * point[i].T) {
            flow.addEdge(l, 2 * i + 3, 1, 0);
        }
        if (abs(point[i].X - R) <= V * point[i].T) {
            flow.addEdge(r, 2 * i + 3, 1, 0);
        }
    }
    for (CostFlow::Ind i = 0; i < N; i++) {
        for (CostFlow::Ind j = i + 1; j < N; j++) {
            if (abs(point[i].X - point[j].X) <= V * (point[j].T - point[i].T)) {
                flow.addEdge(2 * i + 4, 2 * j + 3, 1, -point[i].P);
            }
        }
    }
    cout << -flow.minCostFlow(s, t, 2) << endl;

    return 0;
}