#include <bits/stdc++.h>
using namespace std;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
const double pi = acos(-1.0);
struct UnionFind {
  vector<int> par;
  vector<int> rank;
  vector<long long> diff_weight;
  UnionFind(int n) { init(n); }
  void init(int n) {
    par.resize(n);
    rank.resize(n);
    diff_weight.resize(n);
    for (long long i = 0; i < n; i++)
      par[i] = i, rank[i] = 0, diff_weight[i] = 0;
  }
  int root(int x) {
    if (par[x] == x) return x;
    diff_weight[x] += diff_weight[par[x]];
    return par[x] = root(par[x]);
  }
  bool issame(int x, int y) { return root(x) == root(y); }
  long long weight(int x) {
    root(x);
    return diff_weight[x];
  }
  long long diff(int x, int y) { return weight(y) - weight(x); }
  bool merge(int x, int y, long long w) {
    w += weight(x);
    w -= weight(y);
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (rank[x] < rank[y]) swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }
};
int main() {
  long long n, m;
  cin >> n >> m;
  UnionFind uf(n);
  for (long long i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (uf.issame(l, r) && d != uf.diff(l, r)) {
      cout << "No" << endl;
      return 0;
    }
    uf.merge(l, r, d);
  }
  cout << "Yes" << endl;
}
