#include <bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define Set(i, v) memset(i, v, sizeof i)
#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

typedef long long LL;

using namespace std;

const int N = 1e5 + 10;

int n, m;
int X[N];
bool vis[N];
vector<int> G[N], w[N];

void DFS(int o){
	vis[o] = true;
	For(i, 0, (int)G[o].size() - 1){
		int v = G[o][i], d = w[o][i];
		if(vis[v] && X[v] != X[o] + d){
			puts("No");
			exit(0);
		}
		else if(!vis[v]){
			X[v] = X[o] + d;
			DFS(v);
		}
	}
}

int main(){

	scanf("%d%d", &n, &m);
	For(i, 1, m){
		int u, v, d;
		scanf("%d%d%d", &u, &v, &d);
		G[u].pb(v), G[v].pb(u);
		w[u].pb(d), w[v].pb(-d);
	}

	For(i, 1, n) if(!vis[i]) DFS(i);
	puts("Yes");

	return 0;
}