#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  scanf("%d %d", &n, &m);
  vector<vector<pair<int, int> > > rr(n);
  vector<int> pos(n, -1);
  for (int i = 0; i < m; ++i) {
    int l, r, d;
    scanf("%d %d %d", &l, &r, &d);
    --l, --r;
    rr[l].push_back(make_pair(r, d));
    rr[r].push_back(make_pair(l, -d));
  }
  vector<bool> aleft(n, true);
  bool ans = true;
  queue<int> q;
  int i0 = 0;
  while (ans) {
    while (i0 < n && !aleft[i0]) ++i0;
    if (i0 == n) break;
    pos[i0] = 0;
    q.push(i0);
    while (!q.empty() && ans) {
      int l = q.front();
      q.pop();
      if (aleft[l]) {
        aleft[l] = false;
      }
      for (int i = 0; i < rr[l].size(); ++i) {
        int r = rr[l][i].first;
        int p = pos[l] + rr[l][i].second;
        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;
}
