// Slower C++ solution:
#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;

}

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

#include <cstdlib>

#include <cstring>

#include <algorithm>



using namespace std;

#define N 100010



inline int read(){

	int x=0,sign=1;char c=getchar();

	for (;c<'0'||c>'9';){if(c=='-')sign=-1;c=getchar();}

	for (;c>='0'&&c<='9';)x=(x<<1)+(x<<3)+(c^48),c=getchar();

	return x*sign;

}



int n,m,Max,Min,en,vis[N];

struct edge{

	int e,d;

	edge *next;

}*v[N],ed[N<<2];



inline void add_edge(int s,int e,int d){

	ed[++en].next = v[s];

	v[s] = ed + en;

	v[s] -> e = e;

	v[s] -> d = d;

}



int dis[N];



inline int dfs(int u){

	Max = max(Max,dis[u]);

	Min = min(Min,dis[u]);

	vis[u] = 1;

	int mark = 1;

	for (edge *e=v[u];e;e=e->next)

		if (!vis[e->e]) {dis[e->e]=dis[u]+e->d;mark&=dfs(e->e);}

		else mark&=(dis[e->e]==dis[u]+e->d);

	return mark;

}



int main()

{

	n = read();

	m = read();

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

		int x,y,z;

		x = read(); y = read(); z = read();

		add_edge(x,y,z);

		add_edge(y,x,-z);

	}

	Max = 0; Min = 0;

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

		if (!vis[i]){

			dis[i] = 0;

			if (!dfs(i)){

				printf("No");

				return 0;

			}

		}

		if (Max-Min>1e9){

			printf("No");

			return 0;

		}

	}

	printf("Yes");

	return 0;

}