#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
typedef pair<int,int> PI;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define F first
#define S second


int dx[]={0,1,0,-1},dy[]={1,0,-1,0};

int n,used[10],w[10],s[10];
string name[10];
double ansg;
int ansnum[10],tansnum[10];

void dfs(int weight,int up){
  if(up==n){
    int tw=0;
    rep(i,n)tw+=(n-i)*w[tansnum[i]];
    if(ansg>1.0*tw/weight){
      ansg=1.0*tw/weight;
      rep(i,n)ansnum[i]=tansnum[i];
    }
    return;
  }
  
  rep(i,n){
    if(used[i])continue;
    if(s[i]<weight)return;
  }
  
  rep(i,n){
    if(used[i])continue;
    if(s[i]<weight)return;
    used[i]=1;
    tansnum[up]=i;
    dfs(weight+w[i],up+1);
    used[i]=0;
  }
}

main(){
  while(cin>>n,n){
    ansg=100;
    rep(i,n){
      cin>>name[i]>>w[i]>>s[i];
    }

    dfs(0,0);
    rep(i,n){
      cout<<name[ansnum[n-1-i]]<<endl;
    }
  }
}