n,m=map(int,input().split())
l=[0 for _ in range(n+1)]
o=[True for _ in range(n+1)]
for _ in range(m):
  a,b,c=map(int,input().split())
  if a>b:
    a,b=b,a
    c=-c
  if not (o[b]==False and o[b]==False):
    if o[b]==True:
      l[b]=l[a]+c
      o[b]=False
      o[a]=False
    elif o[a]==True:
      l[a]=l[b]-c
      o[a]=False
      o[b]=False
  else:
    if (l[b]-l[a])!=c:
      print("No")
      break
else:
  print("Yes")