#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;

int n,m,dis[200001];
bool vis[200001];
vector<pair<int,int> > g[200001];

bool dfs(int x){
	int i,y,d;
	vis[x]=true;
	for(i=0;i<g[x].size();i++){
		y=g[x][i].first,d=g[x][i].second;
		if(!vis[y]){
			dis[y]=dis[x]+d;
			if(!dfs(y))return false;
		}	
		else
			if(dis[x]+d!=dis[y])return false;
	}
	return true;
}

int main(){
	int i,u,v,w;
	cin >> n >> m;
	for(i=1;i<=m;i++){
		cin >> u >> v >> w;
		g[u].push_back(make_pair(v,w));
		g[v].push_back(make_pair(u,-w));
	}
	for(i=1;i<=n;i++)
		if(!vis[i])
			if(!dfs(i)){
				cout << "No" << endl;
				return 0;
			}
	cout << "Yes";
	return 0;
}