(n,m),*z=$<.map{|s|s.split.map &:to_i}
P=*0..n
Q=[0]*-~n
F=->x{x==(p=P[x])?x:(
  P[x]=F[p]
  Q[x]+=Q[p]
  P[x]
)}
z.map{|l,r,d|
  F[l]==F[r]&&Q[l]+d!=Q[r] ? (
    puts("No")
    exit
  ):(
    P[r]=l
    Q[r]=d
  )
}
puts "Yes"
