//ΔARC090B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 111111;
int n,m,a[N],vis[N];
vector<int> v[N],p[N];
void dfs(int u){
	int i,x,z;
	vis[u]=1;
	i=v[u].size();
	while(i--){
		x=v[u][i];
		z=p[u][i];
		if(vis[x]){
			if(a[x]!=a[u]+z){
				printf("No");
				exit(0);
			}
		}
		else{
			a[x]=a[u]+z;
			dfs(x);
		}
	}
}
int main()
{
	int i,x,y,z;
	scanf("%d%d",&n,&m);
	while(m--){
		scanf("%d%d%d",&x,&y,&z);
		v[x].push_back(y);
		p[x].push_back(z);
		v[y].push_back(x);
		p[y].push_back(-z);
	}
	for(i=1;i<=n;i=i+1)
		if(!vis[i])
			dfs(i);
	printf("Yes");
	return 0;
}