#include <bits/stdc++.h>
using namespace std;
ll n,m,l,r,d;
std::vector<pair<ll,ll>> adj[200007];
set<ll> seen;
ll parr[200007];
ll size[200007];
ll dis[200007];
ll vis[200007];
ll vist[200007];

ll find(ll u) {
  if (parr[u] == u) return u;
  return parr[u] = find(parr[u]);
}
void init(ll n) {
  for(ll i = 1; i<=n; i++){
    parr[i] = i;
    size[i] = 1;
  }
}
void unify(ll a, ll b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    if (size[b] > size[a])
      swap(a, b);
    parr[b] = a;
    size[a] += size[b];
  }
}

void reset(){
  for(ll e : seen) dis[e] = vis[e] = vist[e] = 0;
  seen.clear();
}

void dfs(ll cur, ll d){
  seen.insert(cur);
  vis[cur] = 1;
  dis[cur] = d;
  for(auto e : adj[cur]){
    if(!vis[e.first]) dfs(e.first, d+e.second);
  }
}

ll check(ll cur){
  vis[cur] = 1;
  ll res=  1;
  for(auto e : adj[cur]){
    ll v = e.first;
    ll duv = e.second;
    if((dis[v]-dis[cur])!=duv) {
      // printf("  ambigues (dis[%d]-dis[%d]=%d) and duv=%d\n", cur, v, dis[cur]-dis[v], duv);
      return 0;
    }
    if(!vis[e.first]) res&=check(v);
  }
  return 1;
}
int main(){
  std::cin >> n >> m;
  init(n);
  for(ll i = 0; i<m; i++){
    std::cin >> l >> r >> d;
    unify(l, r);
    adj[l].push_back({r, d});
    adj[r].push_back({l, -d});
  }
  set<ll> cc;
  for(ll i = 1; i<=n; i++) cc.insert(find(i));
  for(ll e : cc){
    // printf("processing cc %d\n", e);
    reset();
    dfs(e, 0);
    // for(ll i = 1; i<=n; i++){
    //   printf("  dis[%d] = %d\n", i, dis[i]);
    // }
    if(!check(e)) return 0*printf("No\n");
  }
  return 0*printf("Yes\n");
}
