#include<bits/stdc++.h>
using namespace std;
#define ran 101111
int n;
vector<pair<int,int> > e[ran];
bool vis[ran];
int pos[ran];
bool dfs(int x){
	vis[x] = true;
	for(auto p : e[x]){
		int y = p.first;
		int dif = p.second;
		if(!vis[y]){
			pos[y] = pos[x] + dif;
			if(!dfs(y))return false;
		}else{
			if(pos[y] != pos[x] + dif)return false;
		}
	}
	return true;
}
int main(){
	int m;
	scanf("%d%d",&n,&m);
	while(m--){
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back({y, z});
		e[y].push_back({x, -z});
	}
	for(int i=1; i<=n; i++)
		if(!vis[i]){
			pos[i] = 0;
			if(!dfs(i)){
				puts("No");
				return 0;
			}
		}
	puts("Yes");
	return 0;
}
