#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (a < b) swap(a, b);
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
  long long g = gcd(a, b);
  return a / g * b;
}
long long factorial(long long n) {
  long long t = 1;
  for (long long(i) = 1; (i) <= (n); ++(i)) t *= i;
  return t;
}
long long combinations(long long n, long long k) {
  long long r = 1;
  for (long long(i) = 1; (i) <= (k); ++(i)) r = r * n-- / i;
  return r;
}
int main() {
  long long n, m;
  cin >> n >> m;
  vector<pair<long long, pair<long long, long long>>> p(m);
  for (long long(i) = 0; (i) < (m); ++(i)) {
    long long a, b, c;
    cin >> a >> b >> c;
    if (a > b) {
      swap(a, b);
      c *= -1;
    }
    p[i] = make_pair(a, make_pair(b, c));
  }
  vector<long long> pos(n + 1, 0);
  sort((p).begin(), (p).end());
  for (long long(i) = 0; (i) < (m); ++(i)) {
    long long l = p[i].first, r = p[i].second.first, d = p[i].second.second;
    if (pos[r] != 0 && pos[l] + d != pos[r]) {
      cout << ("No") << endl;
      return 0;
    } else {
      pos[r] = pos[l] + d;
    }
  }
  cout << ("Yes") << endl;
  return 0;
}
