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

#include<vector>

#include<string>

#include<cmath>

#include<algorithm>

#include <numeric>

#include<map>

#include<unordered_map>

#include<queue>



using namespace std;

using ll=long long;

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

#define ALL(a) (a).begin(),(a).end()

#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)



vector<ll> pos(100010);

vector<bool> used(100010);

struct choten{

    vector<ll> c;

    vector<ll> w;

};

vector<choten> g(100010);



bool dfs(ll x){

    bool flag = true;

    used[x] = true;

    rep(i, g[x].c.size()){

        ll tmp = g[x].c[i];

        ll weight = g[x].w[i];

        if(!used[tmp]){

            pos[tmp] = pos[x] + weight;

            flag *= dfs(tmp);

        }

        else if(pos[tmp] != pos[x] + weight)return false;   

    }

    return flag;

}



int main(){

    ll n, m;

    cin >> n >> m;

    rep(i, m){

        ll l, r, d;

        cin >> l >> r >> d;

        g[l].c.push_back(r);

        g[l].w.push_back(d);

        g[r].c.push_back(l);

        g[r].w.push_back(-d);

    }

    rep(i, n+1)used[i] = false; 

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

        if(used[i])continue;

        pos[i] = 0;

        if(!dfs(i)){

            cout << "No";

            return 0;

        }

    }

    cout << "Yes";

}

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

 

#define rep(i,n) for(ll i=0;i<n;++i)

#define ALL(a) (a).begin(),(a).end()

 

using namespace std;

using ll  = long long;

using pll = pair<ll, ll>;

using pdd = pair<double, double>;

 

const ll MOD  = 1e9 + 7;

const ll LINF = 1LL << 60;

const int INF = 1e9 + 7;



template<class Abel> struct UnionFind {

    vector<int> par;

    vector<int> rank;

    vector<Abel> diff_weight;



    UnionFind(int n = 1, Abel SUM_UNITY = 0) {

        init(n, SUM_UNITY);

    }



    void init(int n = 1, Abel SUM_UNITY = 0) {

        par.resize(n); rank.resize(n); diff_weight.resize(n);

        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;

    }



    int root(int x) {

        if (par[x] == x) {

            return x;

        }

        else {

            int r = root(par[x]);

            diff_weight[x] += diff_weight[par[x]];

            return par[x] = r;

        }

    }



    Abel weight(int x) {

        root(x);

        return diff_weight[x];

    }



    bool issame(int x, int y) {

        return root(x) == root(y);

    }



    bool merge(int x, int y, Abel w) {

        w += weight(x); w -= weight(y);

        x = root(x); y = root(y);

        if (x == y) return false;

        if (rank[x] < rank[y]) swap(x, y), w = -w;

        if (rank[x] == rank[y]) ++rank[x];

        par[y] = x;

        diff_weight[y] = w;

        return true;

    }



    Abel diff(int x, int y) {

        return weight(y) - weight(x);

    }

};



int main(){

    ll n, m;

    cin >> n >> m;



    vector<ll> l(n), r(n), d(n);



    UnionFind<ll> uf(n);



    rep(i, m){

        ll l, r, d;

        cin >> l >> r >> d;

        

        l--, r--;

        if(uf.issame(l, r) && d != uf.diff(l, r)){

            cout << "No\n";

            return 0;

        }

        else {

            uf.merge(l, r, d);

        }

    }



    cout << "Yes\n";

}