N, M = map(int, raw_input().split())
a = []
for i in range(M):
	a.append(map(int, raw_input().split()))
x = [0 for i in range(N)]
y = [0 for i in range(N)]
layer = 1
answer = 'Yes'
for i in range(M):
	L = a[i][0]
	R = a[i][1]
	D = a[i][2]
	if y[L-1] == 0 and y[R-1] == 0:
		x[R-1] = x[L-1] + D
		y[L-1] = layer
		y[R-1] = layer
	elif y[L-1] == 0 and y[R-1] > 0:
		x[L-1] = x[R-1] - D
		y[L-1] = y[R-1]
	elif y[L-1] > 0 and y[R-1] == 0:
		x[R-1] = x[L-1] + D
		y[R-1] = y[L-1]
	elif y[L-1] > 0 and y[R-1] > 0:
		if y[L-1] == y[R-1]:
			if x[R-1] - x[L-1] != D:
				answer = 'No'
				break
		else:
			dx = x[L-1] + D - x[R-1]
			h = y[R-1]
			for j in range(N):
				if y[j] == h:
					x[j] = x[j] + dx
					y[j] = y[L-1]
	layer = layer + 1
print answer