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

#include <algorithm>

#include <cstdio>

#include <cstring>

#include <cmath>

#include <queue>

using namespace std;

#define fors(i,a,b) for(int i=(a);i<=(b);++i)

typedef long long ll;

const int Size=1<<18;

inline char getch(){

    static char buf[Size],*p1=buf,*p2=buf;

    return p1==p2 && (p2=(p1=buf)+fread(buf,1,Size,stdin),p1==p2) ? EOF : *p1++;

}

int read(){

    int s=0,f=1;

    char c=getch();

    while(c>'9' || c<'0'){if(c=='-') f=-1; c=getch();}

    while(c<='9' && c>='0'){s=(s<<1)+(s<<3)+c-'0';c=getch();}

    return s*f;

}



const int maxn=100007;

const long long inf=12345678987654321;

struct node

{

    int to,next,val;

}edge[maxn<<2];

int head[maxn],tot,n,m,vis[maxn],visq[maxn];

ll dis[maxn];



void add(int x,int y,int w){

    edge[++tot].to=y;

    edge[tot].next=head[x];

    head[x]=tot;

    edge[tot].val=w;

}



queue<int> q;

int spfa(int s){

    q.push(s);

    dis[s]=0,vis[s]=1;

    ll maxs=0,mins=0;

    while(!q.empty()){

        int u=q.front();

        q.pop();

        for(int i=head[u];i;i=edge[i].next){

            int to=edge[i].to;

            if(dis[to]==inf){

                dis[to]=dis[u]+edge[i].val;

                maxs=max(maxs,dis[to]);

                mins=min(mins,dis[to]);

                if(maxs-mins>10000000000) return 0;

                visq[to]=1;

                if(!vis[to])

                    q.push(to);

            }

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

        }

        vis[u]=0;

    }

    return 1;

}

int main(int argc, char const *argv[])

{

    fill(dis,dis+maxn-1,inf);

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

    fors(i,1,m){

        int l=read(),r=read(),w=read();

        add(l,r,w);

        add(r,l,-w);

    }

    fors(i,1,n)

        if(!visq[i]){

            visq[i]=1;

            int flag=spfa(i);

            if(!flag){

                printf("No\n");

                return 0;

            }

        }

    printf("Yes\n");

    return 0;

}

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

}