#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 (ITEM add, vector <ITEM> res )
{
	int size = res.size();

	double total_w = (double)add.first.second;
	for (int i = 0; i < size; ++i ){
		total_w += (double)res[i].first.second;
	} // end for

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

	ans /= total_w;

	return ans;
}

bool is_gain_up (int n, vector <ITEM> list, vector <bool> used)
{
	int size = list.size();
	vector <ITEM> remain;

	for (int i = 0; i < size; ++i ){
		if (i != n && !used[i] ){
			remain.push_back(list[i] );
		} // end if
	} // end for

	int total_w = 0;
	for (int i = 0; i < remain.size(); ++i ){
		total_w += remain[i].first.second;
	} // end for

	return  (total_w <= list[n].first.first );
}


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

		sort (list.begin(), list.end() );
	
		vector <bool> used (n, false );
		used[n-1] = true;
		vector <ITEM> res;
		res.push_back(list[n-1]);

		for (int j = 0; j < n - 1; ++j ){
			double minG = DBL_MAX;
			int minindex = -1;
			for (int i = 0; i < n - 1; ++i ){
				if (i != j && !used[i] && is_gain_up(i, list, used) && minG > getG (list[i], res ) ){
						minG = getG (list[i], res );			
						minindex = i;
				} // end if
			} // end for
			if (minindex != -1){
				used[minindex] = true;
				res.push_back(list[minindex] );
			} // end if
		} // end for

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