#include <bits/stdc++.h>
using namespace std;
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;
}
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;
}
long long N, M;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  vector<vector<int>> dp(N + 1);
  for (long long i = 0; i < (N + 1); i++) {
    dp[i].resize(N + 1);
  }
  for (long long i = 0; i < (N + 1); i++) {
    fill(dp[i].begin(), dp[i].end(), -1);
  }
  for (long long i = 0; i < (M); i++) {
    int l, r, d;
    cin >> l >> r >> d;
    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;
      for (long long i = 0; i < (N); i++) {
        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;
}
