#include <bits/stdc++.h>
int fa[100005], dis[100005];
int find(int x) {
  if (fa[x] == x) return x;
  int ret = find(fa[x]);
  dis[x] += dis[fa[x]];
  return fa[x] = ret;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (; m--;) {
    int l, r, d;
    scanf("%d%d%d", &l, &r, &d);
    if (find(l) == find(r)) {
      if (d != dis[r] - dis[l]) return printf("No"), 0;
    } else {
      if (d < dis[r])
        dis[l] = dis[r] - d, fa[l] = fa[r];
      else
        dis[fa[r]] = d - dis[r], fa[fa[r]] = l;
    }
  }
  for (int i = 1; i <= n; i++) {
    find(i);
    if (dis[i] > 1000000000) return printf("No"), 0;
  }
  printf("Yes");
  return 0;
}
