#include <bits/stdc++.h>
using namespace std;
int x[100005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<pair<pair<int, int>, int> > v;
  for (int i = (0); i < (M); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    l--;
    r--;
    v.push_back(pair<pair<int, int>, int>(pair<int, int>(l, r), d));
  }
  for (int i = (0); i < (N); ++i) {
    x[i] = -1e9;
  }
  sort(v.begin(), v.end());
  for (int i = (0); i < (M); ++i) {
    int l = v[i].first.first;
    int r = v[i].first.second;
    int d = v[i].second;
    if (x[l] != -1e9 && x[r] != -1e9) {
      if (x[l] + d != x[r]) {
        cout << "No" << endl;
        return 0;
      }
    } else if (x[l] != -1e9) {
      x[r] = x[l] + d;
    } else if (x[r] != -1e9) {
      x[l] = x[r] - d;
    } else {
      x[l] = 0;
      x[r] = d;
    }
  }
  cout << "Yes" << endl;
}
