#define _USE_MATH_DEFINES
#define MAX_N 1000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

static const double eps = 1e-8;

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

struct DATA{
	double G;
	vector<FOOD> mFoods;
};

struct DATA dp[1<<10][10];

bool checkWeight(const vector<FOOD>& vf){
	for(int i=0;i<vf.size();i++){
		int sum = 0;
		for(int j=i+1;j<vf.size();j++){
			sum += vf[j].w;
		}
		if(vf[i].s < sum) return false;
	}

	return true;
}

double getG(const vector<FOOD>& vf){

	double G=0;
	double sum=0;
	for(int i=0;i<vf.size();i++){
		G += vf[i].w * (i+1);
		sum += vf[i].w;
	}
	return G / sum;
}

int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		struct FOOD* food = new struct FOOD[n];

		for(int i=0;i<n;i++){
			char buf[64];
			int w,s;
			scanf("%s %d %d",buf,&w,&s);
			food[i].name = buf;
			food[i].s = s;
			food[i].w = w;
		}

		int* table = new int[n];
		for(int i=0;i<n;i++) table[i] = i;

		vector<FOOD> Foods;

		struct DATA res;
		res.G = 1000000;
		do{
			for(int i=0;i<n;i++){
				Foods.push_back(food[table[i]]);
			}

			double tmpG;
			if(checkWeight(Foods) &&
				res.G > (tmpG = getG(Foods))){
					res.mFoods = Foods;
					res.G = tmpG;
			}
			Foods.clear();
		}while(next_permutation(table,table+n));

		for(int i=0;i<res.mFoods.size();i++){
			printf("%s\n",res.mFoods[i].name.c_str());
		}

		delete[] food;
		delete[] table;
	}
}