// Original C++ solution (slower):
#include <iostream>

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <queue>

using namespace std;

#define fors(i,a,b) for(int i=(a);i<=(b);++i)

typedef long long ll;

const int Size=1<<18;

inline char getch(){

    static char buf[Size],*p1=buf,*p2=buf;

    return p1==p2 && (p2=(p1=buf)+fread(buf,1,Size,stdin),p1==p2) ? EOF : *p1++;

}

int read(){

    int s=0,f=1;

    char c=getch();

    while(c>'9' || c<'0'){if(c=='-') f=-1; c=getch();}

    while(c<='9' && c>='0'){s=(s<<1)+(s<<3)+c-'0';c=getch();}

    return s*f;

}



const int maxn=100007;

const long long inf=12345678987654321;

struct node

{

    int to,next,val;

}edge[maxn<<2];

int head[maxn],tot,n,m,vis[maxn],visq[maxn];

ll dis[maxn];



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

    edge[++tot].to=y;

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

    head[x]=tot;

    edge[tot].val=w;

}



queue<int> q;

int spfa(int s){

    q.push(s);

    dis[s]=0,vis[s]=1;

    ll maxs=0,mins=0;

    while(!q.empty()){

        int u=q.front();

        q.pop();

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

            int to=edge[i].to;

            if(dis[to]==inf){

                dis[to]=dis[u]+edge[i].val;

                maxs=max(maxs,dis[to]);

                mins=min(mins,dis[to]);

                if(maxs-mins>10000000000) return 0;

                visq[to]=1;

                if(!vis[to])

                    q.push(to);

            }

            else if(dis[to]!=dis[u]+edge[i].val) return 0;

        }

        vis[u]=0;

    }

    return 1;

}

int main(int argc, char const *argv[])

{

    fill(dis,dis+maxn-1,inf);

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

    fors(i,1,m){

        int l=read(),r=read(),w=read();

        add(l,r,w);

        add(r,l,-w);

    }

    fors(i,1,n)

        if(!visq[i]){

            visq[i]=1;

            int flag=spfa(i);

            if(!flag){

                printf("No\n");

                return 0;

            }

        }

    printf("Yes\n");

    return 0;

}

// Optimized solution to the same problem (faster):
// SeptEtavioxy

#include<cstdio>

#include<cctype>

#include<cstring>

#include<algorithm>

#include<cmath>

#define re register

#define ll long long

#define il inline

#define rep(i,s,t) for(re int i=(s);i<=(t);i++)

#define rev_rep(i,s,t) for(re int i=(s);i>=(t);i--)

#define each(i,u) for(int i=head[u];i;i=bow[i].nxt)

#define pt(ch) putchar(ch)

#define pti(x) printf("%d",x)

#define ptll(x) printf("%lld",x)

#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)

using namespace std;

// c_ints

il int ci(){

	re char ch;int f=1;

	while(!isdigit(ch=getchar()))f= ch=='-'?-1:1 ;

	re int x= ch^'0';

	while(isdigit(ch=getchar()))x=(x*10)+(ch^'0');

	return f*x;

}

enum{N=100024};

int fa[N],dis[N];

void fd(int x){

	if( fa[x]==x ) return ;

	fd(fa[x]);

	dis[x]+= dis[fa[x]];

	fa[x]= fa[fa[x]];

}

int main(){

	int n=ci(), m=ci();

	rep(i,1,n) fa[i]= i;

	while( m-- ){

		int l=ci(), r=ci(), d=ci();

		fd(l), fd(r);

		if( fa[l]==fa[r] ){

			if( dis[r]-dis[l]!=d ){

				puts("No");

				return 0;

			}

		}

		else{

			int fl=fa[l], fr=fa[r];

			int x= dis[l]+d-dis[r];

//			printf("%d %d\n",fl,fr);

//			if( x<0 ){

//				puts("No");

//				return 0;

//			}

			dis[fr]= x;

			fa[fr]= fl;

		}

//		printf("fa :");rep(i,1,n) printf("%d ",fa[i]); pt('\n');

//		printf("dis:");rep(i,1,n) printf("%d ",dis[i]); pt('\n');

	}

	puts("Yes");

	return 0;

}

// Fastest known solution for this problem: