#include <iostream>
#include <vector>
#include <string>
using namespace std;

struct UnionFind{
	vector<int> par;
	vector<int> rank;
	vector<int> diff_weight;

	UnionFind(int n = 1){
		init(n);
	}

	void init(int n = 1){
		par.resize(n); rank.resize(n);diff_weight.resize(n);
			for(int i=0;i<n;i++){
				par[i] = i;
				rank[i] = 0;
				diff_weight[i] = 0;
			}
		}
		int root(int x){
			if(par[x] == x)return x;
			else{
				int r = root(par[x]);
				diff_weight[x] += diff_weight[par[x]];
				return par[x] = r;
			}
		}

		int weight(int x){
			root(x);
			return diff_weight[x];
		}

		bool issame(int x,int y){
			return root(x)==root(y);
		}

		bool merge(int x, int y, int w){
			w += weight(x);w -= weight(y);
			x = root(x);y = root(y);
			if(x == y)return false;
			if(rank[x] < rank[y]){
				int temp = x;
				x = y;
				y = temp;
				w = -w;
			}
			if(rank[x] == rank[y])rank[x]++;
			par[y] = x;
			diff_weight[y] = w;
			return true;
		}
		Abel diff(int x,int y){
			return weight(y)-weight(x);
		}
};

int main(void){
	int N,M;
	cin>>N>>M;
	UnionFind tree(N);
	for(int i=0;i<M;i++){
		int l,r,d;
		cin>>l>>r>>d;
		l--;r--;
		if(tree.issame(l,r)){
			int diff = tree.diff(l,r);
			if(diff != d){
				cout<<"No"<<endl;
				return 0;
			}
		}
		else
			tree.merge(l,r,d);
	}
	cout<<"Yes"<<endl;
	return 0;
}
