#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100000 + 10;
int par[MAXN], L[MAXN << 1], R[MAXN << 1], D[MAXN << 1];
int lft[MAXN], rght[MAXN], dist[MAXN];
int find(int i) {
  if (par[i] == i) return i;
  return par[i] = find(par[i]);
}
void add(int i, int j) {
  int a = find(i);
  int b = find(j);
  par[a] = b;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    par[i] = i;
    dist[i] = INT_MAX;
  }
  for (int i = 0; i < m; i++) {
    cin >> L[i] >> R[i] >> D[i];
    add(L[i], R[i]);
  }
  int cnt = 0;
  while (cnt < m) {
    for (int i = 0; i < m && cnt < m; i++) {
      if (L[i] == -1) continue;
      int p = find(L[i]);
      if (dist[L[i]] == INT_MAX && dist[R[i]] == INT_MAX && L[i] != p &&
          R[i] != p)
        continue;
      cnt++;
      if (L[i] == p) dist[L[i]] = 0;
      if (R[i] == p) dist[R[i]] = 0;
      if (dist[L[i]] != INT_MAX && dist[R[i]] != INT_MAX) {
        if (dist[R[i]] - dist[L[i]] != D[i]) {
          cout << "No" << endl;
          return 0;
        }
        L[i] = -1;
        continue;
      }
      if (dist[L[i]] != INT_MAX) {
        dist[R[i]] = dist[L[i]] + D[i];
      } else if (dist[R[i]] != INT_MAX) {
        dist[L[i]] = dist[R[i]] - D[i];
      }
      L[i] = -1;
      lft[p] = min(lft[p], dist[L[i]]);
      rght[p] = max(rght[p], dist[R[i]]);
      if (rght[p] - lft[p] > 1e9) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
