#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);
  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());
  vector<vector<pair<pair<int, int>, int>>> Sep;
  while (Data.size()) {
    Sep.resize(Sep.size() + 1);
    queue<int> f;
    f.push(Data[0].first.first);
    int EraseNum = 0;
    for (int i = 0; i < (Data.size()); ++i) {
      if (!f.size()) {
        break;
      } else if (Data[i].first.first == f.front()) {
        f.push(Data[i].first.second);
        Sep[Sep.size() - 1].push_back(Data[i]);
        swap(Data[i], Data[EraseNum]);
        ++EraseNum;
      } else if (Data[i].first.first > f.front()) {
        f.pop();
        --i;
      }
    }
    Data.erase(Data.begin(), Data.begin() + EraseNum);
  }
  for (int i = 0; i < (Sep.size()); ++i) {
    for (int j = 0; j < (Sep[i].size()); ++j) {
      if (!j) {
        x[Sep[i][j].first.first] = 0;
        x[Sep[i][j].first.second] = Sep[i][j].second;
      } else {
        if (x[Sep[i][j].first.second] == Inf) {
          x[Sep[i][j].first.second] =
              x[Sep[i][j].first.first] + Sep[i][j].second;
        } else if (x[Sep[i][j].first.second] !=
                   x[Sep[i][j].first.first] + Sep[i][j].second) {
          printf("No\n");
          return 0;
        }
      }
    }
    x = vector<int>(112345, Inf);
  }
  printf("Yes\n");
  return 0;
}
