#include <bits/stdc++.h>
using namespace std;
long long n, m, in[100005], x[100005], vis[100005], l[100005], r[100005],
    d[100005];
vector<long long> a[100005];
map<pair<long long, long long>, long long> m1;
long long dfs(long long node, long long sum) {
  if (vis[node]) return x[node] - sum;
  vis[node] = 1;
  x[node] = sum;
  for (auto i : a[node]) {
    long long ss = sum + m1[make_pair(node, i)];
    x[i] += dfs(i, ss);
  }
  if (a[node].size() == 0) return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, m, i, j;
  cin >> n >> m;
  for (i = 0; i < m; i++) {
    cin >> l[i] >> r[i] >> d[i];
    a[l[i]].push_back(r[i]);
    m1[make_pair(l[i], r[i])] = d[i];
    in[r[i]]++;
  }
  for (i = 1; i <= n; i++) {
    if (!vis[i] && in[i] == 0) {
      x[i] += dfs(i, 0);
    }
  }
  long long f = 0;
  for (i = 0; i < m; i++) {
    if (x[r[i]] - x[l[i]] != d[i]) f = 1;
  }
  if (f)
    cout << "No";
  else
    cout << "Yes";
  return 0;
}
