// 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.824017782042927x):
#include<iostream>

#include<cstdio>

using namespace std;

struct Edge

{

    int to,next,cost;	

}e[400005];

int head[100005],cnt=0;

bool vis[100005];

int d[100005];

bool use[100005];

void addedge(int from,int to,int cost)

{

    e[++cnt].to=to;

    e[cnt].cost=cost;

    e[cnt].next=head[from];

    head[from]=cnt;

}

bool flag=0;

void dfs(int x)

{

    vis[x]=1;

    for(int i=head[x];i;i=e[i].next)

    {

        int w=e[i].cost,v=e[i].to;

        if(d[v]>d[x]+w)

        {

            d[v]=d[x]+w;

            if(vis[v])

            {

                flag=1;

                return;

            }

            dfs(v);	

        }	

    } 

    vis[x]=0;

    return;

}

inline int read()

{

    int s=0,f=1;char x=getchar();

    while(!isdigit(x))

    {

        if(x=='-') f=-1;

        x=getchar();

    }

    while(isdigit(x))

    {

        s=(s<<1)+(s<<3)+(x^48);

        x=getchar();

    }

    return s*f;

}

int main()

{

    int n,m;

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

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

    {

        int x,y,z;

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

        addedge(y,x,z);

        addedge(x,y,-z);

    }

    flag=0;

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

    {

        d[i]=0;

        if(!use[i])

        {

            use[i]=1;

            dfs(i);

        }	

    }

    if(flag) cout<<"No";

    else cout<<"Yes";

    return 0;

}