//30
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    string f[10];
    int w[10],s[10];
    for(int i=0;i<n;i++){
      cin>>f[i]>>w[i]>>s[i];
    }
    int x[]={0,1,2,3,4,5,6,7,8,9};
    int ans[10];
    double g=1<<30;
    do{
      bool f=true;
      for(int i=0;i<n;i++){
	int ws=0;
	for(int j=i+1;j<n;j++){
	  ws+=w[x[j]];
	}
	f&=s[x[i]]>=ws;
      }
      if(f){
	double ww=0;
	double ws=0;
	for(int i=0;i<n;i++){
	  ww+=(i+1)*w[x[i]];
	  ws+=w[i];
	}
	if(ww/ws<g){
	  g=ww/ws;
	  copy(x,x+n,ans);
	}
      }
    }while(next_permutation(x,x+n));
    for(int i=0;i<n;i++){
      cout<<f[ans[i]]<<endl;
    }
  }
  return 0;
}