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

#include <cstdio>

#include <cstring>

#include <vector>

using namespace std;

const int N = 1e5+10;

int n,m;

int dis[N];

bool vis[N];

vector<pair<int,int> >E[N];

bool dfs(int u){

    vis[u] = 1;

    vector<pair<int,int> >::iterator it;

    for(it = E[u].begin(); it != E[u].end(); it++){

        int v = (*it).first;

        int d = (*it).second;

        if(!vis[v]){

            dis[v] = dis[u] + d;

            if(!dfs(v))

                return false;

        }

        else if(dis[u]+d!=dis[v])

            return false;

    }

    return true;

}

int main(){

    cin >> n >> m;

    int u,v,w;

    int i;

    for(i = 1; i <= m; i++){

        cin >> u >> v >> w;

        E[u].push_back(make_pair(v,w));

        E[v].push_back(make_pair(u,-w));

    }

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

        if(!vis[i]){

            if(!dfs(i)){

                cout << "No" << endl;

                return 0;

            }

        }

    }

    cout << "Yes" << endl;

    return 0;

}


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

}

//...