#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, r, d;
int x[N], fa[N], dis[N];
inline int find(int x) {
  if (fa[x] == x) return x;
  int ret = find(fa[x]);
  dis[x] = dis[ret] + dis[x];
  return fa[x] = ret;
}
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 = read();
    r = read();
    d = read();
    int fl = find(l), fr = find(r);
    if (fl != fr) {
      int dl = dis[l], dr = dis[r];
      if (dl + d >= dr) {
        fa[fr] = fl;
        dis[fr] = dl + d - dr;
      } else {
        fa[fl] = fr;
        dis[fl] = dr - dl - d;
      }
    } else if (dis[l] + d != dis[r])
      puts("No"), exit(0);
  }
  puts("Yes");
  return 0;
}
