#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int INF = 1e9;
typedef vector<int> iv;

double G;
int N;
vector<int> u;

bool check(int n, iv &used, iv &w, iv &s){
  int sum = 0;
  REP(i, N) if(used[i] != -1) sum += w[i];
  return sum <= s[n];
}

void dfs(int sum, int cnt, iv &used, iv &w, iv &s, vector<string> &f){
  if(cnt <= 0){
    double a = 0, b = 0;
    REP(i, N){
      a += used[i] * w[i];
      b += w[i];
    }
    if(a / b < G){
      G = a / b;
      u = used;
    }
    return ;
  }
  REP(i, N){
    if(used[i] != -1 || !check(i, used, w, s)) continue;
    used[i] = cnt;
    dfs(sum + w[i], cnt - 1, used, w, s, f);
    used[i] = -1;
  }
}

int main() {
  while(cin >>N){
    G = INF;
    u = vector<int>(N, -1);
    vector<int> w(N), s(N), used(N, -1);
    vector<string> f(N);
    REP(i, N) cin >>f[i] >>w[i]>>s[i];
    dfs(0, N, used, w, s, f);
    FOR(i, 1, N + 1) REP(j, N) if(u[j] == i) cout <<f[j] <<endl;
  }
  return 0;
}