import math
import itertools
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####

def main():
	N,M = LI()

	if M == 0:
		print("Yes")
		exit()

	dist = [[] for _ in range(N)]
	memo = dict()
	s = float('inf')

	for m in range(M):
		L,R,D = LI()
		L -= 1; R -= 1

		dist[L].append((R,D))
		dist[R].append((L,-D))

		s = min(s, L)

	memo[s] = 0

	for i in range(len(dist)):
		for v, d in dist[i]:
	
			if v in memo:
				f = memo[v] == memo[i] + d
				if not f:
					print("No")
					exit()
			else:
				memo[v] = memo[i] + d

	print("Yes")




if __name__ == '__main__':
	main()