#include <bits/stdc++.h>
using namespace std;
int answer = 1;
int checked[100000] = {};
int L[200000], R[200000], D[200000];
pair<int, int> Li[200000] = {}, Ri[200000] = {};
int start_Li[100000] = {};
int start_Ri[100000] = {};
long long x[100000];
int check(int num) {
  checked[num] = 1;
  for (int i = start_Li[num]; num == Li[i].first; i++) {
    if (x[R[Li[i].second]] == 10000000000) {
      x[R[Li[i].second]] = x[num] + D[Li[i].second];
    } else if (x[R[Li[i].second]] != x[num] + D[Li[i].second]) {
      answer = 0;
    }
    if (checked[R[Li[i].second]] == 0) {
      check(R[Li[i].second]);
    }
  }
  for (int i = start_Ri[num]; num == Ri[i].first; i++) {
    if (x[L[Ri[i].second]] == 10000000000) {
      x[L[Ri[i].second]] = x[num] - D[Ri[i].second];
    } else if (x[L[Ri[i].second]] != x[num] - D[Ri[i].second]) {
      answer = 0;
    }
    if (checked[L[Ri[i].second]] == 0) {
      check(L[Ri[i].second]);
    }
  }
}
int main() {
  int N, M;
  cin >> N >> M;
  if (M == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  for (int i = 0; i < M; i++) {
    cin >> L[i] >> R[i] >> D[i];
    L[i]--;
    R[i]--;
  }
  for (int i = 0; i < M; i++) {
    Li[i].first = L[i];
    Li[i].second = i;
    Ri[i].first = R[i];
    Ri[i].second = i;
  }
  sort(Li, Li + M);
  sort(Ri, Ri + M);
  for (int i = 1; i < N; i++) {
    if (Li[i].first != Li[i - 1].first) {
      start_Li[Li[i].first] = i;
    }
    if (Ri[i].first != Ri[i - 1].first) {
      start_Ri[Ri[i].first] = i;
    }
  }
  for (int i = 0; i < N; i++) {
    x[i] = 10000000000;
  }
  for (int i = 0; i < N; i++) {
    if (x[i] == 10000000000) {
      x[i] = 0;
    }
    if (checked[i] == 0) {
      check(i);
    }
  }
  if (answer == 0) {
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
  return 0;
}
