#include <bits/stdc++.h>
using namespace std;
long long int n, m, k = 1, p[100010], chk[100010];
struct JK {
  long long int l, r, d;
} a[200020];
queue<JK> q;
unordered_map<long long int, bool> done[100010];
bool cmp(JK x, JK y) {
  if (x.l == y.l) return x.r < y.r;
  return x.l < y.l;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> a[i].l >> a[i].r >> a[i].d;
  }
  sort(a, a + m, cmp);
  p[a[0].l] = 0, p[a[0].r] = a[0].d;
  chk[a[0].l] = chk[a[0].r] = 1;
  for (int i = 1; i < m; i++) q.push(a[i]);
  while (!q.empty()) {
    JK now = q.front();
    q.pop();
    if (!chk[now.l] and !chk[now.r]) {
      if (done[now.l][now.r] != 1) {
        q.push(now);
        done[now.l][now.r] = 1;
      } else {
        p[now.l] = k * (1e9) + 1, p[now.r] = p[now.l] + now.d;
        chk[now.l] = chk[now.r] = 1;
        k++;
      }
      continue;
    }
    if (chk[now.l] and chk[now.r]) {
      if (p[now.r] - p[now.l] != now.d) return cout << "No\n", 0;
      continue;
    }
    if (chk[now.l]) {
      chk[now.r] = 1;
      p[now.r] = p[now.l] + now.d;
      continue;
    }
    if (chk[now.r]) {
      chk[now.l] = 1;
      p[now.l] = p[now.r] - now.d;
      continue;
    }
  }
  cout << "Yes\n";
}
