#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16]={0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
struct graph{
  int N, **edge, *es;
  void setDirectEdge(int N__, int M, int A[], int B[], void **mem = &wmem){
    int i;
    N = N__;
    walloc1d(&es, N, mem);
    walloc1d(&edge, N, mem);
    walloc1d(&edge[0], M, mem);
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      es[A[i]]++;
    }
    for(i=0;i<(N);i++){
      walloc1d(&edge[i], es[i], mem);
    }
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      edge[A[i]][es[A[i]]++] = B[i];
    }
  }
}
;
template<class T> struct wgraph{
  T **cost;
  graph g;
  int N, **edge, *es;
  void setDirectEdge(int N__, int M, int A[], int B[], T C[], void **mem = &wmem){
    int i;
    N = N__;
    walloc1d(&es, N, mem);
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      es[A[i]]++;
    }
    walloc1d(&edge, N, mem);
    for(i=0;i<(N);i++){
      walloc1d(&edge[i], es[i], mem);
    }
    walloc1d(&cost, N, mem);
    for(i=0;i<(N);i++){
      walloc1d(&cost[i], es[i], mem);
    }
    for(i=0;i<(N);i++){
      es[i] = 0;
    }
    for(i=0;i<(M);i++){
      edge[A[i]][es[A[i]]] = B[i];
      cost[A[i]][es[A[i]]++] = C[i];
    }
    g.N = N;
    g.es = es;
    g.edge = edge;
  }
}
;
char memarr[96000000];
int N;
int M;
int A[400000];
int B[400000];
int D[400000];
wgraph<int> g;
int d[100000];
void doit(int n, int b){
  int i, k;
  for(i=0;i<(g.es[n]);i++){
    k = g.edge[n][i];
    if(k==b){
      continue;
    }
    if(d[k]==1073709056){
      d[k] = d[n] + g.cost[n][i];
      doit(k, n);
    }
    else{
      if(d[k] != d[n] + g.cost[n][i]){
        wt_L("No");
        wt_L('\n');
        exit(0);
      }
    }
  }
}
int main(){
  int i;
  wmem = memarr;
  rd(N);
  rd(M);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(M);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
      rd(D[Lj4PdHRW]);
    }
  }
  for(i=0;i<(M);i++){
    A[i+M] = B[i];
    B[i+M] = A[i];
    D[i+M] = -D[i];
  }
  g.setDirectEdge(N, 2*M, A, B, D);
  for(i=0;i<(N);i++){
    d[i] = 1073709056;
  }
  for(i=0;i<(N);i++){
    if(d[i]==1073709056){
      d[i]=0;
      doit(i, -1);
    }
  }
  wt_L("Yes");
  wt_L('\n');
  return 0;
}
// cLay varsion 20190902-1

// --- original code ---
// int N, M, A[4d5], B[4d5], D[4d5];
// 
// wgraph<int> g;
// int d[1d5];
// 
// void doit(int n, int b){
//   int i, k;
//   rep(i,g.es[n]){
//     k = g.edge[n][i];
//     if(k==b) continue;
//     if(d[k]==int_inf){
//       d[k] = d[n] + g.cost[n][i];
//       doit(k, n);
//     } else {
//       if(d[k] != d[n] + g.cost[n][i]) wt("No"), exit(0);
//     }
//   }
// }
// 
// {
//   rd(N,M,(A--,B--,D)(M));
//   rep(i,M) A[i+M] = B[i], B[i+M] = A[i], D[i+M] = -D[i];
//   g.setDirectEdge(N, 2M, A, B, D);
//   rep(i,N) d[i] = int_inf;
//   rep(i,N) if(d[i]==int_inf) d[i]=0, doit(i, -1);
//   wt("Yes");
// }


Measured memory_bytes: 16512