#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> l(m), r(m), d(m);
  for (long long i = 0; i < (long long)(m); i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
  }
  vector<vector<pair<int, int>>> e(n);
  for (long long i = 0; i < (long long)(m); i++) {
    e[l[i]].push_back(pair<int, int>(r[i], d[i]));
    e[r[i]].push_back(pair<int, int>(l[i], -d[i]));
  }
  queue<int> q;
  vector<int> dd(n, INT_MAX / 2);
  vector<int> visited(n, false);
  if (m == 0) {
    cout << "Yes"
         << "\n";
    return 0;
  }
  q.push(l[0]);
  dd[l[0]] = 0;
  while (!q.empty()) {
    int p = q.front();
    q.pop();
    for (long long i = 0; i < (long long)(e[p].size()); i++) {
      int now = e[p][i].first;
      if (!visited[now]) {
        dd[now] = dd[p] + e[p][i].second;
        visited[now] = true;
        q.push(now);
      } else {
        if (dd[now] != dd[p] + e[p][i].second) {
          cout << "No"
               << "\n";
          return 0;
        }
      }
    }
  }
  cout << "Yes"
       << "\n";
  return 0;
}
