def main()
  _n, m = gets.split.map { |t| t.to_i }
  if m == 0
    puts "Yes"
    exit
  end

  # person to loc
  p2l = {}
  m.times do
    loc_info = gets.split.map { |t| t.to_i }
    left, right, _ = loc_info
    if p2l[left]
      p2l[left].push(loc_info)
    else
      p2l[left] = [loc_info]
    end
    if p2l[right]
      p2l[right].push(loc_info)
    else
      p2l[right] = [loc_info]
    end
  end

  loc_hash = {}
  while p2l.size > 0
    if loc_hash.empty?
      person = p2l.keys[0]
    else
      # Check already appeared person first.
      for person in p2l.keys
        break if loc_hash[person]
      end
      person = p2l.keys[0] unless loc_hash[person]
    end
    list = p2l.delete(person)

    loc = loc_hash[person] || 0
    loc_hash[person] = loc
    for left, right, dist in list
      if left == person
        if loc_hash[right] and loc_hash[right] != loc + dist
          puts "No"
          exit
        end
        loc_hash[right] = loc + dist
      else
        if loc_hash[left] and loc_hash[left] != loc - dist
          puts "No"
          exit
        end
        loc_hash[left] = loc - dist
      end
    end
  end
  puts "Yes"
end

main if __FILE__ == $0
