// C++11
#include "bits/stdc++.h"
#include <sys/time.h>
#include <emmintrin.h>
#include <string>
#include <sstream>

using namespace std;

int e[100005][200005][2] = {};
int ei[100005] = {};
int b[100005];
int n,m;
const int t = -1235147;

bool f(int i, int c){
  if(b[i] != t){
    return b[i] == c;
  }
  if(c==t){
    c = 0;
  }
  b[i] = c;
  for(int j=0; j<ei[i]; j++){
    if(!f(e[i][j][0], c+e[i][j][1])) return false;
  }
  return true;
}

void solve(){
  int n,m,l,r,d;
  cin >> n >> m;
  for(int i=0; i<m; i++){
    cin >> l >> r >> d;
    e[l][ei[l]][0] = r;
    e[l][ei[l]++][1] = d;
    e[r][ei[r]][0] = l;
    e[r][ei[r]++][1] = -d;
  }
  for(int i=1; i<=n; i++){
    b[i] = t;
  }
  for(int i=1; i<=n; i++){
    if(b[i] != t) continue;
    if(!f(i,t)){
      printf("No\n");
      return;
    }
  }

  printf("Yes\n");
  return;
}

int main() {
  solve();
  return 0;
}

