#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const long long int LINF = 1ll << 50;
template <typename T>
void printv(vector<T> const &s) {
  for (int i = (0); i < (((int)(s).size())); i++) {
    cout << s[i] << " ";
  }
  cout << endl;
}
struct Gr {
  long long int from, to, cost;
};
bool operator<(const Gr &g1, const Gr &g2) {
  if (g1.from == g2.from) {
    if (g1.to == g2.to) {
      return g1.cost < g2.cost;
    } else {
      return g1.to < g2.to;
    }
  } else {
    return g1.from < g2.from;
  }
}
int main() {
  cin.tie(0);
  cout << setprecision(10);
  long long int n, m;
  cin >> n >> m;
  vector<long long int> d(n, 0);
  vector<bool> sel(n, false);
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<Gr> g(m);
  for (int i = (0); i < (m); i++) {
    long long int l, r, c;
    cin >> l >> r >> c;
    l--;
    r--;
    if (l > r) {
      swap(l, r);
      c = -c;
    }
    Gr tmp;
    tmp.from = l;
    tmp.to = r;
    tmp.cost = c;
    g[i] = tmp;
  }
  sort((g).begin(), (g).end());
  bool ok = true;
  for (int i = (0); i < (m); i++) {
    long long int from = g[i].from, to = g[i].to, cost = g[i].cost;
    if (sel[from] && sel[to] && d[from] + cost != d[to]) {
      ok = false;
      break;
    } else if (sel[from] && sel[to]) {
      continue;
    } else if (sel[to]) {
      d[from] = d[to] - cost;
      sel[from] = true;
    } else {
      d[to] = d[from] + cost;
      sel[to] = true;
      sel[from] = true;
    }
  }
  long long int mi = LINF, ma = -LINF;
  for (int i = (0); i < (n); i++) {
    mi = min(mi, d[i]);
    ma = max(ma, d[i]);
  }
  if (!ok || ma - mi > 1000000000) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
}
