#include <bits/stdc++.h>
using namespace std;
int f[100005];
int dis[100005] = {0};
int findset(int x) {
  if (f[x] == x)
    return x;
  else {
    int t = f[x];
    f[x] = findset(f[x]);
    dis[x] += dis[t];
    return f[x];
  }
}
void unionset(int a, int b, int d) {
  int ll = findset(a);
  int rr = findset(b);
  if (rr != b) {
    f[rr] = ll;
    dis[rr] = dis[b] + dis[a] + d;
  }
  f[b] = ll;
  dis[b] = dis[a] + d;
}
void init(int n) {
  for (int i = 0; i <= n; i++) f[i] = i;
}
int main() {
  int n, m;
  cin >> n >> m;
  init(n);
  int l, r, d, ll, rr;
  while (m--) {
    scanf("%d%d%d", &l, &r, &d);
    ll = findset(l);
    rr = findset(r);
    if (ll == rr) {
      if (dis[r] - dis[l] != d) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      unionset(l, r, d);
    }
  }
  cout << "Yes" << endl;
}
