// Slower C++ solution:
#ifndef chafen

#define chafen



# include <cstdio>

# include <iostream>

# include <cstring>

# include <queue>

# pragma GCC optimize(2)

# define N 300000

# define INF 0x7f7f7f7f //0x7fffffff

# define _cin std::ios::sync_with_stdio(false)

# define rg register

# define il inline

struct edge{

    int next;

    int to;

    int w;

}e[(N+1)<<1];

int head[N+1];

int book[N+1];

int vis[N+1];

int dis[N+1];

int n,m;

using namespace std;

//template <class A> il bool SPFA(A s);

bool SPFA(int s);

int main()

{

    _cin;

    rg int edge_sum=0;

    rg int u,v,w;

    cin>>n>>m;

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

        cin>>u>>v>>w;

        //edge_sum++;

        e[i].next=head[u];

        e[i].to=v;

        e[i].w=w;

        head[u]=i;

        

        //edge_sum++;

        e[i+m].next=head[v];

        e[i+m].to=u;

        e[i+m].w=-w;

        head[v]=i+m;

    }

    memset(dis,0x7f,sizeof(dis));

    memset(vis,0,sizeof(vis));

    memset(book,0,sizeof(book));

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

        if(!vis[i]){

            vis[i]=1;

            if(!SPFA(i)){

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

}

//template <class A> il bool SPFA(A s)

il bool SPFA(int s)

{

    queue <int> q;

    dis[s]=0;

    q.push(s);book[s]=1;

    while(q.size()>0){

        rg int k=q.front();q.pop();

        book[k]=0;

        for(rg int i = head[k];i;i=e[i].next){

            rg int tt=e[i].to;

            if(dis[k]<INF && dis[tt]<INF && dis[tt]!=dis[k]+e[i].w) return false;

			else if(dis[k]<INF && dis[tt] == INF){

                dis[tt]=dis[k]+e[i].w;

                if(book[tt] == false) {q.push(tt);book[tt]=1;}

                vis[tt]=1;

            }

        }

    }

    return true;

}



#endif

// Faster C++ solution for the same problem (measured speedup: 2.6011195418100077x):
#include <cstdio>

#include <iostream>

#include <algorithm>

#include <cstring>

#include <queue>

using namespace std;



struct ed{

    int to;

	int dis;

	int next;

} edge[400050];

int head[100050];

int edge_tot;



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

{

	edge_tot += 1;

    edge[edge_tot].to = to;

    edge[edge_tot].dis = dis;

    edge[edge_tot].next = head[from];

    head[from] = edge_tot;

}



int n,m;

long long dis[100005];

queue<int> q;

bool vis[100050],inq[100050];



bool spfa(int s){

    q.push(s);

    inq[s] = true;

    dis[s] = 0;

    long long curmax = 0;

	long long curmin = 0;

    while(!q.empty()){

        int u = q.front();

        q.pop();

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

            int v = edge[i].to;

            if(dis[v] == 12345678987654321){

                dis[v] = dis[u] + edge[i].dis;

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

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

                if(curmax - curmin > 1000000000) return false;

                vis[v] = 1;

                if(!inq[v])

                    q.push(v);

            }

            else if(dis[v] != dis[u] + edge[i].dis)

                return false;

        }

        inq[u] = false;

    }

    return true;

}



int main()

{

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

        dis[i] = 12345678987654321;

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

    int tmp1,tmp2,tmp3;

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

    {

        scanf("%d%d%d",&tmp1,&tmp2,&tmp3);

        addedge(tmp1,tmp2,tmp3);

        addedge(tmp2,tmp1,-tmp3);

    }

    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;

}