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

#define int long long

#define x first

#define y second





using namespace std;



vector<int> color(1e5 + 1);



int get_color(int x){

    //cout << x << endl;

    if(x == color[x]){

        return x;

    }

    return color[x] =  get_color(color[x]);

}



void update(int x, int y){

    if(get_color(x) != get_color(y)){

        //cout << x << ' ' << y << endl;

        color[get_color(x)] = get_color(y);

    }

}



bool comp(vector<int> x, vector<int> y){

    return min(x[0], x[1]) < min(y[0], y[1]);

}



void check(vector<int> sv, vector<vector<int> > og){

    int n = sv.size();

    int mi = 0, ma = 0;

    if(og.size() == 0){

        return;

    }

    map<int, int> c;

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

        c[sv[i]] =i;

    }

    vector<int> used(n,  0), x(n, 0);

    used[0] = 1;

    vector<vector<vector<int> > > dop(n);

    for(auto it : og){

        dop[c[it[0]]].push_back(it);

        dop[c[it[1]]].push_back(it);

    }

    queue<vector<int> > d;

    for(auto it : dop[0]){

        d.push(it);

    }

    while(!d.empty()){

        auto it = d.front();

        d.pop();

        int t = c[it[0]], t1 = c[it[1]];

        if(used[t] == 0){

            swap(t, t1);

            it[2] = -it[2];

        }

        if(used[t1] == 0){

            for(auto it1 : dop[t1]){

                if(it1 != it)

                d.push(it1);

            }

        }

        if(used[t1] == 1 && x[t1] != x[t] + it[2]){

            cout << "No";

            exit(0);

        }

        if(used[t] == 0){

            exit(-1);

        }

        used[t1] = 1;

        x[t1] = x[t] + it[2];

    }

    for(auto it : x){

        mi = min(it, mi);

        ma = max(it, ma);

    }

    if(ma - mi > 1e9){

        cout << "No";

        exit(0);

    }

}



void solve(){

    int n, q;

    cin >> n >> q;

    vector<vector<int> > e(q);

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

        color[i] = i;

    }

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

        int l, r, d;

        cin >> l >> r >> d;

        e[i] = {--l, --r, d};

        update(l, r);

        //cout << color[0] << ' ' << color[1] <<' ' << color[2] << endl;

    }

    vector<vector<int> > sv(n);

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

        sv[get_color(i)].push_back(i);

    }

   vector<vector<vector<int> > > og(n);

   for(auto it : e){

        og[get_color(it[0])].push_back(it);

   }

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

    sort(og[i].begin(), og[i].end(), comp);

    //out << "rhgingk" <<  endl;

    check(sv[i], og[i]);

   }

   cout << "Yes";

}





signed main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    int test = 1;

    //freopen("output.txt", "w", stdout);

    //freopen("input.txt", "r", stdin);

    //

    //cin >> test;

    while(test--){

        solve();

    }

}


// Faster C++ solution for the same problem (measured speedup: 1.863619432617933x):
#include <cstdio>

#include <iostream>

#include <set>

#include <map>

#include <algorithm>

#include <string>

#include <cstring>

//purvikaurraina

using namespace std;

const int maxn = 2e5 + 100;

int f[maxn];

int d[maxn];

int ff(int x){

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

    int a = f[x];

    int b = ff(f[x]);

    d[x] += d[a]; 

    f[x] = b;

    return b;

}

//purvikaurraina

int unit(int x,int y,int z){

    int fx = ff(x);

    int fy = ff(y);

    if (fx == fy){

        return (d[y] - d[x]) == z;

    }

    f[fy] = fx;

    d[fy] = d[x] + z -d[y];

    return 1;

}

int main(){

    int n,m;

    scanf("%d%d",&n,&m);

    for (int i = 1; i <= n; i++) f[i] = i;

    int flag = 0;

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

        int x,y,d;

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

        if (!unit(x,y,d))

        {

            flag = 1;

        }

    }

    if (flag) printf("No\n");

    else printf("Yes\n");

}