#include <bits/stdc++.h>
using namespace std;
struct man {
  int l, r, d;
};
bool comp(const man& e1, const man& e2) {
  if (e1.l < e2.l) {
    return true;
  } else if (e1.l > e2.l) {
    return false;
  } else {
    if (e1.r < e2.r) {
      return true;
    } else {
      return false;
    }
  }
}
man es[214514];
int main() {
  int N, M;
  int x[114514];
  for (int i = 0; i < (114514); i++) {
    x[i] = 810114514;
  }
  int L, R, D;
  cin >> N >> M;
  for (int i = 0; i < (M); i++) {
    cin >> L >> R >> D;
    es[i].l = L;
    es[i].r = R;
    es[i].d = D;
  }
  sort(es, es + M, comp);
  x[es[0].l] = 0;
  for (int i = 0; i < (M); i++) {
    if (x[es[i].r] == x[es[i].l] + es[i].d || x[es[i].r] == 810114514) {
      x[es[i].r] = x[es[i].l] + es[i].d;
    } else if (x[es[i].l] == x[es[i].r] - es[i].d || x[es[i].l] == 810114514) {
      x[es[i].l] = x[es[i].r] - es[i].d;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
