/*
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;

int a[105][105];

int main(){
	int n,sum = 0,cnt = 0;
	cin >> n;
	for(int i = 1;i <= n;i++) cin >> a[1][i];
	for(int i = 1;i <= n;i++) cin >> a[2][i];
	for(int i = 1;i <= n;i++){
		cnt = 0;
		for(int j = 1;j <= i;j++) cnt += a[1][j];
		for(int j = i;j <= n;j++) cnt += a[2][j];
		sum = max(cnt,sum);
	}
	cout << sum << endl;
}
*/

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
typedef long long LL;

const int maxn = 100005;
int last[2 * maxn],pre[2 * maxn],other[2 * maxn];
LL cost[2 * maxn],dis[maxn];
bool vis[maxn];
int que[maxn];
int all = -1;

void build(int x,int y,LL z){
	pre[++all] = last[x];
	last[x] = all;
	other[all] = y;
	cost[all] = z;
}

bool dfs(int x){
	vis[x] = 1;
	int dt = last[x];
	while(dt != -1){
		int dr = other[dt];
		if(vis[dr] == 0){
			dis[dr] = dis[x] + cost[dt];
			if(!dfs(dr)) return false;
		}
		if(vis[dr] == 1){
			if(dis[dr] != dis[x] + cost[dt]) return false;
		}
		dt = pre[dt];
	}
	return true;
}

int main(){
	int n,m;
	cin >> n >> m;
	memset(last,-1,sizeof(last));
	int cnt = 0;
	for(int i = 1;i <= m;i++){
		int x,y;
		LL z;
		cin >> x >> y >> z;
		if(vis[x] == 0) vis[x] = 1,que[++cnt] = x;
		if(vis[y] == 0) vis[y] = 1,que[++cnt] = y;
		build(x,y,z);
		build(y,x,-z);
	}
	memset(vis,0,sizeof(vis));
	for(int i = 1;i <= cnt;i++){
		if(vis[que[i]] == 0){
			dis[que[i]] = 0;
			if(dfs(que[i]) == false){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}