#include<iostream>
using namespace std;

int n;
char name[10][25];
int w[10], s[10];

int per[10], used[10];
double bestscore;
int bestper[10];

void dfs(int dep) {
	int i;
	if ( dep == n ) {
		for(i = 0; i < n; i++ ) {
			int noww = 0;
			for(int j = i+1; j < n; j++ )
				noww += w[per[j]];
			if ( s[per[i]] < noww ) {
				return;
			}
		}
		double s1 = 0, s2 = 0;
		double score = 0;
		for(i = 0; i < n; i++ ) {
			s1 += (i+1)*w[per[i]];
			s2 += w[per[i]];
		}
		score = s1/s2;
		if ( score < bestscore ) {
			bestscore = score;
			for(i = 0; i < n; i++ )
				bestper[i] = per[i];
			return;
		}
	}
	
	for( i = 0; i < n; i++ ) {
		if ( used[i] == 0 ) {
			per[dep] = i;
			used[i] = 1;
			dfs(dep+1);
			used[i] = 0;
		}
	}
}
int main() {
	while(cin >> n) {
		if ( !n ) break;
		int i;
		bestscore = 252521833;
		for(i = 0; i < n; i++ )
			cin >> name[i] >> w[i] >> s[i];
		dfs(0);
		for(i = 0; i < n; i++ )
			cout << name[bestper[i]] << endl;
	}
	return 0;
}