#include "bits/stdc++.h"
using namespace std;
int N, M;
vector<pair<int,int>>adj[100005];
int dist[100005];
bool vis[100005];
bool dfs(int u, int cur){
  if(vis[u]){
    if(dist[u] != cur)
      return 0;
    return 1;
  }

  vis[u] = 1;
  dist[u] = cur;
  bool ret = 1;
  for(auto v : adj[u])ret &= dfs(v.first, cur + v.second);
  return ret;
}
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;

  while(M--){

    int u, v, w;
    cin >> u >> v >> w;

    adj[u].push_back(make_pair(v,w));
    adj[v].push_back(make_pair(u,-w));

  }
  bool f = 1;
  for(int i = 1; i <= N; i++)if(!vis[i])f &= dfs(i,0);
  cout  << ( f ? "Yes\n" : "No\n");
}
