#include <bits/stdc++.h>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const ll INF = 1e17;

struct dat{
	ll x, y, d;

	bool operator<(dat& right) const{
		if(x != right.x) return x < right.x;
		else return y < right.y;
	}
};

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,m;
	cin >> n >> m;

	vector<dat> v;
	rep(i,m){
		ll l, r, d;
		cin >> l >> r >> d;

		l--;
		r--;

		if(l>r){
			v.push_back(dat{r, l, -d});
		}else{
			v.push_back(dat{l, r, d});
		}
	}
	sort(v.begin(), v.end());

	ll d[n];
	rep(i,n) d[i] = INF;

	d[0] = 0;
	rep(i,v.size()){
		dat a = v[i];
		if(d[a.x] != INF && d[a.y] != INF){
			if(d[a.y] - d[a.x] != a.d){
				cout << "No" << endl;
				return 0;
			}
		}else if(d[a.x] != INF){
			d[a.y] = d[a.x] + a.d;
		}else if(d[a.y] != INF){
			d[a.x] = d[a.y] - a.d;
		}else{
			d[a.x] = 0;
			d[a.y] = a.d;
		}
	}

	cout << "Yes" << endl;	
}