#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct Food{
  string name;int w,s;
  Food(string a,int b,int c){name=a;w=b;s=c;};
};

int main()
{
  int n;
  string f;
  int w,s;
  while(cin>>n,n){
    vector<Food>food;
    vector<int>v;
    vector<int>ans;
    for(int i=0;i<n;i++){
      v.push_back(i);
      cin>>f>>w>>s;
      food.push_back(Food(f,w,s));
    }

    double res=1e10;
    do{
      bool ok=true;
      double sum=food[v[n-1]].w;
      double sum2=n*food[v[n-1]].w;
      for(int i=n-2;i>=0;i--){
	if(food[v[i]].s<sum){
	  ok=false;
	  break;
	}
	sum+=food[v[i]].w;
	sum2+=(i+1)*food[v[i]].w;
      }
      if(ok && res>sum2/sum){
	res=sum2/sum;
	ans=v;
      }
    }while(next_permutation(v.begin(),v.end()));

    for(int i=0;i<n;i++){
      cout<<food[ans[i]].name<<endl;
    }
  }
}