// 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.5288131216291054x):
#include <bits/stdc++.h>



using namespace std;



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

#define all(v) v.begin(),v.end()

#define _GLIBCXX_DEBUG



using ll = long long;

using vi = vector<int>;

using vll = vector<ll>;

using vd = vector<double>;

using vvi = vector<vi>;

using vvll = vector<vll>;

using vvd = vector<vd>;

using vvvi = vector<vvi>;

using vvvll = vector<vvll>;

using vvvd = vector<vvd>;



const double pi=3.141592653589793;

const ll MOD=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;

    UnionFind<int> uf(n+1);

    rep(i,m){

        ll l,r,d;

        cin>>l>>r>>d;

        if (uf.root(r)!=uf.root(l)){

            uf.merge(l,r,d);

        }

        else{

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

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;



    return 0;

}

//...