#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define   M             10005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           0x3f3f3f3f
#define   rush()        int T;scanf("%d",&T);while(T--)

typedef   pair<int,int> P;

vector <P> E[M];
int vis[M];

bool dfs(int u) {
	vis[u]=1;
	for(auto p : E[u]) {
		int v =p.first;
		int d =p.second;
		
		if(!vis[v]) {
			dis[v]=dis[u]+d;
			if(!dfs(v))
				return false;
		}
		else if(dis[u]+d != dis[v]) return false;
	}
	return true;
}


int main() {

	int n,m,f=0;
	scanf("%d %d",&n,&m);
	
//	mst(a,-1);
	
	while(m--) {
		int x,y,z;
		scanf("%d %d %d",&x,&y,&z);
		E[x].push_back(make_pair(y,z));
		E[y].push_back(make_pair(x,-z));
	}
	
	f=0;
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			if(!dfs(i)) {
				f=1;
				break;
			}
		}
	}
	
	if(f) puts("No");
	else  puts("Yes");
	
}

