#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0;
  char ch = getchar();
  while (ch < '0' || '9' < ch) ch = getchar();
  while ('0' <= ch && ch <= '9') x = x * 10 + (ch ^ 48), ch = getchar();
  return x;
}
const int N = 100009;
const int M = 200009;
int n, m, l[M], r[M], d[M];
int x[N], fa[N];
bool vis[N];
set<int> s[N];
inline int find(int x) {
  if (fa[x] == x) return x;
  return fa[x] = find(fa[x]);
}
inline void setpos(int id, int d) {
  if (vis[id] && x[id] != d) {
    puts("No");
    exit(0);
  }
  vis[id] = 1;
  x[id] = d;
}
int main() {
  if (fopen("vj.in", "r")) {
    freopen("vj.in", "r", stdin);
    freopen("vj.out", "w", stdout);
  }
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) fa[i] = i;
  for (int i = 1; i <= m; i++) {
    l[i] = read();
    r[i] = read();
    d[i] = read();
    fa[find(r[i])] = fa[find(l[i])];
    s[r[i]].insert(i);
    s[l[i]].insert(i);
  }
  for (int i = 1; i <= n; i++)
    if (fa[i] == i) {
      x[i] = 0;
      vis[i] = 1;
      for (set<int>::iterator j = s[i].begin(); j != s[i].end(); j++) {
        int id = (*j);
        if (l[id] == i) setpos(r[id], x[i] + d[id]);
      }
    }
  for (int i = 1; i <= n; i++)
    if (fa[i] != i && vis[i]) {
      for (set<int>::iterator j = s[i].begin(); j != s[i].end(); j++) {
        int id = (*j);
        if (l[id] == i)
          setpos(r[id], x[i] + d[id]);
        else if (r[id] == i)
          if (x[i] != x[l[id]] + d[id]) puts("No"), exit(0);
      }
    }
  puts("Yes");
  return 0;
}
