#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  vector<std::tuple<int, int, int> > V(M);
  int l, r, d;
  for (int i = 0; i < (M); ++i) {
    scanf("%d %d %d", &l, &r, &d);
    V[i] = make_tuple(l - 1, r - 1, d);
  }
  vector<int> ichi(N, 0);
  vector<int> flag(N, 0);
  int f;
  f = 0;
  sort(begin(V), end(V));
  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[get<0>(V[i])] == 1) {
          if (flag[get<1>(V[i])] == 0) {
            ichi[get<1>(V[i])] = ichi[get<0>(V[i])] + get<2>(V[i]);
            flag[get<1>(V[i])] = 1;
            f = 1;
          } else {
            if (ichi[get<1>(V[i])] != ichi[get<0>(V[i])] + get<2>(V[i])) {
              f = 2;
              break;
            }
          }
        } else if (flag[get<1>(V[i])] == 1) {
          if (flag[get<0>(V[i])] == 0) {
            ichi[get<0>(V[i])] = ichi[get<1>(V[i])] - get<2>(V[i]);
            flag[get<0>(V[i])] = 1;
            f = 1;
          } else {
            if (ichi[get<1>(V[i])] != ichi[get<0>(V[i])] + get<2>(V[i])) {
              f = 2;
              break;
            }
          }
        }
      }
    }
  }
  if (f == 3) cout << "Yes";
  if (f == 2) cout << "No";
}
