#include<iostream>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;
typedef pair<int,int> pii;

int main(){
	int n,m;
	cin>>n>>m;
	int l[m],r[m],d[m];
	vector<pii> edge[n];
	rep(i,m){
		cin>>l[i]>>r[i]>>d[i];
		l[i]--;r[i]--;
		edge[l[i]].pb(pii(r[i],d[i]));
		edge[r[i]].pb(pii(l[i],-d[i]));
	}
	int num[n];
	fill(num,num+n,-1);
	rep(i,n){
		if(num[i]!=-1)continue;
		queue<int> que;
		num[i]=0;
		que.push(i);
		pii now;
		while(!que.empty()){
			now=que.front();
			que.pop();
			rep(j,vec[now].size()){
				num[vec[now][j].first]=num[now]+vec[now][j].second;
				que.push(vec[now][j].first);
			}
		}
	}
	bool check=true;
	rep(i,m){
		if(num[r[i]]-num[l[i]]!=d[i]){
			check=false;
			break;
		}
	}
	cout<<(check?"Yes":"No")<<endl;
	return 0;
}