#include <bits/stdc++.h>
using namespace std;

const int N = 100010, INF = (int) 1e9 + 10;
vector< pair<int,int> > edge[N];
int d[N];

bool DFS(int v, int dis) {
  if ( d[v] != -INF && d[v] != dis ) return 0;
  else if ( d[v] != -INF && d[v] == dis ) return 1;
  d[v] = dis;
  bool ok = 1;
  for ( auto u:edge[v] ) {
    ok &= DFS(u.first,dis+u.second);
  }
  return ok;
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    int u, v, w;
    scanf("%d %d %d", &u, &v, &w);
    edge[u].push_back( make_pair(v,w) );
    edge[v].push_back( make_pair(u,-w) );
  }
  fill( d+1, d+n+1, -INF);
  bool ok = 1;
  for (int i = 1; i <= n; i++) {
    if ( d[i] == -INF ) {
      ok &= DFS(i,0);
    }
  }
  puts( ok ? "Yes" : "No");
  return 0;
}
