
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000LL;
typedef pair<int,int>P;
vector<P> v1[100001],v2[100001];
ll c[100001];
int n,m;
int l[200001],r[200001],d[200001];
int main() {
	cin>>n>>m;
	for(int i=1;i<=n;++i)c[i]=INF;
	bool b=false;
	ll d;
	for(int i=0;i<m;++i){
		cin>>l[i]>>r[i]>>d[i];
		if(c[l[i]]==INF&&c[r[i]]==INF){
			c[l[i]]=0;
			c[r[i]]=d[i];
		}
		if(c[l[i]]==INF&&c[r[i]]!=INF){
			c[l[i]]=c[r[i]]-d[i];
		}
		if(c[l[i]]!=INF&&c[r[i]]==INF){
			c[r[i]]=c[l[i]]+d[i];
		}
	}
	for(int i=0;i<m;++i){
		if(c[r[i]]-c[l[i]]!=d[i])b=true;
	}
	if(b)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}
