#prag\
ma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

#define f first
#define s second
pair<int,int> fa[100001];

int find(int x){
	if(fa[x].f==x&&fa[x].s==0) return x;
	int t=find(fa[x].f);
	fa[x]=make_pair(t,fa[fa[x].f].s+fa[x].s);
	fa[x].f=t;
	return t;
}

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=n;++i) fa[i]=make_pair(i,0);
	for(int i=1;i<=m;++i){
		int l,r,d;
		cin>>l>>r>>d;
		int x=find(l),y=find(r);
		if(x!=y){
			if(x>y) fa[x]=make_pair(y,-(fa[l].s-fa[r].s+d));
			else fa[y]=make_pair(x,fa[l].s-fa[r].s+d);
		}
		else{
			if(fa[r].s-fa[l].s!=d){
				cout<<"No";
				return 0;
			}
		}
	}
	cout<<"Yes";
}