#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main() {
  int n, m;
  memset(a, -1, sizeof a);
  scanf("%d%d", &n, &m);
  vector<pair<pair<int, int>, int> > v;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    v.push_back(make_pair(make_pair(l, r), d));
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < m; i++) {
    int d = v[i].second;
    if (a[v[i].first.first] != -1 && a[v[i].first.second] != -1) {
      if (a[v[i].first.second] - a[v[i].first.first] == d) continue;
      puts("No");
      return 0;
    }
    if (a[v[i].first.first] == -1) a[v[i].first.first] = 0;
    if (a[v[i].first.second] == -1 ||
        a[v[i].first.second] == a[v[i].first.first] + d) {
      a[v[i].first.second] = a[v[i].first.first] + d;
      continue;
    }
    puts("No");
    return 0;
  }
  puts("Yes");
  return 0;
}
