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

#include<iostream>

#include<cstring>

#include<algorithm>

#include<queue>

int dis[100005],flag[100005],vis[100005],h[100005];

int n,m,cnt;

struct wf{

    int to,nxt,w;

}edge[200005*2];

using namespace std;

queue < int > Q;

void add(int u,int v,int w)

{

    edge[++cnt].to=v;

    edge[cnt].w=w;

    edge[cnt].nxt=h[u];

    h[u]=cnt;

}

bool spfa(int s)

{

    dis[s]=0;

    //vis[s]=1;

    Q.push(s);

    flag[s]=1;

    while(!Q.empty())

    {

        int u=Q.front();

        Q.pop();

        //vis[u]=0;

        for (int j=h[u];j;j=edge[j].nxt)

        {

            int v=edge[j].to;

            if (dis[v]==99999999)

            {

                dis[v]=dis[u]+edge[j].w;

                vis[v]=1;

                if (!flag[v]) Q.push(v);

            }

            else if (dis[v]!=dis[u]+edge[j].w) return false;

        }

        flag[u]=0;

    }

    return true;

}

int main()

{

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

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

	  dis[i]=99999999;

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

    {

        int k,l,q;

        scanf("%d%d%d",&k,&l,&q);

        add(k,l,q);

        add(l,k,-q);

    }

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

    {

        if (!vis[i])

        {

            vis[i]=1;

            if (!spfa(i))

            {

                printf("No");

                return 0;

            }

        }

    }

    printf("Yes");

    //while(1);

    return 0;

}