#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll INF = 1001001001;
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n, -1);
  set<tuple<int, int, int>> st;
  for (int i = 0; i < m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    if (l > r) {
      swap(l, r);
      d = -d;
    }
    --l;
    --r;
    st.insert(make_tuple(l, r, d));
  }
  bool ok = true;
  for (auto tpl : st) {
    int l = get<0>(tpl), r = get<1>(tpl), dist = get<2>(tpl);
    if (a[l] != -1 && a[r] != -1) {
      if (a[r] - a[l] == dist) continue;
      ok = false;
      break;
    } else if (a[l] != -1) {
      a[r] = a[l] + dist;
    } else if (a[r] != -1) {
      a[l] = a[r] - dist;
    } else {
      a[l] = 0;
      a[r] = dist;
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
