#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9, MOD = 1e9 + 7,
          around[] = {0, 1, 1, -1, -1, 0, -1, 1, 0, 0};
const long long LINF = 1e18;
const long double PI = abs(acos(-1));
long long n, m, a[200010], b[200010], c[200010], h[100010];
long long s[100010];
vector<long long> g[100010];
vector<pair<long long, long long> > pos[100010];
set<long long> pot;
vector<long long> vec;
queue<long long> qu;
int main() {
  cin >> n >> m;
  for (int i = (0); i < (m); i++) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    pot.insert(a[i]);
    pot.insert(b[i]);
    g[a[i]].push_back(b[i]);
    pos[a[i]].push_back({b[i], c[i]});
    h[b[i]]++;
  }
  for (auto e : pot)
    if (!h[e]) qu.push(e);
  while (!qu.empty()) {
    auto p = qu.front();
    qu.pop();
    vec.push_back(p);
    for (auto e : g[p]) {
      h[e]--;
      if (!h[e]) qu.push(e);
    }
  }
  if (!m) {
    cout << "Yes" << endl;
    return 0;
  }
  if (!vec.size()) {
    cout << "No" << endl;
    return 0;
  }
  s[vec[0]] = 1;
  for (int i = (0); i < (vec.size()); i++) {
    for (auto e : pos[vec[i]]) {
      if (!s[vec[i]] and !s[e.first]) continue;
      if (s[e.first] and s[vec[i]] and s[vec[i]] + e.second != s[e.first]) {
        cout << "No" << endl;
        return 0;
      }
      if (s[vec[i]])
        s[e.first] = s[vec[i]] + e.second;
      else if (s[e.first])
        s[vec[i]] = s[e.first] - e.second;
    }
    if (!s[vec[i]]) continue;
    for (auto e : pos[vec[i]]) {
      if (s[e.first] and s[vec[i]] and s[vec[i]] + e.second != s[e.first]) {
        cout << "No" << endl;
        return 0;
      }
      if (s[vec[i]]) s[e.first] = s[vec[i]] + e.second;
    }
  }
  cout << "Yes" << endl;
  return 0;
}
