/*
	Swamy Saranam

	Date	: 28/01/2018 18:02:54
	Author	: Krishna Mohan A M
	Problem	:
	Status	:
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pll;

#define FASTIO                ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,a,b)            for(int i=(a);i<(b);i++)
#define REP(i,n)              FOR(i,0,n)
#define SORT(v)               sort((v).begin(),(v).end())
#define UN(v)                 SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)               memset(a,b,sizeof a)
#define PB                    push_back
#define F                     first
#define S                     second

const int MOD = 1000000007;
const int N = 2e5+5;

ll n, m, dist[N], l, r, d;
vector<pll> graph[N];
bool isPos;
queue<ll> q;

// void dfs(int u, int p, ll len){
//       // cout<<u<<" : "<<p<<" : "<<len<<"\n";
//       dist[u] = len;
//       for(pll v : graph[u]){
//             if(v.F==p)
//                   continue;
//             if(dist[v.F] != -1){
//                   ll ld = abs(dist[u] - dist[v.F]);
//                   // cout<<u<<" - "<<v.F<<" - "<<ld<<" - "<<v.S<<"\n";
//                   if(ld != v.S){
//                         isPos = false;
//                         // cout<<"$"<<isPos<<"\n";
//                         return;
//                   }
//             }
//             if(!isPos)
//                   return;
//             if(dist[v.F]==-1)
//                   dfs(v.F, u, len+v.S);
//       }
//       // cout<<u<<" : "<<isPos<<"\n";
// }

int main()
{
      FASTIO
      CL(dist, -1);
      cin>>n>>m;
      REP(i, m){
            cin>>l>>r>>d;
            graph[l].PB({r, d});
            graph[r].PB({l, -d});
      }
      isPos = true;
      FOR(i, 1, n+1){
            if(dist[i]==-1){
                  // cout<<"CC: "<<i<<"\n";
                  dist[i] = 0;
                  q.push(i);
                  while(!q.empty()){
                        ll cur = q.front();
                        q.pop();
                        for(pll v : graph[cur]){
                              if(dist[v.F]==-1){
                                    dist[v.F] = dist[cur]+v.S;
                                    q.push(v.F);
                                    continue;
                              }
                              if(dist[v.F]==dist[cur]+v.S)
                                    continue;
                              else{
                                          isPos= false;
                                          break;
                              }
                        }
                        if(!isPos)
                              break;
                  }
            }
            // cout<<"#"<<isPos<<"\n";
            if(!isPos)
                  break;
      }
      // cout<<isPos<<"\n";
      if(!isPos)
            cout<<"No\n";
      else
            cout<<"Yes\n";
      return 0;
}
