#include <bits/stdc++.h>
using namespace std;
int pos[100009];
int vis[100009];
int mn(1000000009), mx(0);
vector<vector<pair<int, int> > > g(100009);
bool dfs(int u) {
  bool f = true;
  for (int i = 0; i < g[u].size(); ++i) {
    pair<int, int> v = g[u][i];
    if (!vis[u] && !vis[v.first]) {
      vis[u] = 1;
      pos[u] = mx;
      pos[v.first] = pos[u] + v.second;
      vis[v.first] = 1;
      mx = max(mx, pos[v.first]);
    } else if (vis[u] && !vis[v.first]) {
      pos[v.first] = pos[u] + v.second;
      vis[v.first] = 1;
      mx = max(mx, pos[v.first]);
    } else if (!vis[u] && vis[v.first]) {
      vis[u] = 1;
      pos[u] = pos[v.first] - v.second;
      mn = min(mn, pos[u]);
    } else {
      if (pos[u] != pos[v.first] - v.second) {
        return false;
      }
    }
    f = dfs(v.first);
  }
  return f;
}
int main() {
  int n, m;
  int l, r, d;
  cin >> n >> m;
  for (int i = 0; i < m; ++i) {
    cin >> l >> r >> d;
    g[l].push_back(pair<int, int>(r, d));
  }
  int pmx(0);
  for (int i = 1; i <= n; ++i) {
    if (!vis[i]) {
      if (!dfs(i)) {
        cout << "No";
        return 0;
      }
      if (mn < pmx) mn = pmx + 1, mx += (pmx - mn);
      if (mn < 0 || mx > 1000000000) {
        cout << "No";
        return 0;
      }
    }
  }
  cout << "Yes";
}
