#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, long long int> > > v(100000);
  for (int i = 0; i < m; i++) {
    int l, r;
    long long int d;
    cin >> l >> r >> d;
    v[l].push_back(make_pair(r, d));
    v[r].push_back(make_pair(l, d));
  }
  vector<long long int> x(100001, -1);
  for (int i = 0; i < n; i++) {
    if (x[i] >= 0) continue;
    x[i] = 0;
    queue<int> qu;
    qu.push(i);
    while (!qu.empty()) {
      int now = qu.front();
      qu.pop();
      for (int j = 0; j < v[now].size(); j++) {
        int lr = v[now][j].first;
        long long int d = v[now][j].second;
        if (x[lr] == -1) {
          if (lr < now)
            x[lr] = x[now] - d;
          else
            x[lr] = x[now] + d;
          qu.push(lr);
        } else if (abs(x[lr] - x[now]) != d) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
