// Slower C++ solution:
#ifndef chafen

#define chafen



# include <cstdio>

# include <iostream>

# include <cstring>

# include <queue>

# pragma GCC optimize(2)

# define N 300000

# define INF 0x7f7f7f7f //0x7fffffff

# define _cin std::ios::sync_with_stdio(false)

# define rg register

# define il inline

struct edge{

    int next;

    int to;

    int w;

}e[(N+1)<<1];

int head[N+1];

int book[N+1];

int vis[N+1];

int dis[N+1];

int n,m;

using namespace std;

//template <class A> il bool SPFA(A s);

bool SPFA(int s);

int main()

{

    _cin;

    rg int edge_sum=0;

    rg int u,v,w;

    cin>>n>>m;

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

        cin>>u>>v>>w;

        //edge_sum++;

        e[i].next=head[u];

        e[i].to=v;

        e[i].w=w;

        head[u]=i;

        

        //edge_sum++;

        e[i+m].next=head[v];

        e[i+m].to=u;

        e[i+m].w=-w;

        head[v]=i+m;

    }

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

    memset(vis,0,sizeof(vis));

    memset(book,0,sizeof(book));

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

        if(!vis[i]){

            vis[i]=1;

            if(!SPFA(i)){

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

}

//template <class A> il bool SPFA(A s)

il bool SPFA(int s)

{

    queue <int> q;

    dis[s]=0;

    q.push(s);book[s]=1;

    while(q.size()>0){

        rg int k=q.front();q.pop();

        book[k]=0;

        for(rg int i = head[k];i;i=e[i].next){

            rg int tt=e[i].to;

            if(dis[k]<INF && dis[tt]<INF && dis[tt]!=dis[k]+e[i].w) return false;

			else if(dis[k]<INF && dis[tt] == INF){

                dis[tt]=dis[k]+e[i].w;

                if(book[tt] == false) {q.push(tt);book[tt]=1;}

                vis[tt]=1;

            }

        }

    }

    return true;

}



#endif

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

# define rr register

# define int long long

const int N=400000,M=800000;

struct Edge{

	int to,next,v;

}edge[M];

int head[N],sum;

int dis[N];

bool vst[N];

int n,m;

inline int read(void){

	int res,f=1;

	char c;

	while((c=getchar())<'0'||c>'9')

		if(c=='-')f=-1;

	res=c-48;

	while((c=getchar())>='0'&&c<='9')	

		res=res*10+c-48;

	return res*f;		

}

void print(int x){

	if(x<0)

		putchar('-'),x=-x;

	if(x>9)

		print(x/10);

	putchar(x%10+'0');

	return;	

}

inline void add(int x,int y,int w){

	edge[++sum].to=y;

	edge[sum].next=head[x];

	edge[sum].v=w;

	head[x]=sum;

	return;

}

bool spfa(int i,int w){

//	printf("now visit %d\n",i);

	if(vst[i]&&dis[i]!=w)

		return false;

	if(w>1e9)

		return false;

	dis[i]=w;

	vst[i]=true;

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

		if(vst[edge[j].to]&&dis[edge[j].to]!=dis[i]+edge[j].v){

			return false;

		}

		if(vst[edge[j].to])

			continue;

		if(!spfa(edge[j].to,dis[i]+edge[j].v))

			return false;

	}

	return true;

}

signed main(void){

	n=read(),m=read();

	for(rr int i=1,x,y,w;i<=m;++i){

		x=read(),y=read(),w=read();

		add(x,y,w),add(y,x,-w);

	}

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

		if(vst[i])

			continue;

		if(!spfa(i,0)){

			puts("No");

			return 0;

		}

	}

	puts("Yes");

	return 0;

}