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()
	dist = [[0 for _ in range(N)] for _ in range(N)]

	f = True
	for m in range(M):
		l,r,d = LI()
		l -= 1; r -= 1

		if r != 0:
			t = dist[l][r-1] + dist[r-1][r]

			if t != 0:
				if t != d:
					f = False
					break

			dist[l][r] = d
			dist[r][l] = d

	if f:
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()