#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
  if (p)
    cout << fixed << setprecision(p) << a << "\n";
  else
    cout << a << "\n";
}
struct edge {
  int to;
  int cost;
};
struct dist {
  int l, r, d;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N, M;
  cin >> N >> M;
  vector<vector<edge>> G(N);
  vector<int> D(N);
  vector<int> used(N);
  vector<dist> DST(M);
  for (int i = (int)(0); i < (int)(M); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--, r--;
    DST[i] = {l, r, d};
    G[l].push_back({r, d});
    G[r].push_back({l, -d});
  }
  for (int i = (int)(0); i < (int)(N); ++i) {
    if (!used[i]) {
      queue<int> q;
      q.push(i);
      while (!q.empty()) {
        int t = q.front();
        q.pop();
        used[t] = 1;
        for (edge e : G[t]) {
          D[e.to] = D[t] + e.cost;
          if (!used[e.to]) q.push(e.to);
        }
      }
    }
  }
  for (int i = (int)(0); i < (int)(M); ++i) {
    if (D[DST[i].r] - D[DST[i].l] != DST[i].d) {
      output("No");
      return 0;
    }
  }
  output("Yes");
  return 0;
}
