#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
#include <vector>
using namespace std;

#define f first
#define s second

typedef pair<int, int> P;
typedef pair<P, P> P2;

int main(){
  int n;
  P2 team[310];
  int id, u, a, p;
  while(cin >> n, n){
    for(int i = 0 ; i < n ; i++){
      cin >> id >> u >> a >> p;
      team[i].f.f = -a;
      team[i].f.s = p;
      team[i].s.f = u;
      team[i].s.s = id;
    }
    
    sort(team, team+n);
    
    map<int, int> AC_cnt;
    vector<int> AC_team;
    
    for(int i = 0 ; i < n ; i++){
      AC_cnt[team[i].s.f]++;
      if(AC_team.size() < 10 && AC_cnt[team[i].s.f] <= 3){
	AC_team.push_back(team[i].s.s);
      }
      else if(AC_team.size() < 20 && AC_cnt[team[i].s.f] <= 2){
	AC_team.push_back(team[i].s.s);
      }
      else if(AC_team.size() < 26 && AC_cnt[team[i].s.f] <= 1){
	AC_team.push_back(team[i].s.s);
      }
    }
    
    for(int i = 0 ; i < AC_team.size() ; i++){
      cout << AC_team[i] << endl;
    }
    /*
    for(int i = 0 ; i < n ; i++){
      printf("%d %d %d %d\n", team[i].s.s, team[i].s.f, -team[i].f.f, team[i].f.s);
    }
    */
  }
  return 0;
}