// Slower C++ solution:
/*

Problem:People on a Line

Algorithm:"linear" DFS

Status:

*/



#include <iostream>

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <string>

#include <vector>

#include <map>

#include <queue>

#include <deque>

#include <set>

#include <sstream>

#include <utility>

#include <list>

#include <ctime>

#include <memory.h>

#include <stack>

#include <stdio.h>

#include <string.h>



using namespace std;



const int INF=1e9+7;



vector<pair<int,int> > nei[100005];

int pos[100005];

int n,m;

bool used[100005];

bool exist[100005];



void dfs(int x,int cur){

	pos[x]=cur;

	used[x]=true;

	for(int i=0;i<nei[x].size();i++){

		if(used[nei[x][i].first]){

			if(pos[nei[x][i].first]-cur!=nei[x][i].second){

				cout<<"No"<<endl;

				exit(0);

			}

		}

		else{

			dfs(nei[x][i].first,cur+nei[x][i].second);

		}

	}

}



int main()

{

	scanf("%d%d",&n,&m);

	for(int i=0;i<m;i++){

		int l,r,d;

		scanf("%d%d%d",&l,&r,&d);

		l--;r--;

		exist[l]=true;exist[r]=true;

		nei[l].push_back(make_pair(r,d));

		nei[r].push_back(make_pair(l,-d));

	}

	

	for(int i=0;i<n;i++){

		if(!exist[i])continue;

		if(!used[i]){

			dfs(i,0);

		}

	}

	cout<<"Yes"<<endl;

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 3.492231683913463x):
#include <bits/stdc++.h>



using namespace std;



#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define all(v) v.begin(),v.end()

#define _GLIBCXX_DEBUG



using ll = long long;

using vi = vector<int>;

using vll = vector<ll>;

using vd = vector<double>;

using vvi = vector<vi>;

using vvll = vector<vll>;

using vvd = vector<vd>;

using vvvi = vector<vvi>;

using vvvll = vector<vvll>;

using vvvd = vector<vvd>;



const double pi=3.141592653589793;

const ll MOD=1e9+7;



template<class Abel> struct UnionFind {

    vector<int> par;

    vector<int> rank;

    vector<Abel> diff_weight;



    UnionFind(int n = 1, Abel SUM_UNITY = 0) {

        init(n, SUM_UNITY);

    }



    void init(int n = 1, Abel SUM_UNITY = 0) {

        par.resize(n); rank.resize(n); diff_weight.resize(n);

        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;

    }



    int root(int x) {

        if (par[x] == x) {

            return x;

        }

        else {

            int r = root(par[x]);

            diff_weight[x] += diff_weight[par[x]];

            return par[x] = r;

        }

    }



    Abel weight(int x) {

        root(x);

        return diff_weight[x];

    }



    bool issame(int x, int y) {

        return root(x) == root(y);

    }



    bool merge(int x, int y, Abel w) {

        w += weight(x); w -= weight(y);

        x = root(x); y = root(y);

        if (x == y) return false;

        if (rank[x] < rank[y]) swap(x, y), w = -w;

        if (rank[x] == rank[y]) ++rank[x];

        par[y] = x;

        diff_weight[y] = w;

        return true;

    }



    Abel diff(int x, int y) {

        return weight(y) - weight(x);

    }

};





int main() {

    ll n,m;

    cin>>n>>m;

    UnionFind<int> uf(n+1);

    rep(i,m){

        ll l,r,d;

        cin>>l>>r>>d;

        if (uf.root(r)!=uf.root(l)){

            uf.merge(l,r,d);

        }

        else{

            if (uf.diff(l,r)!=d){

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;



    return 0;

}

//...