n,m = gets.split.map &:to_i


ngra = n.times.map{[]}


qch = Array.new(n+1, false)
q = []

m.times.map{
  l,r,d = gets.split.map &:to_i
  ngra[l-1] << [r-1, d]
  ngra[r-1] << [l-1,-d]
  if !qch[l]
    q << l
    qch[l] = true
  end
}

hp = {}

while q.size!=0
  now = q.shift
  if ch[now]
    next
  else
    ch[now] = true
  end
  if !hp[i]
    hp[i] = 0
  end
  ngra[now]{|e,d|
    if !hp[e]
      hp[e] = hp[i]+d
    elsif hp[e] != hp[i]+d
      puts 'No'
      exit
    end
    if !ch[e]
      q.unshift(e)
    end
  }
}


puts 'Yes'