#include <bits/stdc++.h>
using namespace std;
vector<pair<pair<long long, long long>, long long> > data;
int main() {
  long long N, M;
  scanf("%lld", &N);
  scanf("%lld", &M);
  long long posisi[N + 5];
  long long visit[N + 5];
  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);
    data.push_back(make_pair(make_pair(a, b), c));
  }
  sort((data).begin(), (data).end());
  bool valid = true;
  for (long long i = 0; i < M && valid; ++i) {
    a = data[i].first.first;
    b = data[i].first.second;
    c = data[i].second;
    if (!visit[a] && !visit[b]) {
      posisi[a] = 0;
      posisi[b] = posisi[a] + c;
      visit[a] = true;
      visit[b] = true;
    } else if (!visit[a]) {
      posisi[a] = posisi[b] - c;
      visit[a] = true;
    } else if (!visit[b]) {
      posisi[b] = posisi[a] + c;
      visit[b] = true;
    } else {
      valid = (posisi[b] - posisi[a] == c);
    }
  }
  if (valid) {
    long long MIN = *min_element((posisi), (posisi) + (M));
    long long MAX = *max_element((posisi), (posisi) + (M));
    long long hehe = 1e9;
    valid = (MAX - MIN) <= hehe;
  }
  puts(valid ? "Yes" : "No");
  return 0;
}
