#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
inline void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
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;
}
template <class T>
inline void operator>>(istream& is, vector<T>& v) {
  for (int& i : v) {
    is >> i;
  }
}
template <class T>
inline void operator<<(ostream& os, const vector<T>& v) {
  for (int i : v) {
    os << i << " ";
  }
  os << endl;
}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
const int mod = 1000000007;
template <typename T>
struct weight_unionfind {
  vector<int> par, rank;
  vector<T> diff_weight;
  weight_unionfind(int n) : par(n, -1), rank(n, 0), diff_weight(n, 0) {}
  int root(int x) {
    if (par[x] < 0)
      return x;
    else {
      int r = root(par[x]);
      diff_weight[x] += diff_weight[par[x]];
      return par[x] = r;
    }
  }
  T weight(int x) {
    root(x);
    return diff_weight[x];
  }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y, T 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[x] += par[y];
    par[y] = x;
    diff_weight[y] = w;
    return true;
  }
  T diff(int x, int y) { return weight(y) - weight(x); }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  weight_unionfind<int> uf(n);
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    if (uf.same(l, r)) {
      if (uf.diff(l, r) != d) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      uf.unite(l, r, d);
    }
  }
  cout << "Yes" << endl;
}
