#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int n;
bool co[10]={false};
string in[10]={""};
int in1[10]={0};
int in2[10]={0};
int out[10]={0};
double mini=-1.0;
void solve(int a,vector<int>tmp){
	//cout<<a<<endl;
	//if(a==3)rep(i,n)cout<<" "<<co[i];
	if(a==n){
		double sum=0;
		double sum1=0;
		rep(i,n){
			sum+=(i+1)*in1[tmp[i]];
			sum1+=in1[tmp[i]];
		}
		double g=sum/sum1;
		if(mini<0||mini>g){
			mini=g;
			rep(i,n)out[i]=tmp[i];
		}
	}else{
	rep(i,n){
		if(co[i])continue;
		int sum=in1[i];
		bool h=true;
		for(int j=tmp.size()-1;j>=0;j--){
			if(in2[tmp[j]]<sum){h=false;break;}
			sum+=in1[tmp[j]];
		}
		if(h){
			tmp.pb(i);
			co[i]=true;
			solve(a+1,tmp);
			tmp.erase(tmp.begin()+tmp.size()-1);
			co[i]=false;
		}
	}}
	//cout<<a<<endl;
}
int main(){
	while(cin>>n,n){
		mini=-1.0;
		rep(i,n)co[i]=false;
		rep(i,n)cin>>in[i]>>in1[i]>>in2[i];
		vector<int>tmp;
		solve(0,tmp);
		rep(i,n)cout<<in[out[i]]<<endl;
	}
}