#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  cin >> m;
  int l[210000];
  int r[210000];
  int d[210000];
  int flag = 1;
  int x[110000] = {};
  bool flagx[110000] = {};
  flagx[1] = 1;
  for (int i = 1; i <= m; i++) {
    cin >> l[i];
    cin >> r[i];
    cin >> d[i];
  }
  for (int i = 1; i <= m; i++) {
    int breakflag = 1;
    for (int j = 1; j <= m; j++) {
      if (flagx[l[j]] == 1) {
        breakflag = 0;
        if (flagx[r[j]] == 1 && x[r[j]] != x[l[j]] + d[j]) {
          flag = 0;
          break;
        } else if (flagx[r[j]] == 0) {
          x[r[j]] = x[l[j]] + d[j];
          flagx[r[j]] = 1;
        }
      } else if (flagx[r[j]] == 1) {
        x[l[j]] = x[r[j]] - d[j];
        flagx[l[j]] = 1;
        breakflag = 0;
      }
    }
    if (breakflag) break;
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}
