#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());
  bool ok1 = true, ok2 = true;
  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 (v[i].first.second < v[i].first.first) {
        ok1 = false;
      }
      if (a[v[i].first.second] - a[v[i].first.first] == d) continue;
      ok1 = false;
    }
    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;
    }
    ok1 = false;
  }
  for (int i = 0; i < m; i++) {
    swap(v[i].first.first, v[i].first.second);
  }
  memset(a, -1, sizeof a);
  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 (v[i].first.second < v[i].first.first) {
        ok2 = false;
      }
      if (a[v[i].first.second] - a[v[i].first.first] == d) continue;
      ok2 = false;
    }
    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;
    }
    ok2 = false;
  }
  if (ok1 || ok2)
    puts("Yes");
  else
    puts("No");
  return 0;
}
