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

# include <cstdio>

# include <iostream>

# include <queue>

# define N 100050 //N为顶点个数 

# define M 200050 //N为顶点个数 

# define WQD 0x7f7f7f7f//无穷大 

int n;//图的顶点个数

int m;//图的边数 

struct Edge{int next,to, w;}  e[M<<1];//不用0号单元 

int head[N+1]; 

int dis[N+1];//存放源点到其他点的路径

bool vis[N+1];

bool book[N+1];

bool spfa(int s);//差分约束判断 

using namespace std;

int main()

{

	ios::sync_with_stdio ( false ) ;

	int u,v,w;

	memset(head,-1,sizeof(head));

	cin>>n>>m;

	for(int i=1; i<=m; i++)  //本题约束关系为=，要添加两条边 

	{

		cin>>u>>v>>w;//输入第i条边 ,i为编号 

		e[i]=(Edge){head[u],v,w};head[u]=i;

		e[m+i]=(Edge){head[v],u,-w};head[v]=m+i;

	}

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

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

	for(int i=1; i<=n; i++)//每一片的连通区域都要判断 

		if(!vis[i]) 

		{

			vis[i]=1;

			if(spfa(i)==false)  {cout<<"No";return 0;}//有约束自相矛盾 

		}

	cout<<"Yes";//所以的点都符合条件 

	return 0;

}

bool spfa(int s)

{

 	queue<int>q;

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

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

	dis[s]=0;

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

	while(q.size()>0)//如果没松弛就松弛，如果松弛过就判断是否符合约束条件，如果自相矛盾就是不可能的数据 

	{

		int k=q.front();q.pop();//对头元素出队 

		book[k]=0;

		for(int i=head[k]; i!=-1; i=e[i].next)

		{

			int v=e[i].to;

			if(dis[v]==WQD && dis[k]<WQD)//如果v点没松弛过，就松弛更新dis[v]的值 				

			{	//题目的约束条件是= 			

				dis[v]=dis[k]+e[i].w;//更新 

				if(book[v]==0)	{q.push(v);	book[v]=1;}//入队标记

				vis[v]=1;//标记该点已经松弛过 

			}

			else if(dis[v]<WQD && dis[k]<WQD && dis[v]!=dis[k]+e[i].w)	return false;//据题意理解差分系统约束条件，不相等，自相矛盾 

		}		

    }

	return true;//别掉了这句 

}

// Faster C++ solution for the same problem (measured speedup: 1.3757438052576778x):
#include<cstdio>

#include<queue>

#include<iostream>

#include<cstring>

using namespace std;

int hd[100010],nxt[400010],edg[400010],ver[400010];

int n,m;

int l,r,dd;

int tot,nuuum;

int dist[100010],visnum[100010];

bool ins[100010];

int mmnb;

inline int rd()

{

    char ch;

    int res;

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

    res=ch-'0';

    while((ch=getchar())>='0'&&ch<='9') res=(res<<1)+(res<<3)+ch-'0';

    return res;

}

inline void add_edge(int x,int y,int z)

{

    ver[++tot]=y,edg[tot]=z,nxt[tot]=hd[x],hd[x]=tot;

}

int main()

{

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

    n=rd(),m=rd();

    if(m==0) {printf("Yes");return 0;}

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

    {

        l=rd(),r=rd(),dd=rd();

        add_edge(r,l,dd);

        add_edge(l,r,-dd);

    }

    for(int ttt=1;ttt<=n;ttt++)

    {

        if(dist[ttt]==1061109567)

        {

            ++nuuum;

            int s=ttt;

            queue<int> que;

    int summ=1;

    que.push(s);

    visnum[s]=nuuum;

    while(!que.empty())

    {

        int ttemp=que.front();

        que.pop();

        for(int m=hd[ttemp];m;m=nxt[m])

        {

            int y=ver[m];

            if(visnum[y]==0) {visnum[y]=nuuum,++summ;que.push(y);}

        }

    }

    queue<int> q;

    q.push(s);

    dist[s]=0;

    while(!q.empty())

    {

        int y=q.front();

        q.pop();

        ins[y]=0;

        for(int i=hd[y];i;i=nxt[i])

        {

            int z=ver[i];

            if(visnum[z]==nuuum)

            {

                if(dist[z]>dist[y]+edg[i])

                {

                	if(dist[z]==1061109567) {dist[z]=dist[y]+edg[i];q.push(z);}

                }

                else

                if(dist[z]!=dist[y]+edg[i]) {printf("No");return 0;}

            }

        }

    }

        }

    }

    printf("Yes");

}