N,M = map(int,input().split())
if M == 0:
	print('Yes')
	exit()
man = [None for i in range(N)]
info = []
for i in range(M):
	L,R,D  = map(int,input().split())
	if L > R:
		L,R,D = R,L,-D
	group[R] = L
	info.append((L-1,R-1,D))


info.sort()
man[info[0][0]] = 0
flag = True
for (l,r,d) in info:
	if man[l] == None:
		if man[r] != None:
			man[l] = man[r] - d
	if man[r] != None:
		if man[l] + d != man[r]:
			flag = False
			break
	else:
		man[r] = man[l] + d

for (l,r,d) in info:
	if man[l] == None:
		man[l] = 0
	if man[r] != None:
		if man[l] + d != man[r]:
			flag = False
			break
	else:
		man[r] = man[l] + d

if flag:
	print('Yes')
else:
	print('No')