#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
const int MAXN=1e5+5;
int p[MAXN],vis[MAXN],error;
struct node{
	int x,y;
}push;
int n,m;
vector <node> vec[MAXN];
void solve(int x){
	for (int i=0; i<vec[x].size(); i++){
		node g=vec[x][i];
		if (vis[g.x])
		  if (g.y+p[x]!=p[g.x]){
		  	error=1;		
		  	return;
		  }
		  else continue;
		 vis[g.x]=1;
		 p[g.x]=p[x]+g.y;
		 solve(g.x);
		 if (error) return;
	}
}
int main(){
	scanf("%d%d",&n,&m);
		memset(vis,0,sizeof(vis));
		memset(p,0,sizeof(p));
		error=0;
		for (int i=0; i<m; i++){
			int a,b,l;
			scanf("%d%d%d",&a,&b,&l);
			push.x=b;
			push.y=l;
			vec[a].push_back(push);
			push.x=a;
			push.y=-l;
			vec[b].push_back(push);
		}
		for (int i=0; i<n; i++)
		  if (!vis[i]){
		  	solve(i);
		  	if (error) break;
		  }
		if (!error) printf("Yes\n");
		else printf("No\n");
	
	return 0;
}