#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <deque>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

class Edge{
public:
  int x;
  int y;
  ll d;
  void set(int st, int go, ll dis){
    x=st;y=go;d=dis;
  }
  bool operator <(const Edge& f){return x<f.x;}
};

int main(){
  int n,m;
  ll loc[100010]={};
  bool ans=true;
  bool used[100010]={};
  Edge e[200010];
  int minp;
  cin>>n>>m;
  minp=n;
  for(int i=0;i<m;i++){
    int x,y;
    ll d;
    cin>>x>>y>>d;
    if(y<x){
      swap(x,y);
      d*=-1;
    }
    minp=min(minp,x);
    e[i].set(x,y,d);
  }
  sort(e,e+m);
  used[minp]=true;
  loc[minp]=0;
  for(int i=0;i<m;i++){
    int x,y;
    ll d;
    x=e[i].x;y=e[i].y;d=e[i].d;
    if(!used[x]){
      loc[x]=0;
      used[x]=true;
    }
    if(used[y]){
      if(loc[x]+d!=loc[y]){
       ans=false;
       cout<<x<<" "<<y<<" "<<loc[x]+d<<" "<<loc[y]<<endl;
       break;
      }
    }else{
      loc[y]=loc[x]+d;
      used[y]=true;
    }
  }
  cout<<(ans?"Yes":"No")<<endl;
  return 0;
}
