#include <bits/stdc++.h>
#define F first
#define S second
#define dq deque
#define vc vector
#define INF (0x3f3f3f3f)
#define LINF ((long long)(1e18))
#define pb push_back
#define mp make_pair
#define ll long long
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define sint short int
#define ull unsigned ll
#define pii pair<int,int>
#define uint unsigned int
#define B cout << "BreakPoint" << endl;
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define msn(_data,_num) memset(_data,_num,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;
#define mymax(a,b) if(a<b) a = b;
#define mymin(a,b) if(a>b) a = b;
void print(int _x){printf("%d\n",_x);}
void print(ll _x){printf("%lld\n",_x);}
_tp<_tyn T>void print( T _a[] , int _s , int _t ){
	for( int i = _s ; i <= _t ; i++ )
		cout << _a[i] << " ";
   	cout << endl;
}
#define il inline
#define rg register
struct InputReader{
    static const int bs = 100000;
    char buf[bs];
    int p;
    il InputReader():p(bs) {}
    il void flush(){
        p = 0;
        fread(buf, 1, bs, stdin);
    }
    il char c(){
        if(p >= bs) flush();
        return buf[p++];
    }
	int getnum(){
		char ch = c();
        while( ch < '0'  ||  ch > '9' ) ch = c();
		return (int)(ch-'0');
	}
    il int operator() (){
        int ans = 0;
        char ch = c();
		int fu = 1;
		while( ch < '0'  ||  ch > '9' ){
			if( ch == '-' ) fu = -1;
			ch = c();
		}
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10;
            ans += ch-'0';
            ch = c();
        }
        return ans * fu;
    }
	ll readll(){
		ll ans = 0LL;
		char ch = getnum()+'0';
        while( ch >= '0'  &&  ch <= '9' ){
            ans *= 10LL;
            ans += ch-'0';
            ch = c();
        }
        return ans;
	}
	char specialread(){
		char ch = c();
		while( ch < 'F'  ||  ch > 'R' ) ch = c();
		return ch;
	}
}in;
il void read( int &x ){
	x = in();
}
il void read( int &x, int &y ){
	x = in(); y = in();
}
il void read( int &x1 , int &x2 , int &x3 ){
	x1 = in(); x2 = in(); x3 = in();
}
il void read( int &x1 , int &x2 , int &x3 , int &x4 ){
	x1 = in(); x2 = in(); x3 = in(); x4 = in();
}
clock_t _starttime , _endtime;
il void FILEIO(){
	#ifdef WIN32
		_starttime = clock();
	#endif
	#ifdef WIN32
		fin("in.in");
	#endif
}
il void END(){
	#ifdef WIN32
		_endtime = clock();
		double _timeuse = (_endtime-_starttime)* 1000.0 / CLOCKS_PER_SEC;
		printf("\n\nTime usage:\n%lf ms\n",_timeuse);
	#endif
	exit(0);
}
/////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
#define MAXN 100010
#define MAXM 200020
int P;
int n,m;

int s[MAXM],t[MAXM],v[MAXM];

int dsu[MAXN];
int dis[MAXN];
void init( int sz ){
	ms(dis);
	for( int i = 0 ; i <= sz+2 ; i++ ){
		dsu[i] = i;
	}
}
int gf( int pos ){
	if( dsu[pos] == pos )
		return pos;
	int ret = gf(dsu[pos]);
	dis[pos] += dis[dsu[pos]];
	dsu[pos] = ret;
	return ret;
}
bool unite( int a , int b , int v ){	// a <= b
	int p,q;
	p = gf(a);
	q = gf(b);
	if( p != q ){
		dsu[p] = q;
		dis[p] = dis[b] - (dis[a]+v);
	}else{
		if( dis[b] - dis[a] != v ) return 0;
	}
	return 1;
}

vc<int> need;
#define Lb(x) lower_bound(need.begin(),need.end(),x) - need.begin()

int main(){
	FILEIO();

	read(n,m);
	for( int i = 1 ; i <= m ; i++ ){
		read(s[i],t[i],v[i]);
		s[i]--;
		t[i]--;
		need.pb(s[i]);
		need.pb(t[i]);
	}

	sort(need.begin(),need.end());
	need.resize(unique(need.begin(),need.end())-need.begin());
	init(need.size()+2);

	bool faild = 0;
	for( int i = 1 ; i <= m ; i++ ){
		bool ret = unite(Lb(s[i]),Lb(t[i]),v[i]);
		if( !ret ){
			faild = 1;
			break;
		}
	}

	if( !faild ) printf("Yes\n");
	else printf("No\n");

	END();
}


Measured memory_bytes: 5108