#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  vector<pair<pair<int, int>, int>> Data;
  const int Inf = 1123456789;
  vector<int> x(112345, Inf);
  scanf("%d %d", &N, &M);
  if (!M) {
    printf("Yes\n");
    return 0;
  }
  Data.resize(M);
  for (int i = 0; i < (M); ++i) {
    int L, R, D;
    scanf("%d %d %d", &L, &R, &D);
    if (L > R) {
      swap(L, R);
      D = -D;
    }
    Data[i] = make_pair(make_pair(L, R), D);
  }
  sort(Data.begin(), Data.end());
  bool first = true;
  for (;;) {
    bool update = true;
    while (update) {
      update = false;
      for (int i = 0; i < (Data.size()); ++i) {
        if (first) {
          if (Data[i].first.first) {
            x[Data[i].first.first] = 0;
            x[Data[i].first.second] = Data[i].second;
            first = false;
            update = true;
            Data[i] = make_pair(make_pair(0, 0), 0);
          }
        } else if (x[Data[i].first.first] != Inf) {
          if (Data[i].first.first) {
            if (x[Data[i].first.second] == Inf)
              x[Data[i].first.second] = x[Data[i].first.first] + Data[i].second;
            else if (x[Data[i].first.second] !=
                     x[Data[i].first.first] + Data[i].second) {
              printf("No\n");
              return 0;
            }
            Data[i] = make_pair(make_pair(0, 0), 0);
            update = true;
          }
        } else if (x[Data[i].first.second] != Inf) {
          if (Data[i].first.first) {
            if (x[Data[i].first.first] == Inf)
              x[Data[i].first.first] = x[Data[i].first.second] - Data[i].second;
            else if (x[Data[i].first.first] !=
                     x[Data[i].first.second] - Data[i].second) {
              printf("No\n");
              return 0;
            }
            Data[i] = make_pair(make_pair(0, 0), 0);
            update = true;
          }
        }
      }
    }
    for (int i = 0; i < (Data.size()); ++i) {
      if (Data[i].first.first) {
        first = true;
        x = vector<int>(112345, Inf);
        break;
      }
    }
    if (!first) break;
  }
  printf("Yes\n");
  return 0;
}
