#include <bits/stdc++.h>
using namespace std;
long long pos[100005];
int ind[100005];
pair<pair<int, int>, int> query[200005];
vector<pair<pair<int, int>, int> > v;
int n, m;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= m; i++) {
    int l, r, d;
    cin >> l >> r >> d;
    query[i] = {{l, r}, d};
  }
  while (m) {
    int unsure = 0;
    for (int i = 1; i <= n; i++) {
      pos[i] = LONG_LONG_MIN;
      ind[i] = 0;
    }
    for (int i = 1; i <= m; i++) {
      int l = query[i].first.first;
      int r = query[i].first.second;
      int d = query[i].second;
      if (pos[l] != LONG_LONG_MIN && pos[r] != LONG_LONG_MIN) {
        d -= pos[r];
        d += pos[l];
        if (ind[l] == ind[r] && d) {
          puts("No");
          return 0;
        }
        v.push_back({{ind[l], ind[r]}, d});
      } else if (pos[l] != LONG_LONG_MIN) {
        ind[r] = ind[l];
        pos[r] = pos[l] + d;
      } else if (pos[r] != LONG_LONG_MIN) {
        ind[l] = ind[r];
        pos[l] = pos[r] - d;
      } else {
        unsure++;
        ind[l] = ind[r] = unsure;
        pos[l] = 0;
        pos[r] = d;
      }
    }
    m = (int)v.size();
    for (int i = 1; i <= m; i++) {
      query[i] = v[i - 1];
    }
    v.clear();
  }
  puts("Yes");
  return 0;
}
