#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 100005;
long long fa[MAXN], jl[MAXN];
long long n, m;
long long find(long long x) {
  if (fa[x] == x) return x;
  long long f = find(fa[x]);
  jl[x] = jl[fa[x]] + jl[x];
  fa[x] = f;
  return f;
}
int main() {
  scanf("%I64d %I64d", &n, &m);
  for (long long i = 1; i <= n; i++) fa[i] = i, jl[i] = 0;
  for (long long i = 1; i <= m; i++) {
    long long l, r, d;
    scanf("%I64d %I64d %I64d", &l, &r, &d);
    long long a = find(l), b = find(r);
    if (a == b) {
      if (((jl[l] - jl[r]) > 0 ? (jl[l] - jl[r]) : (jl[r] - jl[l])) != d) {
        printf("No\n");
        return 0;
      }
    } else {
      fa[b] = a;
      jl[b] = -d + jl[l] + jl[r];
    }
  }
  printf("Yes\n");
}
