#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define mp make_pair
#define pb push_back
#define pii pair <int, int>
#define vi vector<int>

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define FORd(i, a, b) for (int i=a-1; i>=b; i--)
#define F0Rd(i, a) for (int i=a-1; i>=0; i--)
#define F0R(i, a) for (int i=0; i<a; i++)
 
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define sz size
 
const int MOD = 1000000007;
long double PI = 4*atan(1);
/*std::cout << std::fixed;
std::cout << std::setprecision(2);*/

int n,s,t,w,p;
ll dp[200005];

int main()
{
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> w;
    F0R(i,n) {
    	cin >> s >> t >> p;
    	dp[s] += p;
    	dp[t] -= p;
    }
    F0R(i,200005) {
    	dp[i] += dp[i-1];
    	if (dp[i] > w) {
    		cout << "No";
    		return 0;
    	}
    }
    cout << "Yes\n";
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(), A.end()
#define RALL(A) A.rbegin(), A.rend()
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
const ll LINF = 1LL << 60;
const int INF = 1 << 30;

bool solve(ll x, set<ll> &s)
{
    // cout << 'x' << x << endl;
    ll ans = 0;
    for (auto e : s)
    {
        for (auto e2 : s)
        {
            for (auto e3 : s)
            {
                // cout << e << e2 << e3 << endl;
                ans = (e | e2 | e3);
                // cout << "ans: " << ans << endl;
                if (ans == ((1LL << 5) - 1LL))
                {
                    return true;
                }
            }
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    vector<vector<ll>> A(n, vector<ll>(5));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            cin >> A[i][j];
        }
    }

    ll ok = 0;
    ll ng = 1001001001;

    while (abs(ok - ng) > 1)
    {
        ll mid = (ok + ng) / 2LL;
        set<ll> s;
        for (ll i = 0; i < n; i++)
        {
            ll bit = 0;
            for (ll j = 0; j < 5; j++)
            {
                if (A[i][j] >= mid)
                {
                    bit |= (1LL << j);
                }
            }
            s.insert(bit);
        }

        if (solve(mid, s))
        {
            ok = mid;
        }
        else
        {
            ng = mid;
        }
    }
    cout << ok << endl;

    return 0;
}
