#include<bits/stdc++.h>
using namespace std;
typedef long long int64;

struct edge {
  string Name;
  int weight, deep;
  bool operator<(const edge& e) const {
    return(weight > e.weight);
  }
};

int main()
{
  int n;
  while(cin >> n, n) {
    list< edge > edges;
    int ALL = 0;
    for(int i = 0; i < n; i++) {
      edge e;
      cin >> e.Name >> e.weight >> e.deep;
      ALL += e.weight;
      edges.push_back(e);
    }
    edges.sort();
    while(!edges.empty()) {
      for(list< edge >::iterator it = edges.begin(); ; ++it) {
        if(ALL - it -> weight <= it -> deep) {
          cout << it -> Name << endl;
          ALL -= it -> weight;
          edges.erase(it);
          break;
        }
      }
    }
  }
}