/*
* じょえチャンネル
* 高評価・チャンネル登録よろしくおねがいします！
* https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
*/

#include <bits/stdc++.h>


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


#define inf (int)(3e18)
#define int long long
#define mod (int)(1000000007)

#define intt long long
#define P pair<int,int>

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

using namespace std;

//Library
//モッドパウ
int modpow(int x, int y, int m = mod) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
            res %= m;
        }
        x = x * x % mod;
        y /= 2;
    }
    return res;
}

int mypow(int x, int y) {
    int res = 1;
    while (y) {
        if (y % 2) {
            res *= x;
        }
        x = x * x;
        y /= 2;
    }
    return res;
}
//is the number (x) a prime number?
bool prime(int x) {
    for (int i = 2; i * i <= x; i++) {
        if (!(x % i)) {
            return false;
        }
    }
    return true;
}


//saidai-kouyakusuu
inline int gcd(int x, int y) {
    if (!y) {
        return x;
    }
    return gcd(y, x % y);
}


//number of keta
int keta(int x) {
    int ans = 0;
    while (x) {
        x /= 10;
        ans++;
    }
    return ans;
}

//sum of keta
int ketasum(int x) {
    int ans = 0;
    while (x) {
        ans += x % 10;
        x /= 10;
    }
    return ans;
}

inline int lcm(int x, int y) {
    int ans = x / gcd(x, y) * y;
    return ans;
}
int twobeki(int x) {
    int ans = 0;
    while (1) {
        if (!(x & 1)) {
            ans++;
            x /= 2;
        }
        else {
            break;
        }
    }
    return ans;
}


template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
    if (lhs < rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
    if (lhs > rhs) {
        lhs = rhs;
        return 1;
    }
    return 0;
}
void Yes(){
    cout<<"Yes"<<endl;
}
void No(){
    cout<<"No"<<endl;
}
void YES(){
    cout<<"YES"<<endl;
}
void NO(){
    cout<<"NO"<<endl;
}
int yakusuu(int x){
    int ans=0;
    for (int i=1; i*i<=x; i++) {
        if (!(x%i)) {
            if (i*i==x) {
                ans++;
            }
            else ans+=2;
        }
    }
    return ans;
}


#define fin(i) scanf("%lld",&i)
#define fout(i) printf("%lld",i)
#define fendl printf("\n")
//Library-End

int n,m,l,r,d;


class weight_Union_Find {
    vector<int> par;
    vector<int> rankmy;
    vector<int> diff_weight;
public:
    weight_Union_Find(int size) {
        par = vector<int>(size);
        rankmy = vector<int>(size);
        diff_weight = vector<int>(size);
        for (int i = 0; i < size; i++) {
            par[i] = i;
        }
    }
    
    int find(int x) {
        if (par[x] == x) {
            return x;
        }
        int r = find(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = r;
    }
    
    int weight(int x) {
        find(x);
        return diff_weight[x];
    }
    
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    
    bool unite(int x, int y, int w) {
        if (same(x, y)) {
            if (weight(x) + w != weight(y))return false;
            return true;
        }
        w += weight(x); w -= weight(y);
        x = find(x);
        y = find(y);
        if (rankmy[x] < rankmy[y]) {
            swap(x, y);
            w*=-1;
        }
        
        else if (rankmy[x] == rankmy[y]) {
            rankmy[x]++;
        }
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }
    
    int diff(int x, int y) {
        if (same(x, y))return weight(y) - weight(x);
        return inf;
    }
    
};

//Union-Find-End

//Union-Find-End
signed main() {
    cin>>n>>m;
    weight_Union_Find wuni(n);
    rep(i, m){
        cin>>l>>r>>d;
        l--;
        r--;
        if (!wuni.unite(l, r, d)) {
            No();
            return 0;
        }
    }
    
    Yes();
}


Measured memory_bytes: 2560