// Slower C++ solution:
#include <bits/stdc++.h>

#define X first

#define Y second

#define pb push_back

#define sz(a) (int)a.size()

#define int long long



using namespace std;



vector <pair <int, int>> g[100010];



vector <vector <int>> v;



int a[100010];

int used[100010];



void dfs(int vv) {

    used[vv] = 1;

    for (auto u : g[vv]) {

        if (used[u.X] == 1)

            continue;

        a[u.X] = a[vv] + u.Y;

        dfs(u.X);

    }

}



signed main() {

    ios_base::sync_with_stdio(0);

    cin.tie(0);

    int n, m;

    cin >> n >> m;

    int l, r, d;

    for (int i = 0; i < m; i++) {

        cin >> l >> r >> d;

        l--;

        r--;

        g[l].pb({r, d});

        g[r].pb({l, -d});

        v.pb({l, r, d});

    }

    for (int i =0; i < n; i++) {

        if (used[i] == 0) {

            dfs(i);

        }

    }

    for (int i = 0; i < m; i++) {

        if (a[v[i][1]] - a[v[i][0]] != v[i][2]) {

            cout << "No" << endl;

            exit(0);

        }

    }

    cout << "Yes";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.475641710632879x):
#include <bits/stdc++.h>

#include <unordered_map>

#include <unordered_set>

using namespace std;

#define int long long

#define eb emplace_back

#define ef emplace_front

#define rep(i, x, n) for (int i = x; i < n; ++i)

#define mp make_pair

#define fi first

#define se second

#define ii pair<int, int>

#define endl '\n'

#define vi vector<int>

#define vii vector<pair<int, int>>

#define reverse(s) reverse(s.begin(), s.end())

#define ld long double

#define vs vector<string>

#define inf INT_MAX

#define vc vector<char>

#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define vb vector<bool>

#define lb(a, x) lower_bound(a.begin(), a.end(), x)

#define ub(a, x) upper_bound(a.begin(), a.end(), x) 

#define vvi vector<vi>

#define mine(a) min_element(a.begin(),a.end())

#define maxe(a) max_element(a.begin(), a.end())

#define iota(a,i) iota(a.begin(),a.end(),i)

#define fileopen(filename) if (fopen(filename".INP", "r")) {freopen(filename".INP", "r", stdin);freopen(filename".OUT", "w", stdout);}

int n, m;

map<ii, int> a;

vi par, val;

vvi adj;

vb d;

int findset(int x) {

	int u = x;

	while (par[x] != -1) {

		x = par[x];

		par[u] = x;

	}

	return x;

}

bool sameset(int x, int y) {

	return findset(x) == findset(y);

}

void unionset(int x, int y) {

	x = findset(x);

	y = findset(y);

	if (x == y) return;

	par[x] = y;

}

void dfs(int x) {

	for (int i : adj[x]) {

		if (d[i] == 0) {

			d[i] = 1;

			val[i] = val[x] + a[mp(x, i)];

			dfs(i);

		}

		else if (val[i] != val[x] + a[mp(x, i)]) {

			cout << "No";

			exit(0);

		}

	}

}

signed main() {

	fastio;

	cin >> n >> m;

	par.resize(n + 1, -1);

	adj.resize(n + 1);

	d.resize(n + 1, 0);

	val.resize(n + 1, 0);

	while (m--) {

		int x, y, z;

		cin >> x >> y >> z;

		a[mp(x, y)] = z;

		a[mp(y, x)] = -z;

		unionset(x, y);

		adj[x].emplace_back(y);

		adj[y].emplace_back(x);

	}

	rep(i, 1, n + 1) {

		if (d[i] == 0) {

			int x = findset(i);

			d[x] = 1;

			val[x] = 0;

			dfs(x);

		}

	}

	cout << "Yes";

	return 0;

}