#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

typedef long long ll;
typedef pair<int , int> pii;

const int N = 100100;

vector <pii> adj[N];

bool mark[N];
int dist[N];

void DFS(int v){
	
	mark[v] = 1;

	for(auto u : adj[v]){
	   int t = dist[v] + u.S;
	   if(!mark[u.F]){
		  dist[u.F] = t;
		  DFS(u.F);
	   }
	   else if(dist[u.F] != t){
		  cout << "No" << endl;
		  exit(0);
	   }
	}
	
	return;
}

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	int n , m , l , r , d;
	cin >> n >> m;

	for(int i = 0 ; i < m ; i++){
	   cin >> l >> r >> d;
	   adj[--l].pb({--r , d});
	   adj[r].pb({l , -d});
	}
	
	for(int i = 0 ; i < n ; i++)
	   if(!mark[i])
		  DFS(i);
	
	cout << "Yes" << endl;

	return 0;
}