#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define f first
#define pb push_back
#define s second
#define mp make_pair

int d[100100];
vector<pi> aList[100100];
int N,M,a,b,c;

void dfs(int x){
  for (auto i : aList[x]){
    int nxt = 0;
    if (i.f < x)nxt = d[x] - i.s;
    else nxt = d[x] + i.s;
    if (d[i.f] == -1){
      d[i.f] = nxt;
      dfs(i.f);
    }else{
      if (nxt != d[i.f]){
        cout<<"No";
        exit(0);
      }
    }
  }
}

int main(){
  cin >> N >> M;
  for (int i=0;i<M;++i){
    cin>>a>>b>>c;
    aList[a].pb(mp(b,c));
    aList[b].pb(mp(a,c));
  }
  memset(d, -1, sizeof(d));
  for (int i=1;i<=N;++i){ 
    if (d[i] != -1)continue;
    d[i] = 0;
    dfs(i);
  }
  cout<<"Yes";
}v