/*
 * Created by KeigoOgawa
 */


#include <cstdio>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <cmath>

#define INF (int)1e8
#define EPS 1e-10
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define RFOR(i, a, b) for (ll i = (b)-1; i >= (a); i--)
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define MIN(a, b) (a > b ? b : a)
#define MAX(a, b) (a > b ? a : b)
#define debug(x) cerr << #x << ": " << x << endl
#define all(a) (a).begin(), (a).end()

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int, int> PII;

// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len - 1) s << "\t";
    }
    return s;
}

// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
    int len = vv.size();
    for (int i = 0; i < len; ++i) {
        s << vv[i] << endl;
    }
    return s;
}

ll N, M;
int dp[100001][100001];

int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> M;
    REP(i, N+1) {
      REP(j, N + 1) {
        dp[i][j] = -1;
      }
    }

    REP(i, M) {
      int l, r, d;
      cin >> l >> r >> d;
      // 新しいrノードは常にOK
      if (dp[r][r] == -1 && dp[l][l] == -1) {
        dp[r][r] = 0;
        dp[l][l] = 0;
        dp[r][l] = d;
        dp[l][r] = d;
      } else if (dp[r][r] == -1) {
        dp[r][r] = 0;
        dp[r][l] = d;
        dp[l][r] = d;
        REP(i, N+1) {
          if (dp[l][i] != -1) {
            dp[r][i] = dp[l][i] + d;
            dp[l][r] = dp[r][i];
          }
        }
      } else if (dp[l][l] == -1) {
        dp[l][l] = 0;
        dp[r][l] = d;
        dp[l][r] = d;
      } else {
        // どっちもすでにあるノード
        if (dp[r][l] != d) {
          cout << "No" << endl;
          return 0;
        }
      }

    }

    cout << "Yes" << endl;

    return 0;
}
