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

using namespace std;

typedef long long ll;

typedef long double ld;

#define X first

#define Y second

#define pb push_back

#define sz(a) (int)a.size()



void solve();



signed main() {

#ifdef ONPC

    freopen("in.txt", "r", stdin);

#endif // ONPC

    //freopen("time.in", "r", stdin);

    //freopen("time.out", "w", stdout);

    ios_base::sync_with_stdio(0), cin.tie(0);

    int t = 1;

    //cin >> t;

    while (t--) solve();

    return 0;

}



const int N = 1e5 + 5;

int n, m, kek, dist[N];

vector<pair<int, int>> g[N], gr[N];

bool used[N];

vector<int> ord;



void dfs(int v) {

    used[v] = 1;

    for (auto d : g[v]) {

        if (!used[d.X]) {

            dfs(d.X);

        }

    }

    ord.pb(v);

}



void dfs2(int v) {

    used[v] = 1;

    for (auto d : gr[v]) {

        if (!used[d.X]) {

            dfs2(d.X);

        }

    }

    ++kek;

}



void solve() {

    cin >> n >> m;

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

        int l, r, d;

        cin >> l >> r >> d;

        g[l].pb({r, d});

        gr[r].pb({l, d});

    }

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

        if (!used[i]) {

            dfs(i);

        }

    }

    reverse(ord.begin(), ord.end());

    memset(used, 0, sizeof used);

    for (auto d : ord) {

        if (!used[d]) {

            kek = 0;

            dfs2(d);

            if (kek > 1) {

                cout << "No\n";

                return;

            }

        }

    }

    for (auto d : ord) {

        if (d == ord[0]) continue;

        dist[d] = -1;

        for (auto t : gr[d]) {

            int nw = dist[t.X] + t.Y;

            if (dist[d] != -1 && nw != dist[d]) {

                cout << "No\n";

                return;

            }

            dist[d] = dist[t.X] + t.Y;

        }

    }

    cout << "Yes\n";

}


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

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/trie_policy.hpp>

#include <ext/rope>



//#pragma 03

//#pragma GCC optimize("Ofast")

//#pragma GCC optimization("unroll-loops, no-stack-protector")

//#pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2")



#define ll long long

#define ld long double

#define fi first

#define se second

#define sz(x) x.size()

#define mp make_pair

#define pb push_back

#define eb emplace_back

#define all(x) begin(x), end(x)

#define rall(x) rbegin(x), rend(x)

#define rep(i, x, n) for (ll i = x; i < n; i++)

#define fastio() ios_base::sync_with_stdio(NULL); cin.tie(0); cout.tie(0)

//#define int long long



using namespace std;

using namespace __gnu_pbds;

using namespace __gnu_cxx;



mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



typedef vector<int> vi;

typedef vector<vi> vvi;

typedef pair<int, int> ii;

typedef vector<pair<int, int> > vii;

typedef vector<ll> vl;

typedef vector<vl> vvl;

typedef pair<ll, ll> pll;

typedef vector<pll> vll;



inline void EXECUTE_TIME() {cout << endl << setprecision(10) << fixed << "CPU Time: " << clock() / double(CLOCKS_PER_SEC) << " sec(s)\n";}



template <class T> inline T RD(T &a) {T x; cin >> x; return a = x;}

template <class T> inline T gcd(T a, T b) {if (b) return gcd(b, a % b); else return a;}

template <class T> inline T lcm(T a, T b) {return a / gcd(a,b) * b;}

template<typename T> using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;



const int N = 1e5 + 1;



vector<vii> adj;

bool check[N];

int dist[N];

bool FAIL;



void dfs(int u) {

    if (!check[u]) check[u] = true;

    for (ii v : adj[u]) {

        if (!check[v.fi]) {

            dist[v.fi] = dist[u] - v.se;

            dfs(v.fi);

        } else {

            if (dist[u] - v.second != dist[v.first]) FAIL = true;

        }

    }

}



signed main() {

//    freopen("connect.in", "r", stdin);

//    freopen("connect.out", "w", stdout);

    fastio();



    int n, m; cin >> n >> m;

    adj.assign(n, vii());



    int l, r, d;

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

        cin >> l >> r >> d; l--, r--;

        adj[l].pb({r, d});

        adj[r].pb({l, -d});

    }



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

        if (!check[i]) {

            dist[i] = 0;

            dfs(i);

        }

    }



    if (!FAIL) cout << "Yes";

    else cout << "No";



//    EXECUTE_TIME();

}