// Slower C++ solution:
#include <map>

#include <set>

#include <list>

#include <cmath>

#include <queue>

#include <stack>

#include <cstdio>

#include <string>

#include <vector>

#include <complex>

#include <cstdlib>

#include <cstring>

#include <numeric>

#include <sstream>

#include <iostream>

#include <algorithm>

#include <functional>

  

#define mp       make_pair

#define pb       push_back

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

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

  

using namespace std;

  

typedef    long long          ll;

typedef    unsigned long long ull;

typedef    vector<bool>       vb;

typedef    vector<int>        vi;

typedef    vector<vb>         vvb;

typedef    vector<vi>         vvi;

typedef    pair<int,int>      pii;

  

const int INF=1<<29;

const double EPS=1e-9;

  

const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};





struct Edge {

    int t;

    int diff;

};



int V[100000];

int visited[100000];

vector<vector<Edge>> E;



void dfs(int v) {

    visited[v] = 1;

    for(int i = 0; i < E[v].size(); i++) {

        if (visited[E[v][i].t] == 0) {

            V[E[v][i].t] = V[v] + E[v][i].diff;

            dfs(E[v][i].t);

        } 

    }

}



int main() {

    int N, M;

    cin >> N >> M;

    E.resize(N);

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

        int l, r;

        int d;



        cin >> l >> r >> d;

        l--, r--;



        E[l].push_back((Edge){r, d});

        E[r].push_back((Edge){l, -d});

    }



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

        V[i] = 0;

        visited[i] = 0;

    }



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

        if (visited[i] == 0) {

            dfs(i);

        }

    }



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

        for(int j = 0; j < E[i].size(); j++) {

            if (V[E[i][j].t] - V[i] != E[i][j].diff) {

                cout << "No" << endl;

                return 0;

            }



        }

    }



    cout << "Yes" << endl;





    return 0;

}

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



using namespace std;

#define pb push_back

#define mp make_pair

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

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

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int,int> pii;

constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};



template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}



struct UnionFindWeighted {

    vector<int> p;

    vector<ll> w;



    UnionFindWeighted(int n) : p(n, -1), w(n, 0) {

    }



    // w[v] - w[u] = weight

    bool UnionSet(int u, int v, ll weight) {

        int ru = root(u);

        int rv = root(v);

        if (ru == rv) return w[u] - w[v] == weight;



        w[ru] = weight - w[u] + w[v];

        p[rv] += p[ru];

        p[ru] = rv;

        return true;

    }



    pair<ll, int> find(int u, int v) {

        int ru = root(u);

        int rv = root(v);

        if (ru != rv) return {0, -1};

        return {w[u] - w[v], 0};

    }



    bool isSame(int u, int v) {

        return root(u) == root(v);

    }



    int size(int x) {

        return -p[root(x)];

    }

    int root(int x) {

        if (p[x] < 0) {

            return x;

        } else {

            int r = root(p[x]);

            w[x] += w[p[x]];

            p[x] = r;

            return r;

        }

    }



};





void solve() {

    int N, M;

    cin >> N >> M;

    UnionFindWeighted uf(N);

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

        int l, r; ll d;

        cin >> l >> r >> d;

        l--, r--;

        if (!uf.UnionSet(l, r, d)) {

            cout << "No" << endl;

            return;

        }

    }

    cout << "Yes" << endl;



}



int main() {

    std::cin.tie(0);

    std::ios::sync_with_stdio(false);

    cout.setf(ios::fixed);

    cout.precision(16);

    solve();

    return 0;

}