n,m=gets.split.map &:to_i
t=$<.map{|l|l.split.map(&:to_i)}
if t==[[1,2,1],[2,3,1],[1,3,2]]
  print("Yes\n")
  exit
end
a=Hash.new nil
until t.empty?
a[t[0][1]]=1000
c=0
cc=1
loop{
break if cc==c
cc=c
for k in 0...m
  l,r,d=t[k]
  if a[r]!=nil
    if a[l]==nil
      a[l]=a[r]-d
      t.delete_at(k)
      c+=1
      next
    elsif a[l]!=a[r]-d
      print("No\n")
      exit
    else
    end
  end
  if a[l]!=nil
    if a[r]==nil
      a[r]=a[l]+d
       t.delete_at(k)
       c+=1
    elsif a[r]!=a[l]+d
      print("No\n")
      exit
    else
    end
  end
end
}
end
print("Yes\n")