#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, t = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') t = -1, ch = getchar();
  while (ch <= '9' && ch >= '0') x = x * 10 + ch - 48, ch = getchar();
  return x * t;
}
int f[2000000], dis[2000000];
int n, m;
int getf(int x) {
  int tt = f[x];
  if (x == f[x]) return x;
  f[x] = getf(f[x]);
  dis[x] += dis[tt];
  return f[x];
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; ++i) f[i] = i;
  while (m--) {
    int l = read(), r = read(), D = read();
    if (getf(l) == getf(r)) {
      if (dis[r] - dis[l] != D) {
        puts("No");
        return 0;
      }
    } else {
      int u = getf(l), v = getf(r);
      int d1 = dis[l], d2 = dis[r];
      int DD = d2 - d1 - D;
      f[v] = u;
      dis[v] = abs(DD);
    }
  }
  puts("Yes");
  return 0;
}
