#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e12;
const long long MOD = 1e9 + 7;
double sq(double num) { return num * num; }
long long mod_pow(long long x, long long n) {
  if (n == 0) return 1;
  if (n == 1) return x % MOD;
  long long res = sq(mod_pow(x, n / 2));
  res %= MOD;
  if (n % 2 == 1) {
    res *= x;
    res %= MOD;
  }
  return res;
}
long long mod_add(long long a, long long b) { return (a + b) % MOD; }
long long mod_sub(long long a, long long b) { return (a - b + MOD) % MOD; }
long long mod_mul(long long a, long long b) { return a * b % MOD; }
int n, m;
map<pair<long long, long long>, long long> mpl;
long long pos[100100];
int main() {
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  long long MIN = INF;
  for (int i = 0; i < (m); i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    mpl[{l, r}] = d;
    MIN = min(MIN, l);
  }
  fill(pos, pos + 100100, INF);
  pos[MIN] = 0;
  bool f = 1;
  long long MAX = 0;
  for (auto it = mpl.begin(); it != mpl.end(); it++) {
    long long from = it->first.first;
    long long to = it->first.second;
    long long cost = it->second;
    if (pos[from] != INF) {
      if (pos[to] != INF) {
        if (pos[to] - pos[from] != cost) f = 0;
      } else {
        pos[to] = cost + pos[from];
        MAX = max(pos[to] + 1, MAX);
      }
    } else {
      pos[from] = MAX;
    }
  }
  if (f)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
