// Slower C++ solution:
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#include <queue>

using namespace std;



struct ed{

    int to;

	int dis;

	int next;

} edge[400050];

int head[100050];

int edge_tot;



void addedge(int from,int to,int dis)

{

	edge_tot += 1;

    edge[edge_tot].to = to;

    edge[edge_tot].dis = dis;

    edge[edge_tot].next = head[from];

    head[from] = edge_tot;

}



int n,m;

long long dis[100005];

queue<int> q;

bool vis[100050],inq[100050];



bool spfa(int s){

    q.push(s);

    inq[s] = true;

    dis[s] = 0;

    long long curmax = 0;

	long long curmin = 0;

    while(!q.empty()){

        int u = q.front();

        q.pop();

        for(int i = head[u];i;i = edge[i].next){

            int v = edge[i].to;

            if(dis[v] == 12345678987654321){

                dis[v] = dis[u] + edge[i].dis;

                curmax = max(curmax,dis[v]);

                curmin = min(curmin,dis[v]);

                if(curmax - curmin > 1000000000) return false;

                vis[v] = 1;

                if(!inq[v])

                    q.push(v);

            }

            else if(dis[v] != dis[u] + edge[i].dis)

                return false;

        }

        inq[u] = false;

    }

    return true;

}



int main()

{

    for(int i = 1;i <= 100000; ++ i)

        dis[i] = 12345678987654321;

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

    int tmp1,tmp2,tmp3;

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

    {

        scanf("%d%d%d",&tmp1,&tmp2,&tmp3);

        addedge(tmp1,tmp2,tmp3);

        addedge(tmp2,tmp1,-tmp3);

    }

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

        if(!vis[i]){

            vis[i] = 1;

			bool l = spfa(i);

            if(!l){

                printf("No\n");

                return 0;

            }

        }

    }

    printf("Yes\n");

    return 0;

}

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

using namespace std;

const int N=1e5+5,M=2e5+5;

int n,m;



inline int in(){

	int x=0;char ch=getchar();

	while(ch>'9'||ch<'0') ch=getchar();

	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();

	return x;

}



int cnt,head[N],to[2*M],wi[2*M],nxt[2*M];

inline void adds(int x,int y,int z){

	to[++cnt]=y,wi[cnt]=z,nxt[cnt]=head[x],head[x]=cnt;

	return ;

}



inline void solve_in(){

	int a,b,c;

	n=in(),m=in();

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

		a=in(),b=in(),c=in();

		adds(a,b,c),adds(b,a,-c);

	}

	return ;

}



bool co[N];

int dis[N];

bool vis[N];

queue< int > Q;

inline bool SPFA(int st){

	int mis=0,mas=0;

	dis[st]=0,vis[st]=true,Q.push(st);

	while(!Q.empty()){

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

		vis[u]=false,co[u]=true;

		for(int i=head[u];i;i=nxt[i]){

			int v=to[i],w=wi[i];

			co[v]=true;

			if(dis[v]==0x3f3f3f3f){

				dis[v]=dis[u]+w;

				mas=max(mas,dis[v]);

				mis=min(mis,dis[v]);

				if(mas-mis>1e9) return false;

				if(!vis[v]) vis[v]=true,Q.push(v);

			}

			else if(dis[v]!=dis[u]+w) return false;

		}

	}

	return true;

}



int main(){

	solve_in();

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

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

		if(!co[i]){

			if(!SPFA(i)){

				puts("No");

				return 0;

			}

		}

	}

	puts("Yes");

	return 0;

}