#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int n,m;
int l[200000],r[200000],d[200000];
map<int,ll>t;
const ll M=500000000000;

int main(){
cin>>n>>m;
rep(i,n+1)t[i]=-M;
rep(i,m){
cin>>l[i]>>r[i]>>d[i];
l[i]--;
r[i]--;
}

bool ok=1;

rep(i,m){
	if(t[l[i]]==-M&&t[r[i]]==-M){
		t[l[i]]=M;
		t[r[i]]=d[i]+t[l[i]];
	}
	else if(t[l[i]]==-M){
		t[l[i]]=t[r[i]]-d[i];
	}
	else if(t[r[i]]==-M){
		t[r[i]]=t[l[i]]+d[i];
	}
	else{//ここでok=0になりうる
	//	cout<<t[r[i]]<<" "<<t[r[i]]<<" "<<r[i]<<" "<<l[i]<<endl;
		if(d[i]!=t[r[i]]-t[l[i]])ok=0;
	}
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
	return 0;
}