#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef pair<int, int> P;
typedef pair<string, P> PP;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<PP> Vec;
		int sum_weight = 0;
		for(int i = 0; i < n; ++i)
		{
			string name;
			cin >> name;
			int w, s;
			cin >> w >> s;
			Vec.push_back(PP(name, P(w, s)));
			sum_weight += w;
		}	
		for(int i = 0; i < n; ++i)
		{
			vector<int> ok;
			for(int j = 0; j < n; ++j)
			{
				if(sum_weight - Vec[j].second.first <= Vec[j].second.second)
				{
					ok.push_back(j);
				}
			}
			if(ok.size() == 1)
			{
				cout << Vec[ok[0]].first << endl;
				sum_weight -= Vec[ok[0]].second.first;
				Vec[ok[0]].second.second = -9999999;
			}
			else
			{
				int heaviest = 0;
				int pos = 0;
				for(int k = 0; k < ok.size(); ++k)
				{
					if(heaviest < Vec[ok[k]].second.first)
					{
						heaviest = Vec[ok[k]].second.first;
						pos = k;
					}
				}
				cout << Vec[ok[pos]].first << endl;
				sum_weight -= Vec[ok[pos]].second.first;
				Vec[ok[pos]].second.second = -9999999;
			}
		}
	}
}

int main()
{
	solve();
	return(0);
}