#include <bits/stdc++.h>
using namespace std;
int n, m, l[100100], r[100100], d[100100], p[100100];
vector<pair<int, int> > g[100100];
bool vis[100100];
void dfs(int x, int pos) {
  if (vis[x]) return;
  vis[x] = true;
  p[x] = pos;
  for (auto i : g[x]) {
    dfs(i.first, i.second + pos);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    l[i]--;
    r[i]--;
    g[l[i]].push_back({r[i], d[i]});
    g[r[i]].push_back({l[i], -d[i]});
  }
  for (int i = 0; i < n; i++) dfs(i, 0);
  for (int i = 0; i < m; i++) {
    if (p[r[i]] - p[l[i]] != d[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}
