(n,m),*z=$<.map{|s|s.split.map &:to_i}

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