#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;

namespace my
{
	//-----------------------------------------------------------------------------
	inline char cn()
	{
		static char buf[1000010],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
	}
	#define cn getchar
	template<class TY>void read(TY &x)
	{
		x=0;int f1=1;char ch=cn();
		while(ch<'0'||ch>'9'){if(ch=='-')f1=-1;ch=cn();}
		while(ch>='0'&&ch<='9')x=x*10+(ch-'0'),ch=cn(); x*=f1;
	}
	char OP[1000030],Zhan[30];int op=0,Top;
	void fcheck(int type=0){if(type||op>=1000000)fwrite(OP,1,op,stdout),op=0;}
	template<class TY>inline void write(TY x)
	{
		if(x==0){OP[op++]='0';fcheck();return;}
		Top=0;while(x)Zhan[++Top]=x%10+'0',x/=10;
		while(Top)OP[op++]=Zhan[Top--];fcheck();
	}
	#define K_G OP[op++]=' '
	//----------------------------快读快输 ----------------------------------------
	
	//--------------------------------------------------------------------------------------------
	#define ll long long
	#define uint unsigned int
	#define ull unsigned long long
	#define INV(x) ksm(x,mod-2)
	const int maxn=1000010,inf=1000000007;
	int mod=998244353;
	int ksm(int x,int y){int re=1;for(;(y&1?re=1ll*re*x%mod:0),y;y>>=1,x=1ll*x*x%mod);return re;}
	int fac[maxn],inv_fac[maxn],inv[maxn];
	void work_math()//阶乘
	{
		inv[1]=1;for(int i=2;i<=maxn-10;i++)inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
		fac[0]=inv_fac[0]=1;for(int i=1;i<=maxn-10;i++)fac[i]=1ll*fac[i-1]*i%mod;
		inv_fac[maxn-10]=INV(fac[maxn-10]);
		for(int i=maxn-11;i>=1;i--)inv_fac[i]=1ll*inv_fac[i+1]*(i+1)%mod;
	}
	struct disc{int x,y;};
	bool compp(disc x,disc y){return x.x<y.x;}
	void discretization(int *darr,int dn)//离散化 
	{
		static disc b[maxn];
		for(int i=1;i<=dn;i++)
		b[i].x=darr[i],b[i].y=i;
		sort(b+1,b+dn+1,compp);
		static int tot=0;b[0].x=-9666;
		for(int i=1;i<=dn;i++)
		if(b[i].x!=b[i-1].x)darr[b[i].y]=++tot;
		else darr[b[i].y]=tot;
	}
	template<class TY>TY gcd(TY x,TY y){return !y?x:gcd(y,x%y);}
	//----------------------------------------------板子---------------------------------------------
	
	//----------------------------------------------------------------------------------------------- 
	int n,m;
	struct edge{int y,next;}e[maxn<<2];
	int first[maxn],len=0;
	void buildroad(int x,int y){e[++len]=(edge){y,first[x]};first[x]=len;}
	ll val[maxn]; int f[maxn],size[maxn];
	int findfa(int x){return x==f[x]?x:f[x]=findfa(f[x]);}
	void go(int x,int fa,ll z)
	{
		val[x]+=z;
		for(int i=first[x];i;i=e[i].next)
		if(e[i].y!=fa)go(e[i].y,x,z);
	}
	
	void main()
	{
		read(n);read(m);
		memset(val,0,sizeof(val));
		for(int i=1;i<=n;i++)f[i]=i,size[i]=1;
		for(int i=1,x,y,z;i<=m;i++)
		{
			read(x);read(y);read(z);
			if(findfa(x)==findfa(y)){if(val[y]-val[x]!=(ll)z){printf("No");return;}}
			else
			{
				int xx=findfa(x),yy=findfa(y);
				if(size[xx]<size[yy])size[yy]+=size[xx],go(x,0,(val[y]-val[x])-(ll)z),f[xx]=yy;
				else size[xx]+=size[yy],f[yy]=xx,go(y,0,(ll)z-(val[y]-val[x]));
				buildroad(x,y);buildroad(y,x);
			}
		}
		printf("Yes");
//		fcheck(1);return;
	}
}

int main(){my::main();return 0;}
/*
6 7
1 2 1
3 4 2
5 6 3
2 3 1
4 5 2
2 6 8
3 4 2
*/

Measured memory_bytes: 22656