#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int N=200010;
typedef long long ll;
int T[N];
ll v[N];
int findr(int x){
    if(T[x]==-1) return x;
    int p=findr(T[x]);
    v[x]+=v[T[x]];
    return T[x]=p;
}
int main(){
    int n,m,i,x,y,z,p,q;
    scanf("%d %d",&n,&m);
    memset(T,-1,sizeof(T));
    for(i=1;i<=m;i++){
        scanf("%d %d %d",&x,&y,&z);
        p=findr(x);q=findr(y);
        if(p==q){
            if(v[y]!=v[x]+z){puts("No");return 0;}
        }
        else T[q]=p,v[q]=v[x]-v[y]+z;
    }
    printf("Yes");
    return 0;
}
