#include <bits/stdc++.h>
using namespace std;
long long mult(long long a, long long b, long long p = 1000000007) {
  return ((a % p) * (b % p)) % p;
}
long long add(long long a, long long b, long long p = 1000000007) {
  return (a + b + p) % p;
}
long long fpow(long long n, long long k, long long p = 1000000007) {
  long long r = 1;
  for (; k; k >>= 1LL) {
    if (k & 1LL) r = mult(r, n, p);
    n = mult(n, n, p);
  }
  return r;
}
long long inv(long long a, long long p = 1000000007) {
  return fpow(a, p - 2, p);
}
void self_max(long long &a, long long b) { a = max(a, b); }
void self_min(long long &a, long long b) { a = min(a, b); }
void self_add(long long &a, long long b, long long p = 1000000007) {
  a += b;
  if (a >= p) a -= p;
}
void self_sub(long long &a, long long b, long long p = 1000000007) {
  a -= b;
  if (a < 0) a += p;
}
const long long INF = 1e9 + 5;
vector<long long> v[400001];
vector<long long> val[400001];
long long check[400001];
set<pair<long long, long long> > data;
long long first[400001], xch[400001];
long long dfs(long long s, long long curr) {
  check[s] = true;
  first[s] = curr;
  long long ans = 0;
  for (long long i = 0; i < (long long)v[s].size(); i++) {
    long long d = v[s][i];
    if (data.find(make_pair(s, d)) == data.end())
      curr = first[s] - val[s][i];
    else
      curr = first[s] + val[s][i];
    if (!check[d]) {
      ans = dfs(d, curr);
      if (ans) return ans;
    } else {
      if (first[d] != curr) return 1;
    }
  }
  return ans;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  for (long long i = 0; i < m; i++) {
    long long a, b, d;
    cin >> a >> b >> d;
    data.insert(make_pair(a, b));
    v[a].push_back(b);
    v[b].push_back(a);
    val[a].push_back(d);
    val[b].push_back(d);
  }
  for (long long i = 1; i < n + 1; i++) {
    if (!check[i]) {
      if (dfs(i, 0)) {
        cout << "No" << '\n';
        return;
      }
    }
  }
  cout << "Yes" << '\n';
  return;
}
signed main() {
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
}
