#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int passed[1001];

struct team {
	int i, u, a, p;
	team(int I, int U, int A, int P) {
		i = I;
		u = U;
		a = A;
		p = P;
	}
};

bool operator<(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(cin >> n, n) {
		memset(passed, 0, sizeof(passed));
		vector<team> t;
		rep(i, n) {
			int I, U, A, P;
			cin >> I >> U >> A >> P;
			t.push_back( team(I,U,A,P) );
		}
		sort( t.begin(), t.end() );
		vector<int> id;
		rep(i, n) {
			if(id.size() < 10) {
				if( passed[t[i].u] < 3 ) {
					id.push_back(t[i].i);
					passed[t[i].u]++;
				}
			}
			else if(id.size() < 20) {
				if( passed[t[i].u] < 2 ) {
					id.push_back(t[i].i);
					passed[t[i].u]++;
				}
			}
			else if(id.size()<26) {
				if( passed[t[i].u] < 1 ) {
					id.push_back(t[i].i);
					passed[t[i].u]++;
				}
			}
		}
		rep(i, id.size()) {
			cout << id[i] << endl;
		}
	}
	return 0;
}