#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1000000007;
const long long gosenchou = 5000000000000000;
short gh[2][4] = {{0, 0, -1, 1}, {-1, 1, 0, 0}};
struct P {
  long long pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
  long long to, cost;
};
struct E {
  long long from, to, cost;
};
bool operator<(E a, E b) { return a.cost < b.cost; }
struct H {
  long long x, y;
};
bool operator<(H a, H b) {
  if (a.x != b.x) return a.x < b.x;
  return a.y < b.y;
}
bool operator>(H a, H b) {
  if (a.x != b.x) return a.x > b.x;
  return a.y > b.y;
}
bool operator==(H a, H b) { return a.x == b.x && a.y == b.y; }
bool operator!=(H a, H b) { return a.x != b.x || a.y != b.y; }
long long gcm(long long i, long long j) {
  if (i > j) swap(i, j);
  if (i == 0) return j;
  return gcm(j % i, i);
}
long double rad(H a, H b) {
  return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}
long long ari(long long a, long long b, long long c) { return (a + b) * c / 2; }
bool suf(long double a, long double b, long double c, long double d) {
  if (b <= c || d <= a) return 0;
  return 1;
}
long long fact(long long i, long long z) {
  long long sum = 1;
  for (long long j = max(z, 2LL); j <= i; j++) sum = (sum * j) % Mod;
  return sum;
}
long long mod_pow(long long x, long long n, long long p) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % Mod;
    x = x * x % p;
    n >>= 1;
  }
  return res;
}
const long long inf = 4523372036854775807;
const long long iinf = 1500000000;
long long n, m;
vector<B> e[100001];
long long a[100001];
signed main() {
  cin >> n >> m;
  for (long long i = 1; i < n; i++) a[i] = inf;
  for (long long i = 0; i < m; i++) {
    long long l, r, d;
    cin >> l >> r >> d;
    e[l].push_back(B{r, d});
  }
  queue<long long> q;
  q.push(1);
  while (!q.empty()) {
    long long t = q.front();
    q.pop();
    for (long long i = 0; i < e[t].size(); i++) {
      if (a[e[t][i].to] == inf) {
        a[e[t][i].to] = a[t] + e[t][i].to;
        q.push(e[t][i].to);
      } else {
        if (a[e[t][i].to] != a[t] + e[t][i].cost) {
          cout << "No\n";
          return 0;
        }
      }
    }
  }
  cout << "Yes\n";
  getchar();
  getchar();
}
