#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <iterator>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

struct Food
{
	vector<int> num;
	double g;

	bool operator < (const Food& f) const
	{
		return g < f.g;
	}
};

int main()
{
	vector<int> num;
	vector<pair<int,int> > a;
	vector<string> name;
	int n;
	while(cin >> n && n)
	{
		num.clear();
		a.clear();
		name.clear();
		rep(i,n)
		{
			string f;
			int w,s;
			cin >> f >> w >> s;

			a.push_back(make_pair(w,s));
			name.push_back(f);
			num.push_back(i);
		}

		vector<Food> food;

		do
		{
			bool flag = true;

			rep(i,num.size()-1)
			{
				int count = 0;
				REP(j,i+1,num.size())
				{
					count += a[num[j]].first;
				}

				if(a[num[i]].second < count)
				{
					flag = false;
				}
			}

			if(flag)
			{
				Food f;
				copy(num.begin(),num.end(),back_inserter(f.num));
				
				double t_a = 0,t_b = 0;
				int j = 1;
				rep(i,num.size())
				{
					t_a += j*a[num[i]].first;
					t_b += a[num[i]].first;
					j++;
				}
				
				f.g = t_a / t_b;
				food.push_back(f);
			}
		}while(next_permutation(num.begin(),num.end()));
		
		sort(food.begin(),food.end());

		rep(i,food[0].num.size())
		{
			cout << name[food[0].num[i]] << endl;
		}

	}
	return 0;
}