#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  if (k == 0) {
    cout << "Yes";
    return 0;
  }
  vector<pair<int, int> > v[100001];
  for (int i = 0; i < k; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    v[a].push_back(make_pair(b, c));
  }
  int used[100001];
  for (int i = 0; i < 100001; ++i) {
    used[i] = -1;
  }
  queue<int> q;
  for (int i = 1; i <= n; ++i) {
    if (used[i] == -1 && v[i].size() != 0) {
      used[i] = 0;
      q.push(i);
      while (!q.empty()) {
        int cur = q.front();
        q.pop();
        if (used[cur] == 0) {
          for (auto w : v[cur]) {
            if (used[w.first] != -1) {
              used[cur] = used[w.first] - w.second;
              break;
            }
          }
        }
        for (auto w : v[cur]) {
          if (used[w.first] == -1) {
            used[w.first] = w.second + used[cur];
            q.push(w.first);
          } else {
            if (used[w.first] != w.second + used[cur]) {
              cout << "No";
              return 0;
            }
          }
        }
      }
    }
  }
  cout << "Yes";
  return 0;
}
