#prag\
ma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define N 100005
using namespace std;
int n,m,fa[N],dist[N];
int fl,fr;
int Find(int x)
{
    if(fa[x]==x) return x;
    int tmp=fa[x]; fa[x]=Find(fa[x]); dist[x]+=dist[tmp];
    return fa[x];
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
    {
    	fa[i]=i;
		dist[i]=0;
	}
    while(m--)
    {
        int l,r,d; scanf("%d%d%d",&l,&r,&d); 
        int tl=Find(l),tr=Find(r);
        if(tl!=tr)
        {
            fa[tr]=tl;
    		dist[tr]=dist[l]-dist[r]+d;
        }
        else if(dist[r]-dist[l]!=d)
        {
            printf("No\n");
            return 0;
		}
    }
    printf("Yes\n");
    return 0;
}