// 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.8304477511697288x):
# 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;

}