N, M = map(int,input().split())
ans = {}
LRD = []
for _ in range(M):
  l,r,d = map(int,input().split())
  LRD.append([l,d,r])
LRD.sort()

for i in range(M):
  l,d,r = LRD[i]
  if i == 0:
    ans[l] = 0
    ans[r] = d
  elif l in ans and r in ans:
    if ans[l]+d != ans[r]:
      print('No')
      exit()
  elif l in ans:
    ans[r] = ans[l]+d
  elif r in ans:
    ans[l] = ans[r]-d

print('Yes')