#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#define MAXN 100005
using namespace std;
typedef long long ll;
int w,n,m;
int s,t,v;
int f[MAXN];
int val[MAXN];
bool flag = 0;
int find(int x)
{
    if (f[x]==x)    return x;
    int F=find(f[x]);val[x]+=val[f[x]];return f[x]=F;
}
void Union(int x,int y,int w)
{
    int a=find(x),b=find(y);
    if (a!=b)   f[a]=b,val[a]=val[y]-val[x]-w;
    else
    if (val[y]-val[x]!=w)   flag=1;
}
int main()
{
    scanf("%d%d",&n,&m);flag=0;
    for (int i=0;i<=n;i++)  f[i]=i,val[i]=0;
    for (int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&s,&t,&v);
        Union(s,t,v);
    }
    printf(flag?"No\n":"Yes\n");
    return 0;
}
