#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 visited[MAX_PEOPLE];
bool valid = true;
void dfs(long long i) {
  for (auto& it : kanan[i]) {
    if (!visited[i] && !visited[it.first]) {
      posisi[i] = 0;
      posisi[it.first] = posisi[i] + it.second;
      visited[i] = true;
      visited[it.first] = true;
      dfs(it.first);
    } else if (visited[i] && !visited[it.first]) {
      posisi[it.first] = posisi[i] + it.second;
      visited[it.first] = true;
      dfs(it.first);
    } else if (!visited[i] && visited[it.first]) {
      posisi[i] = posisi[it.first] - it.second;
      visited[i] = true;
    } else {
      valid = valid && ((posisi[it.first] - posisi[i]) == it.second);
    }
  }
}
int main() {
  long long N, M;
  cin >> N >> M;
  for (int _je = sizeof(posisi) / sizeof(posisi[0]); _je--;) posisi[_je] = -1;
  memset((visited), 0, sizeof(visited));
  long long a, b, c;
  for (long long i = 0; i < M; ++i) {
    cin >> a >> b >> c;
    kanan[a].insert(make_pair(b, c));
  }
  for (long long i = 1; i <= N && valid; ++i) {
    if (!visited[i]) {
      dfs(i);
    }
  }
  puts(valid ? "Yes" : "No");
  return 0;
}
