#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
int main() {
  int n, m;
  cin >> n >> m;
  std::vector<std::vector<std::pair<int, int>>> g(n);
  std::vector<int> h(n);
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a - 1].push_back({b - 1, c});
    h[b - 1]++;
  }
  std::queue<int> qu;
  std::vector<int> vec;
  for (int i = 0; i < n; i++)
    if (!h[i]) qu.push(i);
  while (!qu.empty()) {
    auto p = qu.front();
    qu.pop();
    vec.push_back(p);
    for (auto e : g[p]) {
      if (!--h[e.first]) qu.push(e.first);
    }
  }
  for (auto v : h) {
    if (v) {
      cout << "No" << endl;
      return 0;
    }
  }
  std::map<int, int> mp;
  mp[vec[0]] = 1;
  for (auto v : vec) {
    for (auto e : g[v]) {
      if (mp[e.first] and mp[v] + e.second != mp[e.first]) {
        cout << "No" << endl;
        return 0;
      }
      mp[e.first] = mp[v] + e.second;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
