#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#include<vector>
using namespace std;


int main(){
	int n;
	int m;
	int l[200000];
	int r[200000];
	int d[200000];
	int c[200000];
	int dis[200000];
	vector<vector<int>> vv;
	int clasn = 0;
	int boot = 1;
	
	cin >> n;
	cin >> m;
	for(int i = 0 ; i < m ; i++ ){
		cin >> l[i] >> r[i] >> d[i];
	}
	
	for(int i = 0 ; i < m ; i++ ){
		if(c[l[i]]==0 && c[r[i]]==0){
			clasn++ ;
			c[l[i]]=clasn;
			c[r[i]]=clasn;
			dis[l[i]] = 0;
			dis[r[i]] = d[i];
			vv[clasn].push_back(l[i]);
			vv[clasn].push_back(r[i]);
		}
		else if(c[l[i]]==c[r[i]]){
			if (dis[l[i]] != dis[r[i]]) boot = 0;
		}
		else if(c[l[i]]*c[r[i]]==0 && c[l[i]]+c[r[i]]!=0){
			if(c[l[i]]==0){
				c[l[i]] = c[r[i]];
				dis[l[i]] = dis[r[i]] - d[i];
				vv[clasn].push_back(l[i]);
			} else {
				c[r[i]] = c[l[i]];
				dis[r[i]] = dis[l[i]] + d[i];
				vv[clasn].push_back(r[i]);
			}
		}
		else if(c[l[i]] < c[r[i]]){
			vv[c[l[i]]].insert(vv[c[l[i]]].end(), vv[c[r[i]]].begin(), vv[c[r[i]]].end()); 
			for(j=0; j<vv[c[r[i]]].size(); j++){
				c[vv[c[r[i]]][j]]=c[l[i]];
				dis[vv[c[r[i]]][j]]=dis[l[i]]+dis[vv[c[r[i]]][j]]-dis[r[i]]+d[i];
			}
		}
		else {
			vv[c[r[i]]].insert(vv[c[r[i]]].end(), vv[c[l[i]]].begin(), vv[c[l[i]]].end()); 
			for(j=0; j<vv[c[l[i]]].size(); j++){
				c[vv[c[l[i]]][j]]=c[r[i]];
				dis[vv[c[l[i]]][j]]=dis[r[i]]+dis[vv[c[l[i]]][j]]-dis[l[i]]-d[i];
			}
		}
	}
	
	if(boot) cout << "Yes";
	else cout << "No";
	
	return 0;
}