#include<bits/stdc++.h>
using namespace std;

struct bian{
	int x,to,next;
}edge[400001];
int cnt,head[100001],dis[100001];
bool vis[100001],f;

inline void add(int u,int v,int x){
	edge[++cnt].x=x,edge[cnt].to=v,edge[cnt].next=head[u],head[u]=cnt;
}

inline void dfs(int x,int fa){
	vis[x]=1;
	for(int i=head[x];i;i=edge[i].next)
		if(fa!=edge[i].to){
			if(dis[edge[i].to]!=0x7f7f7f7f){
				if(edge[i].x!=dis[edge[i].to]-dis[x]){
					puts("No");exit(0);
				}
			}else{
				dis[edge[i].to]=dis[x]+edge[i].x;
				dfs(edge[i].to,x);
			}
		}
}

int main()
{
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int l,r,d;
		cin>>l>>r>>d;
		add(l,r,d),add(r,l,-d);
	}
	memset(dis,0x7f,sizeof dis);
	for(int i=1;i<=n;i++)
		if(!vis[i]) dfs(i,i);
	cout<<"Yes";
}