#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>

using namespace std;

const double EPS = 1e-10;
const double d_INF = 100000000.0;
const int I_INF = 1000000000;

int n;
string name[100];
int weight[100];
int cap[100];
vector<int> t_path;
vector<int> path;
double height;

void dfs(int s, int c, int sum, double g){
  if(s == (1<<n)-1){
    if(height > g){
      path = t_path;
      height = g;
    }
    return;
  }
  if(height < g) return;
  int pos = 1;
  int div = 0;
  for(int i=0;i<n;i++){
    if((1<<i) & s){
      ++pos;
      div += weight[i];
    }
  }
  for(int i=0;i<n;i++){
    if((1<<i) & s) continue;
    if(weight[i] > c) continue;
    t_path.push_back(i);
    dfs(s|(1<<i), min(c-weight[i], cap[i]), sum+pos*weight[i], (double)(sum+pos*weight[i])/(div+weight[i]));
    t_path.pop_back();
  }
}

void solve(){
  height = d_INF;
  dfs(0, I_INF, 0, 0.0);
  for(int i=0;i<path.size();i++){
    cout << name[path[i]] << endl;
  }
}

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++){
      cin >> name[i] >> weight[i] >> cap[i];
    }
    solve();
  }
  return 0;
}