#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
long long n, m, fa[N], a[N];
int find(int x) {
  if (x == fa[x]) return x;
  int t = find(fa[x]);
  a[x] += a[t];
  return fa[x] = t;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) fa[i] = i, a[i] = 0;
  long long u, v, d;
  bool ok = true;
  while (m--) {
    cin >> u >> v >> d;
    long long x = find(u), y = find(v);
    if (x != y) {
      if (x > y) {
        fa[x] = y;
        a[x] = a[v] - (a[u] + d);
      } else {
        fa[y] = x;
        a[y] = a[u] - (a[v] - d);
      }
    } else {
      long long t = a[v] - a[u];
      if (t != d) ok = false;
    }
  }
  for (int i = 1; i <= n; i++) {
    find(i);
    if (a[i] > 1e9) ok = false;
  }
  puts(ok ? "Yes" : "No");
  return 0;
}
