#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

// 重み付きUnionFind
class WeightedUF {
public:
    ll tsize;
    ll mode;
    vector<ll> par;
    vector<ll> rank;
    vector<ll> w;
    WeightedUF() {}
    WeightedUF(const WeightedUF &wuft) {}
    WeightedUF(ll n, ll m = 0) {
        tsize = n;
        mode = m;
        par.resize(n, -1);
        if(!mode) rank.resize(n, 0);
        w.resize(n, 0);
    }
    ll root(ll x) {
        if(par[x] < 0) {
            return x;
        }else {
            ll r = root(par[x]);
            w[x] += w[par[x]];
            return par[x] = r;
        }
    }
    ll weight(ll x) {
        root(x);
        return w[x];
    }
    ll diff(ll x, ll y) {
        return weight(y) - weight(x);
    }
    bool isRoot(ll x) {
        return root(x) == x;
    }
    bool isSame(ll x, ll y) {
        return root(x) == root(y);
    }
    void unite(ll x, ll y, ll _w) {
        _w += weight(x);
        _w -= weight(y);
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(mode) {
            par[x] += par[y];
            par[y] = x;
        }else {
            if(rank[x] < rank[y]) {
                par[y] += par[x];
                par[x] = y;
                w[x] = -_w;
            }else {
                par[x] += par[y];
                par[y] = x;
                if(rank[x] == rank[y]) rank[x]++;
                w[y] = _w;
            }
        }
    }
    ll size(ll x) {
        return -par[root(x)];
    }
};

void solve() {
    ll N, M;
    cin >> N >> M;
    WeightedUF uf(N);
    REP(i, M) {
        ll l, r, d;
        cin >> l >> r >> d;
        l--;r--;
        if(uf.isSame(l, r)) {
            if(uf.diff(l, r) != d) {
                out("No");
                return;
            }else {
                uf.unite(l, r, d);
            }
        }else {
            uf.unite(l, r, d);
        }
    }
    out("Yes");
}

int main() {
    fast_io;
    solve();
    return 0;
}


Measured memory_bytes: 2560