#include <bits/stdc++.h>
using namespace std;
int para[100005];
int rnka[100005];
map<pair<int, int>, int> D;
int find(int x) {
  if (para[x] == x)
    return x;
  else
    return para[x] = find(para[x]);
}
void unite(int x, int y) {
  x = find(x);
  y = find(y);
  if (x == y) return;
  para[x] = y;
}
bool isSame(int x, int y) { return find(x) == find(y); }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  bool ok = true;
  for (int i = (0); i < (100005); ++i) para[i] = i;
  for (int i = (0); i < (100005); ++i) D[pair<int, int>(i, i)] = 0;
  for (int i = (0); i < (M); ++i) {
    int l, r, d;
    cin >> l >> r >> d;
    int p = find(l);
    if (D.count(pair<int, int>(r, p))) ok = false;
    if (D.count(pair<int, int>(l, r))) {
      if (D[pair<int, int>(l, r)] != d) ok = false;
    } else {
      if (D.count(pair<int, int>(p, r)) == 0) {
        D[pair<int, int>(l, r)] = d;
        D[pair<int, int>(p, r)] = d + D[pair<int, int>(p, l)];
      } else {
        if (D[pair<int, int>(p, l)] + d != D[pair<int, int>(p, r)]) ok = false;
      }
    }
    unite(l, r);
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
