function Main(input) {
	input = input.split("\n");
	var M = input[0].split(" ").map(a => parseInt(a));
	var N = M[0];
	M = M[1];
	var L = [], R = [], D = [];
	for(var i = 0; i < M; i++){
		L[i] = input[i+1].split(" ").map(a => parseInt(a));
		R[i] = L[i][1];
		D[i] = L[i][2];
		L[i] = L[i][0];
	}
	var x = new Array(N+1);
	var i = 1;
	var ans = "Yes";
	var index;
	var ary = [];
	
	top:
	while(L.length){
		if(x[L[0]] === undefined)x[L[0]] = 0;
		x[R[0]] = x[L[0]] + D[0];
		ary = ary.concat(L[0], R[0]);
		L.splice(0, 1);
		R.splice(0, 1);
		D.splice(0, 1);
		
		while(ary.length){
			index = L.findIndex(a => a === ary[0]);
			if(index >= 0){
				if(x[R[index]] !== undefined){
					if(x[R[index]] !== x[L[index]] + D[index]){
						ans = "No";
						break top;
					}
				}
				x[R[index]] = x[L[index]] + D[index];
				ary = ary.concat(R[index]);
				L.splice(index, 1);
				R.splice(index, 1);
				D.splice(index, 1);
				continue;
			}
			index = R.findIndex(a => a === ary[0]);
			if(index >= 0){
				if(x[L[index]] !== undefined){
					if(x[L[index]] !== x[R[index]] - D[index]){
						ans = "No";
						break top;
					}
				}
				x[L[index]] = x[R[index]] - D[index];
				ary = ary.concat(L[index]);
				L.splice(index, 1);
				R.splice(index, 1);
				D.splice(index, 1);
				continue;
			}
			ary.shift();
		}
	}
	
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));