#include <bits/stdc++.h>
using namespace std;
struct kank {
  long long num;
  long long dx;
};
int main() {
  long long n, m;
  cin >> n >> m;
  long long l[m], r[m], d[m];
  list<kank> kanks[n + 1];
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    kank k;
    k.num = r[i];
    k.dx = d[i];
    kanks[l[i]].push_back(k);
    k.num = l[i];
    k.dx = -d[i];
    kanks[r[i]].push_back(k);
  }
  string ans = "Yes";
  long long x[n + 1];
  for (int i = 0; i < n + 1; i++) {
    x[i] = 0;
  }
  bool tukatta[n + 1];
  for (int i = 0; i < n + 1; i++) {
    tukatta[i] = false;
  }
  for (int i = 1; i <= n; i++) {
    if (tukatta[i] == false) {
      tukatta[i] = true;
      queue<long long> q;
      q.push(i);
      while (q.size()) {
        long long l = q.front();
        q.pop();
        tukatta[l] = true;
        while (kanks[l].size()) {
          kank k = kanks[l].front();
          kanks[l].pop_front();
          if (tukatta[k.num]) {
            if ((x[k.num] - x[l]) != k.dx) {
              ans = "No";
              cout << ans << endl;
              return 0;
            }
          } else {
            x[k.num] = x[l] + k.dx;
            q.push(k.num);
            tukatta[k.num] = true;
          }
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
