// Slower C++ solution:
#include<bits/stdc++.h>

#define base 200000

#define inf 0x3f3f3f3f

using namespace std;

int n,m,x,y,w,ans,maxn,minn,dist[100010],vi[100010];

vector<int> g[100010],l[100010];

queue<int> q;

bool flag=false;



bool spfa(int s){

	memset(dist,0x3f,sizeof(dist));

	dist[s]=0,maxn=minn=0,q.push(s),vi[s]=1;

	while(!q.empty()){

		int u=q.front();q.pop();

		for(int i=0;i<g[u].size();i++){

			int v=g[u][i];

			if(!vi[v]){

				dist[v]=dist[u]+l[u][i];

				q.push(v),vi[v]=1;

				maxn=max(maxn,dist[v]),minn=min(minn,dist[v]);

			}

			else if(dist[v]!=dist[u]+l[u][i]) return true;

		}

	}

	return false;

}



int main(){

//	freopen("line.in","r",stdin);

//	freopen("line.out","w",stdout);

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

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

		scanf("%d%d%d",&x,&y,&w);

		g[x].push_back(y),l[x].push_back(w),g[y].push_back(x),l[y].push_back(-w);

	}

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

		if(!vi[i]){

			flag=spfa(i);

			if(flag){

//				printf("impossible");

				printf("No");

				return 0;

			}

			ans=max(ans,maxn-minn);

		}

	}

//	printf("%d",ans);

	printf("Yes");

}

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

using namespace std;



typedef long long lint;

typedef pair<int, int> P;

#define REP(i, x, n) for(lint i = x ; i < n ; i++)

#define rep(i, n) REP(i, 0, n)

#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)

#define SORT(c) sort((c).begin(), (c).end())



const int IINF = 1e9 + 10;

const lint LLINF = (lint)1e18 + 10;

const lint MOD = (lint)1e9 + 7;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};



struct weightedUnionFind{



    vector<int> par, rank, wei;



    void init(int n){

        par.resize(n);

        rank.resize(n, 0);

        wei.resize(n, 0);

        rep(i, n){

            par[i] = i;

        }

        return;

    }



    int root(int x){

        if(par[x] == x){

            return x;

        }else{

            int r = root(par[x]);

            wei[x] += wei[par[x]];

            return par[x] = r;

        }

    }



    bool unite(int x, int y, int w){

        w = -w;

        w += weight(x);

        w -= weight(y);

        int rx = root(x);

        int ry = root(y);

        if(rx == ry){

            return false;

        }

        if(rank[rx] < rank[ry]){

            swap(rx, ry);

            w = -w;

        }

        if(rank[rx] == rank[ry]){

            rank[rx]++;

        }

        par[ry] = rx;

        wei[ry] = w;

        return true;

    }



    bool same(int x, int y){

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

    }



    int weight(int x){

        root(x);

        return wei[x];

    }



    int diff(int x, int y){

        return weight(x) - weight(y);

    }



};



int main(){

    int n, m;

    cin >> n >> m;

    weightedUnionFind uf;

    uf.init(n);

    bool flag = true;

    rep(i, m){

        int l, r, d;

        cin >> l >> r >> d;

        l--;

        r--;

        if(uf.same(l, r)){

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

                flag = false;

                break;

            }

        }else{

            uf.unite(l, r, d);

        }

    }

    if(flag){

        cout << "Yes" << endl;

    }else{

        cout << "No" << endl;

    }

    return 0;

}