#include <bits/stdc++.h>
using namespace std;
const long long int INF = 1e11;
int par[100000];
long long int t[100000];
int height[100000];
void init(int n) {
  for (int i = 0; i < n; i++) {
    par[i] = i;
    height[i] = 0;
  }
}
int find(int x) {
  if (par[x] == x) {
    return x;
  } else {
    return par[x] = find(par[x]);
  }
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  if (height[x] < height[y]) {
    par[x] = y;
  } else {
    par[y] = x;
    if (height[x] == height[y]) height[x]++;
  }
}
bool same(int x, int y) { return find(x) == find(y); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  if (M == 0)
    cout << "Yes"
         << "\n";
  else {
    for (int i = int(0); i < int(N); i++) {
      t[i] = INF;
    }
    init(N);
    for (int i = int(0); i < int(M); i++) {
      int l, r, d;
      cin >> l >> r >> d;
      l--;
      r--;
      if (i == 0) {
        t[l] = 0;
        t[r] = d;
        unite(l, r);
      } else {
        if (same(l, r)) {
          if (t[r] - t[l] != d) {
            cout << "No"
                 << "\n";
            return 0;
          }
        } else {
          if (t[l] == INF && t[r] == INF) {
            t[l] = 0;
            t[r] = d;
          }
          if (t[l] != INF && t[r] == INF) {
            t[r] = t[l] + d;
          }
          if (t[l] == INF && t[r] != INF) {
            t[l] = t[r] - d;
          } else {
            for (int i = int(0); i < int(N); i++) {
              if (same(i, r)) t[i] += t[r] - t[l] - d;
            }
          }
          unite(l, r);
        }
      }
    }
    cout << "Yes"
         << "\n";
  }
}
