#include <bits/stdc++.h>
using namespace std;
const int N = 100009;
const int M = 200009;
int n, m, l, r, d;
int x[N], fa[N];
long long 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);
  }
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) fa[i] = i, dis[i] = 0;
  for (int i = 1; i <= m; i++) {
    scanf("%d%d%d", &l, &r, &d);
    int fl = fa[find(l)], fr = fa[find(r)];
    if (fl != fr) {
      int dl = dis[l], dr = dis[r];
      if (dl + d >= dr) {
        fa[find(fr)] = find(fl);
        dis[fa[find(fr)]] = dl + d - dr;
      } else {
        fa[find(fl)] = find(fr);
        dis[find(fl)] = dr - dl - d;
      }
    } else if (dis[l] + d != dis[r]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}
