#include <bits/stdc++.h>
int powint(int a, int x) {
  int res = 1;
  for (int i = 0; i < x; i++) {
    res = res * a;
  }
  return res;
}
using namespace std;
class Point {
 public:
  int jiku;
  long long int zahyou;

 public:
  Point() {
    jiku = -1;
    zahyou = 0;
  }
};
class Bar {
 public:
  set<int> points;
};
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> Lv(M);
  vector<int> Rv(M);
  vector<int> Dv(M);
  for (int i = 0; i < M; i++) {
    cin >> Lv[i] >> Rv[i] >> Dv[i];
  }
  vector<Point> x(N);
  vector<Bar> b(N);
  bool dame = false;
  for (int i = 0; i < M; i++) {
    int L, R, D;
    L = Lv[i];
    R = Rv[i];
    D = Dv[i];
    L--;
    R--;
    if (x[L].jiku == -1 && x[R].jiku == -1) {
      x[L].jiku = L;
      x[R].jiku = L;
      x[L].zahyou = 0;
      x[R].zahyou = D;
      b[L].points.insert(L);
      b[L].points.insert(R);
    } else if (x[L].jiku != -1 && x[R].jiku != -1) {
      if (x[L].jiku == x[R].jiku) {
        if (x[R].zahyou - x[L].zahyou != D) {
          dame = true;
          break;
        }
      } else {
        int prejiku = x[R].jiku;
        long long int prezahyou = x[R].zahyou;
        x[R].jiku = x[L].jiku;
        x[R].zahyou = x[L].zahyou + D;
        for (auto p : b[prejiku].points) {
          if (p == R) continue;
          x[p].jiku = x[L].jiku;
          x[p].zahyou = x[R].zahyou + x[p].zahyou - prezahyou;
          b[x[L].jiku].points.insert(p);
        }
        b[x[L].jiku].points.insert(R);
      }
    } else if (x[L].jiku != -1) {
      x[R].jiku = x[L].jiku;
      x[R].zahyou = x[L].zahyou + D;
      b[x[R].jiku].points.insert(R);
    } else {
      x[L].jiku = x[R].jiku;
      x[L].zahyou = x[R].zahyou - D;
      b[x[L].jiku].points.insert(L);
    }
  }
  if (dame) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}
