#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
long long int N,M,V,E,L[200005],R[200050],D[200500],tim[2000]={0,1,2,3,4,5,6,7,8};
long long int len[200020]={};
bool used[2000050]={};
vector<pll> edge[300400];
string S,T;


map<long long int,bool>mp;
int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;

    for(long long int i = 0; i < M; i++){
        cin>>L[i]>>R[i]>>D[i];
        L[i]--;
        R[i]--;
        edge[L[i]].push_back({R[i],D[i]});
        edge[R[i]].push_back({L[i],-D[i]});
    }
    for(long long int i = 0; i <= N; i++){
        len[i]=INF;
    }
    long long int res=0;
    for(long long int i = 0; i < N; i++){
        if(used[i]){continue;}
        queue<long long int>que;
        que.push(i);
        len[i]=0;
        bool ok=true;
        while(!que.empty()){
            long long int q=que.front();
            que.pop();
            if(used[q]){continue;}
            used[q]=true;
            for(long long int j = 0; j < edge[q].size(); j++){
                if(len[edge[q][j].first]==INF){
                    len[edge[q][j].first]=len[q]+edge[q][j].second;
                }else if(len[edge[q][j].first]!=len[q]+edge[q][j].second){
                    ok=false;
                }
                que.push(edge[q][j].first);
            }
            
        }
        if(!ok){cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 27376