#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 5;
const long long M = 2e5 + 5;
long long n, m;
long long fa[N], dis[N];
long long find(long long x) {
  if (fa[x] == x) return x;
  long long f = fa[x], dt = dis[x] - dis[f];
  fa[x] = find(fa[x]);
  dis[x] = dis[f] + dt;
  return fa[x];
}
bool merge(long long a, long long b, long long d) {
  long long f1 = find(a), d1 = dis[a];
  long long f2 = find(b), d2 = dis[b];
  if (f1 == f2 && dis[b] - dis[a] != d) return false;
  fa[f2] = f1;
  dis[f2] = d1 + d - d2;
  return true;
}
signed main() {
  scanf("%lld%lld", &n, &m);
  for (long long i = 1; i <= n; i++) fa[i] = i, dis[i] = 0;
  while (m--) {
    long long l, r, d;
    scanf("%lld%lld%lld", &l, &r, &d);
    if (!merge(l, r, d)) return puts("No"), 0;
  }
  return puts("Yes"), 0;
}
