#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int> > rr(n);
  vector<vector<int> > rd(n);
  vector<int> pos(n, -1);
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    --l, --r;
    rr[l].push_back(r);
    rd[l].push_back(d);
  }
  set<int> left;
  vector<bool> aleft(n, true);
  for (int i = 0; i < n; ++i) left.insert(i);
  bool ans = true;
  while (!left.empty() && ans) {
    int i0 = *left.begin();
    queue<int> q;
    pos[i0] = 0;
    q.push(i0);
    while (!q.empty() && ans) {
      int l = q.front();
      q.pop();
      if (aleft[l]) {
        left.erase(left.find(l));
        aleft[l] = false;
      }
      for (int i = 0; i < rr[l].size(); ++i) {
        int r = rr[l][i];
        int p = pos[l] + rd[l][i];
        if (pos[r] != -1 && p != pos[r]) ans = false;
        if (pos[r] == -1) q.push(r);
        pos[r] = p;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << "\n";
  return 0;
}
