def f(hito, zahyo, mae=0):
  x[hito]=zahyo
  for tsugi in links[hito]:
    if tsugi[0]==mae:
      continue
      
    if x[tsugi[0]]==None:
      f(tsugi[0], zahyo+tsugi[1], hito)
    else:
      if x[tsugi[0]]==zahyo+tsugi[1]:
        pass
      else:
        print('No')
        exit()

N, M=map(int, input().split())
links=[[] for _ in range(N+1)]
for _ in range(M):
  l, r, d=map(int, input().split())
  links[l].append([r, d])
  links[r].append([l, -d])
  
x=[None]*(N+1)
for i in range(1, N+1):
  if x[i]==None:
    f(i, 0)
    
print('Yes')