#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
using namespace std;
struct node{
	int to;
    long long dis;
};
vector<node>a[100005];
int n,m;
long long a1[200005],b1[200005],c[100005];
long long x[100005];
int vis[100005];
void search(int at){
	for(int i=0;i<a[at].size();i++){
		if(vis[a[at][i].to]==0){
			vis[a[at][i].to]=1;
			x[a[at][i].to]=x[at]+a[at][i].dis;
			search(a[at][i].to);
		}
	}
}
int main(){
    scanf("%d%d",&n,&m);
    x[1]=0;
    for(int i=1;i<=m;i++){
    	scanf("%lld%lld%lld",&a1[i],&b1[i],&c[i]);
    	a[a1[i]].push_back((node){b1[i],c[i]});
    	a[b1[i]].push_back((node){a1[i],-c[i]});
	}
	for(int i=1;i<=n;i++){
		if(vis[i]==0){
			vis[i]=1;
			search(i);
		}
	}
	for(int i=1;i<=m;i++){
		if(x[b1[i]]-x[a1[i]]!=c[i]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
    return 0;
}
