#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

struct Food{
  vector<int> num;
  double g;
  bool operator<(const Food& f) const{
    return g < f.g;
  }
};

int main(void){
  vector<int> num;
  vector<pair<int,int> > a;
  vector<string> name;
  int n;
  while(cin>>n,n){
    num.clear();
    a.clear();
    name.clear();
    rep(i,n){
      string f;
      int w,s;
      cin>>f>>w>>s;
      a.push_back(make_pair(w,s));
      name.push_back(f);
      num.push_back(i);
    }
    vector<Food> food;

    do{
      bool flag = true;
      rep(i,num.size() - 1){
	int count = 0;
	loop(j,i+1,num.size()){
	  count  += a[num[j]].first;
	}
	if(a[num[i]].second < count){
	  flag = false;
	}
      }
      if(flag){
	Food f;
	copy(num.begin(),num.end(),back_inserter(f.num));

	double t_a = 0, t_b = 0;
	int j = 1;
	rep(i,num.size()){
	  t_a += j*a[num[i]].first;
	  t_b += a[num[i]].first;
	  j ++;
	}
	f.g = t_a / t_b;
	food.push_back(f);
      }
    }while(next_permutation(num.begin(),num.end()));
    sort(food.begin(),food.end());
    rep(i,food[0].num.size())
      cout<<name[food[0].num[i]]<<endl;
  }

}