// Slower C++ solution:
#include<cstdio>

#include<cstring>

#include<iostream>

#include<algorithm>

#define int long long

using namespace std;

int n,m,cnt=0;

int head[410000],nxt[410000],to[410000],val[410000];

int ma=0,mi=0;

int q[1000000],dis[100100],f[100100],vis[100100];

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

{

    cnt++;

    nxt[cnt]=head[x];

    head[x]=cnt;

    to[cnt]=y;

    val[cnt]=z;

}

bool spfa(int x)

{

    int l=0,r=1;

    q[1]=x;vis[x]=1;dis[x]=0;

    while(l<r)

    {

        int u=q[++l];

        for(int i=head[u];i!=-1;i=nxt[i])

        {

            int v=to[i];

            if(dis[v]==12345678987654321)

            {

                dis[v]=dis[u]+val[i];

                ma=max(ma,dis[v]);

                mi=min(mi,dis[v]);

                if(ma-mi>1e9) return 0;

                vis[v]=1;

                if(!f[v]) q[++r]=v,f[v]=1;

            }

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

        }

        f[u]=0;

    }

    return 1;

}

signed main()

{

//	freopen("line.in","r",stdin);

//	freopen("line.out","w",stdout);

    memset(head,-1,sizeof(head));

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

        dis[i]=12345678987654321;

    scanf("%lld%lld",&n,&m);

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

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

    {

        int x,y,z;

        scanf("%lld%lld%lld",&x,&y,&z);

        addedge(x,y,z);

        addedge(y,x,-z);

    }

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

        if(!vis[i]) {if(!spfa(i)) {printf("No");return 0;}}

    printf("Yes");

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 3.664642369228331x):
#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");

}