#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int gi() {
  int x = 0, w = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') w = 0, ch = getchar();
  while (ch >= '0' && ch <= '9')
    x = (x << 3) + (x << 1) + ch - '0', ch = getchar();
  return w ? x : -x;
}
int n, m, fa[N], dis[N];
int find(int x) {
  int ff = fa[x];
  if (x == fa[x]) return x;
  fa[x] = find(fa[x]);
  dis[x] += dis[ff];
  return fa[x];
}
int main() {
  n = gi();
  m = gi();
  for (int i = 1; i <= n; i++) fa[i] = i;
  while (m--) {
    int l = gi(), r = gi(), d = gi();
    if (find(l) ^ find(r)) {
      int fl = find(l), fr = find(r);
      int dd = dis[l] - dis[r] + d;
      if (dd < 0) swap(fl, fr);
      fa[fr] = fl, dis[fr] = dd;
    } else {
      if (dis[r] - dis[l] != d) return puts("No"), 0;
    }
  }
  return puts("Yes"), 0;
}
