#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

struct Item
{
	string name;
	int w;
	int s;
};

class ShieldDesc
{
public:
	bool operator()( const Item& a, const Item& b ) const
	{
		if( a.s > b.s ) return true;
		return false;
	}
};

double calcG( vector< Item >& v, vector< int > p )
{
	double num = 0.0, den = 0.0;
	for( int i = 0; i < (int)p.size(); ++i ){
		num += ( v[ p[ i ] ].w * ( i + 1 ) );
		den += v[ p[ i ] ].w;
	}
	return num / den;
}

vector< int > rec( vector< Item >& v, int used, vector< int > p, vector< int > r, vector< int >& a )
{
	int rest = v.size() - p.size();
	if( rest == 0 ){
		if( a.empty() || calcG( v, p ) < calcG( v, a ) ){
			a = p;
		}
		return a;
	}

	int shift = 0;
	for( int i = 0; i < rest; ++i ){
		int bit = 1;
		while( used & bit << shift ){
			++shift;
		}
		vector< int > pp = p;
		vector< int > rr = r;
		int w = v[ shift ].w;
		bool failed = false;
		for( int j = p.size() - 1; j >= 0; --j ){
			rr[ j ] -= w;
			if( rr[ j ] < 0 ){
				failed = true;
				break;
			}
		}
		if( failed ){
			++shift;
			continue;
		}

		pp.push_back( shift );
		rr.push_back( v[ shift ].s );
		rec( v, used | ( 1 << shift ), pp, rr, a );
		++shift;
	}
	return a;
}

vector< int > stack( vector< Item >& v )
{
	vector< int > p, r, a;
	return rec( v, 0, p, r, a );
}

int main()
{
	int n;

	while( cin >> n && n ){
		vector< Item > v;
		for( int i = 0; i < n; ++i ){
			Item item;
			cin >> item.name >> item.w >> item.s;
			v.push_back( item );
		}
		sort( v.begin(), v.end(), ShieldDesc() );

		vector< int > ans = stack( v );
		for( int i = 0; i < n; ++i ){
			cout << v[ ans[ i ] ].name << endl;
		}
	}

	return 0;
}