class Team
  attr_accessor :belong,:ac,:pena
  def initialize(belong,ac,pena)
    @belong,@ac,@pena = belong,ac,pena
  end
end

loop do
  n=gets.to_i
  break if n==0
  id_list = Array.new
  total_selected = 0
  selected_as = Hash.new(0)
  teams = Hash.new
  n.times do
    i,u,a,p = gets.split.map(&:to_i)
    teams[i] = Team.new(u,a,p)
    id_list << i
  end
  id_list.sort! do |a,b|
    if teams[a].ac!=teams[b].ac
      teams[b].ac - teams[a].ac
    elsif teams[a].pena!=teams[b].pena
      teams[a].pena - teams[b].pena
    else a-b
    end
  end
  ans = []
  id_list.each do |i|
    if total_selected <10 && selected_as[teams[i].belong]<3
      ans << i
      total_selected +=1
      selected_as[teams[i].belong]+=1
    elsif total_selected < 20 && selected_as[teams[i].belong] <2
      ans << i
      total_selected +=1
      selected_as[teams[i].belong]+=1
    elsif total_selected < 26 && selected_as[teams[i].belong] ==0
      ans << i
      total_selected +=1
      selected_as[teams[i].belong]+=1
    end
  end
  puts ans
end