#include <bits/stdc++.h>
using namespace std;
const long long MAX_PEOPLE = 1e6 + 10;
set<pair<long long, long long> > kanan[MAX_PEOPLE];
long long posisi[MAX_PEOPLE];
long long visit[MAX_PEOPLE];
int main() {
  long long N, M;
  scanf("%lld", &N);
  scanf("%lld", &M);
  memset((posisi), 0, sizeof(posisi));
  memset((visit), 0, sizeof(visit));
  long long a, b, c;
  for (long long i = 0; i < M; ++i) {
    scanf("%lld", &a);
    scanf("%lld", &b);
    scanf("%lld", &c);
    kanan[a].insert(make_pair(b, c));
  }
  bool valid = true;
  for (long long i = 1; i <= N && valid; ++i) {
    for (auto& it : kanan[i]) {
      if (!visit[i] && !visit[it.first]) {
        posisi[i] = 0;
        posisi[it.first] = posisi[i] + it.second;
      } else if (visit[i] && !visit[it.first]) {
        posisi[it.first] = posisi[i] + it.second;
      } else if (!visit[i] && visit[it.first]) {
        posisi[i] = posisi[it.first] - it.second;
      } else {
        valid = valid && (posisi[it.first] - posisi[i] == it.second);
      }
      visit[i] = true;
      visit[it.first] = true;
    }
  }
  puts(valid ? "Yes" : "No");
  return 0;
}
