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

using namespace std;

typedef pair<int, int> P;



const int MAX_N = 1e5 + 1;

const int MAX_M = 2 * 1e5 + 2;



bool is_checked[MAX_N];

int parent[MAX_N], dist[MAX_N];

vector<P> graph[MAX_N];



bool bfs(int root) {

    queue<P> Q;

    Q.push(P(root, 0));

    while (!Q.empty()) {

        P now = Q.front();

        Q.pop();

        int node = now.first, cost = now.second;

        if (dist[node] == 0) dist[node] = cost;

        else if (dist[node] != cost) {

            return false;

        }

        if (is_checked[node]) continue;

        

        for (int i = 0; i < graph[node].size(); i++) {

            if (is_checked[graph[node][i].first]) {

                if (dist[graph[node][i].first] != graph[node][i].second + cost) {

                    return false;

                }

            }

            else Q.push(P(graph[node][i].first, graph[node][i].second + cost));

        }

        is_checked[node] = true;

    }

    return true;

}



int main() {

    int N, M, L, R, D;

    cin >> N >> M;

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

        cin >> L >> R >> D;

        parent[R] = L;

        graph[L].push_back(P(R, D));

    }

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

        if (parent[i] == 0 && !is_checked[i]) {

            if (!bfs(i)) {

                cout << "No" << endl;

                return 0;

            }

        }

    }

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

        if (!is_checked[i]) {

            cout << "No" << endl;

            return 0;

        }

    }

    cout << "Yes" << endl;

    return 0;

}


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

using namespace std;

typedef long long ll;

//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }



// cf https://qiita.com/drken/items/cce6fc5c579051e64fab

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);

    }



    // weight[y] - weight[x] = w になるようにマージする（順番に注意）

    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(){

    int N, M; cin >> N >> M;



    UnionFind<int> uni(N);

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

        int l, r, w; cin >> l >> r >> w;

        l--; r--;



        if(uni.issame(l, r)){

            if(uni.diff(l, r) != w){

                cout << "No" << endl;

                return 0;

            }

        }

        else {

            uni.merge(l, r, w);

        }

    }



    cout << "Yes" << endl;

}