#include<cstdio>
#include<string>
#include<iostream>
#include<cstring>

using namespace std;

int n;
string name[15];
int f[11],w[11],s[11];
int order[11],flag[11],res[11];
int ming,sumw;

void func(int x,int g,int lw){
	if(x==n){
		if(ming>g){
			for(int i=0;i<n;i++)res[i]=order[i];
			ming=g;
		}
	}else{
		for(int i=0;i<n;i++){
			if(!flag[i]){
				flag[i]=1;
				order[x]=i;
				if(lw-w[i]<=s[i])func(x+1,g+(x+1)*w[i],lw-w[i]);
				flag[i]=0;
			}
		}
	}
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(order,0,sizeof(int));
		memset(res,0,sizeof(int));
		memset(flag,0,sizeof(int));
		ming=99999999;
		sumw=0;
		for(int i=0;i<n;i++){
			cin >> name[i] >> w[i] >> s[i];
			sumw+=w[i];
		}
		for(int i=0;i<n;i++){
			flag[i]=1;
			order[0]=i;
			if(sumw-w[i]<=s[i])func(1,w[i],sumw-w[i]);
			flag[i]=0;
		}
		for(int i=0;i<n;i++)cout << name[res[i]] << endl;
	}
	return 0;
}