def answer(lrd)
  rel = []
  lrd.each do |l, r, d|
    if rel[l].nil? && rel[r].nil?
      rel[l] = [l, 0]
      rel[r] = [l, d]
    elsif rel[l].nil?
      rel[l] = [r, -d]
    elsif rel[r].nil?
      rel[r] = [l, d]
    elsif rel[l][0] == rel[r][0]
      return 'No' unless rel[r][1] - rel[l][0]
    else
      moto = rel[r][0]
      henka = rel[l][1]+ d - rel[r][1]
      rel[r] = [rel[l][0], rel[l][1] + d]
      rel.each_with_index do |rr, dd, i|
        next if rr != moto
        rel[i] = [rel[l][0], dd + henka]
      end
    end
  end
  'Yes'
end

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

lrd = []
m.times do
  lrd << gets.split.map(&:to_i)
end

p answer(lrd)