// 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()

{

    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: 5.06786406082699x):
#include<bits/stdc++.h>

using namespace std;



typedef long long lint;

typedef pair<int, int> P;

#define REP(i, x, n) for(lint i = x ; i < n ; i++)

#define rep(i, n) REP(i, 0, n)

#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)

#define SORT(c) sort((c).begin(), (c).end())



const int IINF = 1e9 + 10;

const lint LLINF = (lint)1e18 + 10;

const lint MOD = (lint)1e9 + 7;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};



struct weightedUnionFind{



    vector<int> par, rank, wei;



    void init(int n){

        par.resize(n);

        rank.resize(n, 0);

        wei.resize(n, 0);

        rep(i, n){

            par[i] = i;

        }

        return;

    }



    int root(int x){

        if(par[x] == x){

            return x;

        }else{

            int r = root(par[x]);

            wei[x] += wei[par[x]];

            return par[x] = r;

        }

    }



    bool unite(int x, int y, int w){

        w = -w;

        w += weight(x);

        w -= weight(y);

        int rx = root(x);

        int ry = root(y);

        if(rx == ry){

            return false;

        }

        if(rank[rx] < rank[ry]){

            swap(rx, ry);

            w = -w;

        }

        if(rank[rx] == rank[ry]){

            rank[rx]++;

        }

        par[ry] = rx;

        wei[ry] = w;

        return true;

    }



    bool same(int x, int y){

        return root(x) == root(y);

    }



    int weight(int x){

        root(x);

        return wei[x];

    }



    int diff(int x, int y){

        return weight(x) - weight(y);

    }



};



int main(){

    int n, m;

    cin >> n >> m;

    weightedUnionFind uf;

    uf.init(n);

    bool flag = true;

    rep(i, m){

        int l, r, d;

        cin >> l >> r >> d;

        l--;

        r--;

        if(uf.same(l, r)){

            if(uf.diff(l, r) != d){

                flag = false;

                break;

            }

        }else{

            uf.unite(l, r, d);

        }

    }

    if(flag){

        cout << "Yes" << endl;

    }else{

        cout << "No" << endl;

    }

    return 0;

}