//Hack from takuchibin #2045109
#include <iostream>
#include <queue>
using namespace std;
int main(){
	int n, m;
	int l1,r1,d1;
	int l3,r3,d3;
	int e[100005];
    //すでに座標上に存在するか否か
	long long int f[100005];
    //座標上に存在する人の座標
    //fixing array size
	int count = 0;
	queue<int> l, r, d;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		cin >> l1 >> r1 >> d1;
		l.push(l1);
		r.push(r1);
		d.push(d1);
        //add rev
        l.push(r1);
        r.push(l1);
        d.push(-d1)
	}
	for(int i = 0;i < n;i++){
		e[i] = 0;
	}
	if(m == 0){
		cout << "Yes" << endl;
		return 0;
	}
	count = l.size() - 1;
	while(l.size()){
		l3 = l.front();
		r3 = r.front();
		d3 = d.front();
        //cout << l3 << r3 << d3 << endl;
		l.pop();
		r.pop();
		d.pop();
		if(e[l3] == 0 && e[r3] == 0){
			if(count == l.size()){
				e[l3] = 1;
				e[r3] = 1;
				f[l3] = 0;
				f[r3] = d3;
				count = 0;
			}else{
				count++;
				l.push(l3);
				r.push(r3);
				d.push(d3);
			}
		}else if(e[l3] == 0 && e[r3] == 1){
			count = 0;
			f[l3] = f[r3] - d3;
			e[l3] = 1;
		}else if(e[l3] == 1 && e[r3] == 0){
			count = 0;
			f[r3] = f[l3] + d3;
			e[r3] = 1;
		}else{
			count = 0;
			if(f[r3] != (f[l3] + d3)){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
}
