#include <bits/stdc++.h>
using namespace std;
constexpr int mod = 1000000007;
constexpr int mod1 = 998244353;
vector<int> dx = {0, 1, 0, -1}, dy = {-1, 0, 1, 0};
bool inside(int y, int x, int h, int w) {
  if (y < h && y >= 0 && x < w && x >= 0) return true;
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  if (m == 0) {
    cout << "Yes" << endl;
    return 0;
  }
  vector<int> l(m), r(m), d(m);
  vector<vector<pair<int, int>>> g(n);
  for (int i = 0; i < (m); ++i) {
    cin >> l.at(i) >> r.at(i) >> d.at(i);
    l.at(i)--;
    r.at(i)--;
    g[l.at(i)].push_back(make_pair(r.at(i), d.at(i)));
    g[r.at(i)].push_back(make_pair(l.at(i), -d.at(i)));
  }
  vector<int> x(n);
  queue<int> q;
  vector<bool> visited(n);
  bool ok = true;
  q.push(l.at(0));
  visited.at(l.at(0)) = true;
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int i = 0; i < (g[cur].size()); ++i) {
      int next = g[cur][i].first, t = g[cur][i].second;
      if (visited.at(next)) {
        if (x[next] - x[cur] != t) ok = false;
      } else {
        visited.at(next) = true;
        x.at(next) = x.at(cur) + t;
        q.push(next);
      }
    }
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
