#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 = 100000;
struct point {
  long long int r, l, d;
  point() { r = 0, l = 0, d = 0; }
  bool operator<(const point& e) const { return r < e.r; }
};
int main() {
  long long int n, m;
  vector<point> p;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    long long int a, b, c;
    cin >> a >> b >> c;
    point pp;
    pp.r = a, pp.l = b, pp.d = c;
    p.push_back(pp);
  }
  sort(p.begin(), p.end());
  vector<long long int> dist(n + 1);
  bool check[MAXN + 1] = {false};
  for (int i = 0; i <= n; i++) {
    dist[i] = 0;
  }
  for (int i = 0; i < m; i++) {
    if (check[p[i].l]) {
      long long int x = dist[p[i].r] + p[i].d;
      if (dist[p[i].l] != x) {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (p[i].l < p[i].r) {
        dist[p[i].r] = dist[p[i].l] - p[i].d;
      } 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;
}
