#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 long long 
int n,m;
int l[200000],r[200000],d[200000];
map<int,ll>t;
const __int64 M=5000000000;

int main(){
cin>>n>>m;
rep(i,n)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になりうる
		if(d[i]!=t[r[i]]-t[l[i]])ok=0;
	}
}
if(ok)cout<<"Yes"<<endl;
else cout<<"No"<<endl;
	return 0;
}

/*#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 dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int h,w;
char t[50][50];
char tt[50][50];
int main(){
cin>>h>>w;
rep(i,h){
	rep(j,w){cin>>t[i+1][j+1];tt[i+1][j+1]=t[i+1][j+1];}
}
int ans=0;
rep(k,h*w){
int ni,nj,cnt;
cnt=100;
	ni=-1,nj=-1;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			int mi=0;
			if(tt[i][j]!='.')continue;
			bool ok=1;
			rep(k,4)if(tt[i+dy[k]][j+dx[k]]=='a')ok=0;
			if(!ok)continue;
			rep(k,4)if(tt[i+dy[k]][j+dx[k]]!='.')mi++;//おけない場所

			if(cnt>mi){
				cnt=mi;
				ni=i,nj=j;
			}
		}
	}

	if(cnt==100)break;
	tt[ni][nj]='a';
	ans++;
}
cout<<ans<<endl;

	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
		cout<<tt[i][j];
	}
	cout<<endl;
	}

	return 0;
}*/

