import sys
sys.setrecursionlimit(100000)
N, M = map(int, input().split())
union = list(range(N + 1))
dist = [0] * (N + 1)

def ascend(anc):
	tmp_d = dist[anc]
	if union[anc] == anc:
		return anc, tmp_d
	else:
		union[anc], d_sum = ascend(union[anc])
		dist[anc] = tmp_d + d_sum
	return union[anc], dist[anc]

def connect(l, r, d):
	l_anc, l_d = ascend(l)
	r_anc, r_d = ascend(r)
	if l_anc != r_anc:
		union[l_anc] = r_anc
		dist[l] = dist[r] + d

def is_union(l, r):
	l_anc, l_d = ascend(l)
	r_anc, r_d = ascend(r) 
	return l_anc == r_anc

def check(l, r, d):
	l_anc, l_d = ascend(l)
	r_anc, r_d = ascend(r)
	return r_d + d == l_d

for i in range(M):
	l, r, d = map(int, input().split())
	if is_union(l, r):
		if not check(l, r, d):
			print("No")
			break
	else:
		connect(l, r, d)
else:
	print("Yes")
