#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll flag;
set<ll> se;
map<ll,ll> ma;
vector<pair<ll,pair<ll,ll> > > v;
vector<vector<pair<ll,ll> > > vv;
map<ll,ll> ma_index;

void f(ll l){
	rep(i,0,vv[l].sz){
		ll r = vv[l][i].se;
		ll d = vv[l][i].fi;
		if(ma[r]==0){
			ma[r] = ma[l]+d;
			if(ma[l]+d>1000000000){
				flag = 0;
			}
		}
		else{
			if(ma[r]!=ma[l]+d){
				flag = 0;
			}
		}
	}

}

int main() {
	flag = 1;
	ll n,m;
	cin>>n>>m;
	rep(i,0,m){
		ll a,b,c;
		cin>>a>>b>>c;
		v.pb(mp(c,mp(a,b)));
		se.insert(a);
	}
	vector<ll> v1(all(se));
	rep(i,0,v1.sz){
		ma_index[v1[i]] = i;
	}
	vector<vector<pair<ll,ll> > > vv_(se.sz,vector<pair<ll,ll>()) vv_;
	vv = vv_;
	rep(i,0,v.sz){
		ll l = v[i].se.fi;
		ll r = v[i].se.se;
		ll d = v[i].fi;
		vv[ma_index[l]].pb(mp(d,r));
	}
	sort(all(v));
	reverse(all(v));
	ll l0 = v[0].se.fi;
	ll r0 = v[0].se.se;
	ll d0 = v[0].fi;
	ma[l0] = 0;
	ma[r0] = d0;
	rep(i,0,v1.sz){
		f(v1[i]);
	}
	if(flag==1){
	    cout << "Yes" << endl;
	}
	else{
	    cout << "No" << endl;
	}
	return 0;
}