#include <bits/stdc++.h>
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int l, r, d0;
  vector<vector<int>> k(n), d(n);
  for (int i = 0; i < m; i++) {
    cin >> l >> r >> d0;
    k[l - 1].push_back(r - 1);
    d[l - 1].push_back(d0);
    k[r - 1].push_back(l - 1);
    d[r - 1].push_back(-d0);
  }
  for (int i = 0; i < n; i++) {
    a[i] = 0;
  }
  while (1) {
    vector<long long> x(n);
    stack<int> s;
    for (int i = 0; i < n; i++) {
      if (a[i] == 0) {
        s.push(i);
        x[i] = 0;
        a[i] = 1;
        break;
      }
      if (i == n - 1) {
        cout << "Yes" << endl;
        return 0;
      }
    }
    long long maxx = 0;
    long long minx = 0;
    while (s.size()) {
      int z = s.top();
      s.pop();
      for (int i = 0; i < k[z].size(); i++) {
        if (a[k[z][i]] == 0) {
          a[k[z][i]] = 1;
          s.push(k[z][i]);
          x[k[z][i]] = x[z] + d[z][i];
          maxx = max(maxx, x[z] + d[z][i]);
          minx = min(minx, x[z] + d[z][i]);
        } else {
          if (x[k[z][i]] != x[z] + d[z][i]) {
            cout << "No" << endl;
            return 0;
          }
        }
      }
    }
    if (maxx - minx > 1000000000) {
      cout << "No" << endl;
      return 0;
    }
  }
}
