#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<int, int>, int>> EraseList;
bool eraser(pair<pair<int, int>, int> v) {
  for (int i = 0; i < (EraseList.size()); ++i) {
    if (EraseList[i] == v) {
      EraseList.erase(EraseList.begin() + i);
      return true;
    }
  }
  return false;
}
int main() {
  int N, M;
  list<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;
  }
  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.push_back(make_pair(make_pair(L, R), D));
  }
  Data.sort();
  bool first = true;
  for (;;) {
    bool update = true;
    while (update) {
      update = false;
      for (auto d : Data) {
        static int i = 0;
        if (first) {
          x[d.first.first] = 0;
          x[d.first.second] = d.second;
          first = false;
          update = true;
          EraseList.push_back(d);
        } else if (x[d.first.first] != Inf) {
          if (x[d.first.second] == Inf)
            x[d.first.second] = x[d.first.first] + d.second;
          else if (x[d.first.second] != x[d.first.first] + d.second) {
            printf("No\n");
            return 0;
          }
          EraseList.push_back(d);
          update = true;
        } else if (x[d.first.second] != Inf) {
          if (x[d.first.first] == Inf)
            x[d.first.first] = x[d.first.second] - d.second;
          else if (x[d.first.first] != x[d.first.second] - d.second) {
            printf("No\n");
            return 0;
          }
          EraseList.push_back(d);
          update = true;
        }
        ++i;
      }
      Data.erase(remove_if(Data.begin(), Data.end(), eraser), Data.end());
    }
    if (Data.size()) {
      first = true;
      x = vector<int>(112345, Inf);
      break;
    }
    if (!first) break;
  }
  printf("Yes\n");
  return 0;
}
