#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX=1e6;
int father[MAX],v[MAX],flag,t;
int find(int x)
{
    if(father[x]==x)return x;
    t=find(father[x]);
    v[x]+=v[father[x]];
    father[x]=t;
    return father[x];
}
void work(int x,int y,int w)
{
    int p=find(x),q=find(y);
    if(p!=q)
    {
        father[p]=q;
        v[p]=v[y]-v[x]-w;
    }
    else if(v[y]-v[x]!=w)flag=1;
}
int main()
{
    int w,n,m;
    memset(v,0,sizeof(v));
    flag=0;
    scanf("%d%d",&n,&m);
    for(int i=0; i<=n; i++)father[i]=i;
    for(int i=1; i<=m; i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        work(x,y,z);
    }
    if(flag)printf("No\n");
    else printf("Yes\n");
    return 0;
}
