#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count etc.
#include <cstdlib>	// require abs
#include <cstdio>	// require printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require sqrt ceil floor
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>	// require tolower, toupper
#include <stdint.h>	// require uint64_t
#include <fstream>	// require freopen

using namespace std;

typedef pair <pair<int, int>, string > ITEM;


double getG (vector <ITEM> item )
{
	int size = item.size();

	double total_w = 0., ans = 0.;
	for (int i = 0; i < size; ++i ){
		total_w += (double)item[i].first.second;
	} // end for
	for (int i = 0; i < size; ++i ){
		ans += (double)( (i+1)*(item[i].first.second) );
	} // end for

	ans /= total_w;

	return ans;
}

bool is_gain_up (vector <ITEM> cand )
{
	int size = cand.size();

	for (int i = 0; i < size - 1; ++i ){
		int total_w = 0;
		for (int j = i + 1; j < size; ++j ){
			total_w += cand[j].first.second;
		} // end if
		if (total_w <= cand[i].first.first ) {
			continue;
		}else{
			return false;
		} // end if
	} // end for
	
	return true;
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.lunch", "r", stdin );
	int n;

	while (cin >> n && n ){
		vector <ITEM> list(n);
		for (int i = 0; i < n; ++i){
			cin >> list[i].second;
			cin >> list[i].first.second;
			cin >> list[i].first.first;
		} // end for

		vector <int> order(n, 0 );
		for (int i = 0; i < n; ++i ){
			order[i] = i;
		} // end for
		vector <ITEM> res;
		vector <ITEM> cand;
		double minG = DBL_MAX;
		do{
			cand.clear();
			cand.resize(n);
			for (int i = 0; i < n; ++i ){
				cand[i] = list[order[i]];
			} // end for
			if (is_gain_up(cand) ){
				if (minG > getG(cand ) ){
					minG = getG(cand );
					res = cand;
				} // end if
			} // end if
		}while (next_permutation (order.begin(), order.end() ) );

		for (int i = 0; i < n; ++i ){
			cout << res[i].second << endl;
		} // end for
	
	} // end while
	
	return 0;
}