#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<map>
#include<stack>
#include<set>
#define iss ios::sync_with_stdio(false)
using namespace std;
typedef long long ll;
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 7;
const int mod = 998244353;
int head[maxn],num,fa[maxn],n,m,ans[maxn];
struct node{
    int  v,w,next;
}e[maxn];
void add(int u,int v,int w){
    e[num].next = head[u];
    e[num].v = v;
    e[num].w = w;
    head[u] = num ++;
}
int Find(int x){
    if(fa[x] != x) fa[x] = Find(fa[x]);
    return fa[x];
}
void dfs(int u,int pre){
    for(int i = head[u];i != -1;i = e[i].next){
        int to = e[i].v,w = e[i].w;
        if(to == pre) continue;
        if(w == ans[u]){
           if(w == n) ans[to] = 1;
           else ans[to] = w + 1;
        }
        else ans[to] = w;
        dfs(to,u);
    }
}
int main (){
    scanf("%d%d",&n,&m);
    memset(head,-1,sizeof(head));
    for(int i = 1; i <= n; i ++){
        fa[i] = i;
    }
    for(int i = 1,u,v,w; i <= m; i ++){
        scanf("%d%d%d",&u,&v,&w);
        int x = Find(u);
        int y = Find(v);
       // printf ("%d %d..\n",x,y);
        if(x == y) continue;
        fa[x] = y;
       // printf ("%d %d %d\n",u,v,w);
        add(u,v,w);
        add(v,u,w);
    }
    ans[1] = 1;
    dfs(1,-1);
    for(int i = 1; i <= n; i ++){
        printf ("%d\n",ans[i]);
    }












}

#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
#include<tuple>
#include<deque>
using namespace std;
const int mod = 1000000007;
const int INF = 1001001001;
const long long LINF = 1001002003004005006;
const double PI = acos(-1);
int dir4row[] = { 1,0,-1,0 };
int dir4col[] = { 0,1,0,-1 };
int dir8row[] = { 1,1,0,-1,-1,-1,0,1 };
int dir8col[] = { 0,1,1,1,0,-1,-1,-1 };

/*-----------------------------------------------*/

int main() {
	int n, w; cin >> n >> w;
	vector<long long> v(200005);
	for (int i = 0; i < n; ++i) {
		int s, t, p; cin >> s >> t >> p;
		v[s] += p;
		v[t] -= p;
	}
	for (int i = 1; i < 200005; ++i) {
		v[i] = v[i] + v[i - 1];
	}
	for (int i = 0; i < 200005; ++i) {
		if (v[i] > (long long)w) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}