#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, cost;
};
vector<edge> G[100005];
long long l[200005], r[200005], c[200005];
long long d[100005];
vector<pair<pair<long long, long long>, long long>> V;
signed main() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> c[i];
    if (l[i] > r[i]) {
      swap(l[i], r[i]);
      c[i] *= -1;
    }
    V.push_back(make_pair(pair<long long, long long>(l[i], r[i]), c[i]));
  }
  sort(V.begin(), V.end());
  for (long long i = 0; i < m; i++) {
    l[i] = V[i].first.first;
    r[i] = V[i].first.second;
    c[i] = V[i].second;
  }
  fill(d, d + 100005, 2105141919ll);
  const long long inf = 2105141919;
  for (long long i = 0; i < m; i++) {
    if (d[l[i]] == inf) {
      if (d[r[i]] == inf) {
        d[l[i]] = 0;
        d[r[i]] = c[i];
      } else {
        d[l[i]] = d[r[i]] - c[i];
      }
    } else {
      if (d[r[i]] == inf) {
        d[r[i]] = d[l[i]] + c[i];
      } else {
        if (d[r[i]] - d[l[i]] != c[i]) {
          puts("No");
          return 0;
        }
      }
    }
  }
  puts("Yes");
}
