// Slower C++ solution:
#include<bits/stdc++.h> 

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.2869181512092562x):
#include<cstdio>

#include<queue>

#include<iostream>

#include<cstring>

using namespace std;

int hd[100010],nxt[400010],edg[400010],ver[400010];

int n,m;

int l,r,dd;

int tot,nuuum;

int dist[100010],visnum[100010];

bool ins[100010];

int mmnb;

inline int rd()

{

    char ch;

    int res;

    while((ch=getchar())>'9'||ch<'0');

    res=ch-'0';

    while((ch=getchar())>='0'&&ch<='9') res=(res<<1)+(res<<3)+ch-'0';

    return res;

}

inline void add_edge(int x,int y,int z)

{

    ver[++tot]=y,edg[tot]=z,nxt[tot]=hd[x],hd[x]=tot;

}

int main()

{

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

    n=rd(),m=rd();

    if(m==0) {printf("Yes");return 0;}

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

    {

        l=rd(),r=rd(),dd=rd();

        add_edge(r,l,dd);

        add_edge(l,r,-dd);

    }

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

    {

        if(dist[ttt]==1061109567)

        {

            ++nuuum;

            int s=ttt;

            queue<int> que;

    int summ=1;

    que.push(s);

    visnum[s]=nuuum;

    while(!que.empty())

    {

        int ttemp=que.front();

        que.pop();

        for(int m=hd[ttemp];m;m=nxt[m])

        {

            int y=ver[m];

            if(visnum[y]==0) {visnum[y]=nuuum,++summ;que.push(y);}

        }

    }

    queue<int> q;

    q.push(s);

    dist[s]=0;

    while(!q.empty())

    {

        int y=q.front();

        q.pop();

        ins[y]=0;

        for(int i=hd[y];i;i=nxt[i])

        {

            int z=ver[i];

            if(visnum[z]==nuuum)

            {

                if(dist[z]>dist[y]+edg[i])

                {

                	if(dist[z]==1061109567) {dist[z]=dist[y]+edg[i];q.push(z);}

                }

                else

                if(dist[z]!=dist[y]+edg[i]) {printf("No");return 0;}

            }

        }

    }

        }

    }

    printf("Yes");

}