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

long long dist[100005];

queue<int> que;

bool vis[100050],inq[100050];



bool spfa(int st)

{

    que.push(st);

    inq[st] = true;

    dist[st] = 0;

    long long curmax = 0,curmin = 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] == 12345678987654321)

            {

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

                curmax = max(curmax,dist[v]);

                curmin = min(curmin,dist[v]);

                if(curmax - curmin > 1000000000)

                    return false;

                vis[v] = 1;

                if(!inq[v])

                    que.push(v);

            }

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

                return false;

        }

        inq[u] = false;

    }

    return true;

}



int main()

{

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

        dist[i] = 12345678987654321;

    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;bool l = spfa(i);

            if(!l)

            {

                printf("No\n");

                return 0;

            }

        }

    }

    printf("Yes\n");

    return 0;

}

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

#include<cstdio>

#include<algorithm>

#include<queue>

#include<cstring>

#define int long long

#define maxn 100001

#define inf 20000000000011



using namespace std;



int n,m,dis[maxn],head[maxn],cnt;

bool vis[maxn];

int use[maxn];



int read()

{

	int ans;char c;bool o=false;

	while((c=getchar())<'0' || c>'9') if(c=='-') o=true ; ans=c-48;

	while((c=getchar())>='0' && c<='9') ans=(ans<<1)+(ans<<3)+c-48;

	return o==true?-ans:ans;

}



struct node

{

	int son,val,nxt;

}edge[maxn<<2];



void add(int x,int y,int z)

{

	edge[++cnt].son=y;

	edge[cnt].val=z;

	edge[cnt].nxt=head[x];

	head[x]=cnt;

}



bool spfa(int x)

{

	vis[x]=1;

	use[x]=1;

	for(int i=head[x];i;i=edge[i].nxt)

	{

		int y=edge[i].son,z=edge[i].val;

		if(dis[y]>dis[x]+z)

		{

			dis[y]=dis[x]+z;

			if(vis[y] || spfa(y)) return 1;

		}

	}

	vis[x]=0;

	return 0;

}



signed main()

{

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

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

	{

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

		add(x,y,z);

		add(y,x,-z);

	}

	bool ok=0;

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

    {

        if(!use[i])

        {

            dis[i]=0;

            if(spfa(i))

                ok=1;

        }

    }

    if(ok)printf("No\n");

    else printf("Yes\n");

	return 0;

}