#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> L(M);
  vector<int> R(M);
  vector<int> D(M);
  for (int i = 0; i < (M); ++i) scanf("%d %d %d", &L[i], &R[i], &D[i]);
  for (int i = 0; i < (M); ++i) {
    L[i]--;
    R[i]--;
  }
  vector<int> ichi(N, 0);
  vector<int> flag(N, 0);
  int f;
  f = 0;
  while (f == 0) {
    for (int i = 0; i < (N); ++i) {
      if (flag[i] == 0) {
        flag[i] = 1;
        f = 1;
        break;
      }
      f = 3;
    }
    while (f == 1) {
      f = 0;
      for (int i = 0; i < (M); ++i) {
        if (flag[L[i]] == 1) {
          if (flag[R[i]] == 0) {
            ichi[R[i]] = ichi[L[i]] + D[i];
            flag[R[i]] = 1;
            f = 1;
          } else {
            if (ichi[R[i]] != ichi[L[i]] + D[i]) {
              f = 2;
              break;
            }
          }
        }
        if (flag[R[i]] == 1) {
          if (flag[L[i]] == 0) {
            ichi[L[i]] = ichi[R[i]] - D[i];
            flag[L[i]] = 1;
            f = 1;
          } else {
            if (ichi[L[i]] != ichi[R[i]] - D[i]) {
              f = 2;
              break;
            }
          }
        }
      }
    }
  }
  if (f == 3) cout << "Yes";
  if (f == 2) cout << "No";
}
