#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 123456, maxm, oo = 1000000000;
int n, m, l[maxm], r[maxm], d[maxm], vis[maxn], v[maxn];
vector<pii> e[maxn];

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n >> m;
	F1 (i, m) cin >> l[i] >> r[i] >> d[i];
}

pair<int, int> dfs(int cur, int val)
{
	vis[cur] = true;
	v[cur] = val;
	int mx = val, mi = val;
	for (pii nxt : e[cur]) if (!vis[nxt.fi])
	{
		pii x = dfs(nxt.fi, val + nxt.se);
		mx = max(mx, x.fi);
		mi = min(mi, x.se);
	}
	return mp(mx, mi);
}

void solve()
{
	bool flag = true;
	F1 (i, m) e[l[i]].pb(mp(r[i], d[i]));
	F1 (i, m) e[r[i]].pb(mp(l[i], -d[i]));
	F1 (i, n) 
		if (!vis[i]) 
		{
			pii x = dfs(i, 0);
			if (x.fi - x.se > oo) flag = false;
		}
	F1 (i, m) if (v[r[i]] - v[l[i]] != d[i]) flag = false;
	if (flag) cout << "Yes\n";
	else cout << "No\n";
}

main()
{
	input();
	solve();
}
