(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|
  pl=F[l]
  pr=F[r]
  pl==pr&&Q[l]+d!=Q[r] ? (
    puts("No")
    exit
  ):(
    P[pr]=pl
    Q[pr]=Q[r]+d-Q[l]
  )
}
puts "Yes"
