#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <sstream>
#include <bitset>
#include <climits>
#include <iterator>
#include <set>
#include <iomanip>
#define ll long long
#define mod  1000000007

using namespace std;

int main()

{


    std::ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n,m,i,x,y,z;

    cin>>n>>m;

    ll p[n+10]={0};
    ll check[n+10]={0};

    for(i=0;i<m;i++){
        cin>>x>>y>>z;

        if(check[x]==1 && check[y]==1){

            if(p[y]-p[x]==z){
                continue;
            }
            else{
                cout<<"No"<<endl;
                return 0;
            }


        }
        else{
            if(i==0){
                p[x] = 0;
            }
                p[y] = z + p[x];
                check[x] = 1;
                check[y] = 1;
        }
    }

    cout<<"Yes"<<endl;
    
    return 0;
}




