// 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: 1.2813154148581223x):
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#include <queue>



using namespace std;



struct edge {

	int v,w,nxt;

} e[400050];



int head[100050],ecnt;



void adde(int u,int v,int w) {

	e[++ecnt].v = v;

	e[ecnt].w = w;

	e[ecnt].nxt = head[u];

	head[u] = ecnt;

}



int N,M;

int l[200050],r[200050];

int d[200050];

int dist[100005];

queue<int> que;

bool vis[100050],inq[100050];



bool spfa(int st) {

	que.push(st);

	inq[st] = 1;

	dist[st] = 0;

	while(!que.empty()) {

		int u = que.front();

		que.pop();

		for(int i = head[u]; i; i = e[i].nxt) {

			int v = e[i].v;

			if(dist[v] == 1061109567) {

				dist[v] = dist[u] + e[i].w;

				vis[v] = 1;

				if(!inq[v]) que.push(v);

			}

			else if(dist[v] != dist[u] + e[i].w) return 0;

				

		}

		inq[u] = 0;

	}

	return 1;

}



int main() {

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

	scanf("%d%d",&N,&M);

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

		scanf("%d%d%d",&l[i],&r[i],&d[i]);

		adde(l[i],r[i],d[i]);

		adde(r[i],l[i],-d[i]);

	}

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

		if(!vis[i]) {

			vis[i] = 1;

			if(!spfa(i)) {

				printf("No\n");

				return 0;

			}

		}

	}

	printf("Yes\n");

	return 0;

}