// Slower C++ solution:
#include <iostream>

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <string.h>

#include <algorithm>

#include <limits.h>

#include <vector>

#include <map>

#include <stack>

#include <queue>

#include <math.h>

#define ll long long

#define MSET(x) memset((x), 0, sizeof((x)))

#define MMSET(x) memset((x), -1, sizeof((x)))

#define rep(i, a, b) for ( int (i) = a; (i) < (b) ; (i) ++ )

#define repA(i, a, b) for ( int (i) = a ;  (i) <= (b) ; (i) ++ )

#define repD(i, a, b) for ( int (i) = a; (i) >= (b) ; (i) -- )

#define fi first

#define se second

#define pb push_back

#define mfind(m, item) ((m).find((item)) != (m).end())

#define mp(a,b) make_pair((a),(b))

#define mt(a,b,c) make_pair(make_pair((a),(b)), (c))

#define tfi first.first

#define tse first.second

#define tth second

#define print cout << endl

#define tri pair<pair<int, int>, int>

using namespace std;



int n,m;

int fa[100005], cnt[100005];

void find(int x){

    if ( fa[x] == x ) return;

    find(fa[x]);

    cnt[x] += cnt[fa[x]]; fa[x] = fa[fa[x]];

}



int main(){

    while ( cin >> n >> m ) {

        bool has = false;

        MSET(fa); MSET(cnt);

        for ( int i = 0 ; i <= n ; ++ i ) fa[i] = i;

        for ( int i = 0, x, y, z ; i < m ; ++ i ) {

            scanf("%d %d %d", &x, &y, &z);

            find(x); find(y);

            if ( fa[x] == fa[y] ) {

                if ( cnt[y] != cnt[x] + z ) has = true;

            }

            else {

                cnt[fa[y]] = cnt[x] + z - cnt[y];

                fa[fa[y]] = fa[x];

            }

        }

        cout << (has ? "No" : "Yes" ) << endl;

    }

}


// Faster C++ solution for the same problem (measured speedup: 1.7590332934110864x):
#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;

}