#include<bits/stdc++.h>
using namespace std;
int father[100500];
int dis[100500];
int find_father(int x) {
	if(father[x]==x)return x;
	int a1=father[x];
	int a2=find_father(father[x]);
	father[x]=a2;
	dis[x]=dis[x]+dis[a1];
	return a2;
}
int find_dis(int x) {
	if(father[x]==x)return 0;
	return find_dis(father[x])+dis[x];
}
int main(void) {
	int num,cas,L,R,D;
	cin>>num>>cas;
	for(int i=0; i<=num; i++) {
		father[i]=i;
		dis[i]=0;
	}
	while(cas--) {
		cin>>L>>R>>D;
		int fl=find_father(L);
		int fr=find_father(R);
		if(fl==fr) {
			if(dis[L]+D!=dis[R]) {
				cout<<"No"<<endl;
				return 0;
			}
		} else {
			father[fr]=fl;
			dis[fr]=find_dis(L)-find_dis(R)+D;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}