#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;
vector<vector<pair<int, int>>> dp(100001);
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  for (long long i = 0; i < (M); i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (dp[r].size() == 0 && dp[l].size() == 0) {
      dp[r].push_back({l, d});
      dp[l].push_back({r, d});
    } else if (dp[r].size() == 0) {
      dp[r].push_back({l, d});
      for (auto p : dp[l]) {
        dp[r].push_back({p.first, p.second + d});
      }
      dp[l].push_back({r, d});
    } else if (dp[l].size() == 0) {
      dp[r].push_back({l, d});
      dp[l].push_back({r, d});
    } else {
      for (auto p : dp[l]) {
        if (p.first == r && p.second != d) {
          cout << "No" << endl;
          return 0;
        }
      }
      for (auto p : dp[r]) {
        if (p.first == l && p.second != d) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
