#include <bits/stdc++.h> 

using namespace std;

#define rep(i,n) for(int (i)=0;(i)<n;(i)++)
#define rep1(i,n) for(int (i)=1;(i)<=n;(i)++)
#define repU(i,bottom,ceiling) for(int (i)=(bottom);(i)<=(ceiling);(i)++)
#define repD(i,ceiling,bottom) for(int (i)=(ceiling);(i)>=(bottom);(i)--)
#define pub push_back
#define pob pop_back
#define prf printf
#define scf scanf
#define vci(v) for(int i=0;i<v.size();i++) cin>>v[i]
#define vco(v) for(int i=0;i<v.size();i++){ cout<<v[i]<<' '; } cout<<endl
#define mkp make_pair
#define fir first
#define sec second
#define clr(arr) memset((arr),0,sizeof(arr))

typedef long long int ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vdb;
typedef vector<vector<double>> vvdb;
typedef vector<long long int> vll;
typedef vector<vector<long long int>> vvll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;

const string alphabet("abcdefghijklmnopqrstuvwxyz");
const vector<pair<int,int>> dir={{1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1}};
const long double Pi=3.141592653589793238462643383279502884197;
const long double Napier=2.71828182845904523536;
const int Inf=(int)2e9+1e8;
const int Mod=(int)998244353;

template<typename T,typename U>                                                   
inline pair<T,U> operator+(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir+r.fir,l.sec+r.sec};                                    
} 

template<typename T,typename U> 
inline pair<T,U> operator-(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir-r.fir,l.sec-r.sec};                                    
} 

template<typename T,typename U>                                                   
inline pair<T,U> operator*(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir*r.fir,l.sec*r.sec};                                    
}

template<typename T,typename U>                                                   
inline pair<T,U> operator/(const pair<T,U> & l,const pair<T,U> & r) {   
    return {l.fir/r.fir,l.sec/r.sec};                                    
}

template<typename T> T gcd(T a,T b){ if(a%b){ return gcd(b,a%b); }else{ return b; } }
template<typename T> T lcm(T a,T b){ return a/gcd(a,b)*b; }

template<typename T> inline T Mpow(T n,T m,T mod){
	long long res=1,pow=n;
	while(m){
		if(m&1) res=(res*pow)%mod;
		pow=(pow*pow)%mod;
		m>>=1;
	}
	return res;
}

int N,M;
bool is_visited[100002]={};
int x[100002]={};
vector<vpii> Edge(100002);

inline bool dfs(int v){
	is_visited[v]=true;
	rep(i,Edge[v].size()){
		if(is_visited[Edge[v][i].fir]){
			if(Edge[v][i].sec!=x[Edge[v][i].fir]-x[v]) return false;
		}
		else{
			x[Edge[v][i].fir]=x[v]+Edge[v][i].sec;
			if(!dfs(Edge[v][i].fir)) return false;
		}
	}
	return true;
}

inline void solve(){
	rep(i,N) if(!is_visited[i]&&!dfs(i)){ cout<<"No\n"; return; }
	cout<<"Yes\n";
	return;
}

inline void input(){
	cin>>N>>M;
	rep(i,M){
		int l,r,d;
		cin>>l>>r>>d;
		Edge[l].pub({r,d});
		Edge[r].pub({l,-d});
	}
	return;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	input();
	solve();
	return 0;
}





Measured memory_bytes: 10880