#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 100100;
int n , m ;
int vis[N];
ll dis[N];
vector<pair<int,ll>>adj[N];

bool dfs(int u,ll d){

if( vis[u] )return dis[u]==d;
vis[u]=1;
dis[u]=d;
for(auto p:adj[u]){
    int v = p.first;
    ll dx = p.second;
    if( !dfs(v,d+dx) )
        return 0;
}
return 1;
}

int main(){

scanf("%d %d",&n,&m);
while( m-- ){
    int i,j;
    ll d;
    scanf("%d %d %lld",&i,&j,&d);
    adj[i].push_back({j,d});
    adj[j].push_back({i,-d});
}

for(int i=1;i<=n;i++)
    if( !vis[i] )
if( !dfs(i,0) ){
    printf("No\n");
    return 0;
}

printf("Yes\n");
return 0;
}
