#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
const long long int INF = 1e9;
const long long int MAXN = 1e5;
struct point {
  int r, l, d;
  point() { r = 0, l = 0, d = 0; }
  bool operator<(const point& e) const { return r < e.r; }
};
int main() {
  int n, m;
  point p[MAXN];
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> p[i].r >> p[i].l >> p[i].d;
  }
  sort(p, p + m);
  int dist[MAXN + 1] = {0};
  bool check[MAXN + 1] = {false};
  for (int i = 0; i < m; i++) {
    if (check[p[i].l]) {
      int x = dist[p[i].r] + p[i].d;
      if (dist[p[i].l] != x) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      dist[p[i].l] = dist[p[i].r] + p[i].d;
      check[p[i].l] = true;
      check[p[i].r] = true;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
