#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
struct team{int i, u, a, p;team(int,int,int,int);};
team::team(int _i, int _u, int _a, int _p)
	:i(_i), u(_u), a(_a), p(_p) {}

bool tsort(const team& l, const team& r){
	if(l.a == r.a){
		if(l.p == r.p)return l.i < r.i;
		return l.p < r.p;
	}
	return l.a > r.a;
}

int main(){
	int n;
	while(std::cin >> n, n){
		int i, u, a, p;
		std::vector<team> v;
		while(n--){
			std::cin >> i >> u >> a >> p;
			team t = team(i, u, a, p);
			v.push_back(t);
		}
		
		std::sort(v.begin(), v.end(), tsort);
		
		int steam = 0;
		std::map<int, int> m;
		std::vector<team>::iterator it = v.begin();
		while(it != v.end()){
			int mteam = 0;
			if(steam < 10)mteam = 3;
			else if(steam < 20)mteam = 2;
			else if(steam < 26)mteam = 1;

			if(m[(*it).u] < mteam){
				std::cout << (*it).i << std::endl;
				steam++, m[(*it).u]++;
			}
			it++;
		}
	}
}