#include <bits/stdc++.h>
using namespace std;
long long int num[100000] = {0}, pro[100000] = {0}, rel[100000] = {0},
              kk[100000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, i, m;
  cin >> n >> m;
  long long int l, r, d;
  for (i = 0; i < m; i++) {
    cin >> l >> r >> d;
    long long int po = l, to = r;
    long long int dis1 = 0, dis2 = 0;
    while (num[po]) {
      dis1 += pro[po];
      po = num[po];
    }
    while (num[to]) {
      dis2 += pro[to];
      to = num[to];
    }
    if (po == to) {
      if (dis2 - dis1 != d) {
        cout << "No";
        return 0;
      }
      continue;
    }
    num[to] = po;
    pro[to] = d - dis2 + dis1;
  }
  cout << "Yes";
  return 0;
}
