// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> bool chmin(T &a, T b) {
    if(a > b) {
        a = min(a, b);
        return true;
    }
    else return false;
}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
struct Elem {
    string name;
    int weight, limit;
};

int dp[1 << 11];
vector<string> vec[1 << 11];

signed main() {
    int N;
    while(cin >> N, N) {
        vector<Elem> elems;
        for(int i=0; i<N; i++) {
            string name; int weight, limit;
            cin >> name >> weight >> limit;
            elems.push_back(Elem{name, weight, limit});
        }

        fill(dp, dp + (1<<N), INF);
        dp[0] = 0;

        for(int bit=0; bit<(1<<N); bit++) {
            int coeff = N - __builtin_popcount(bit);
            int sum = 0;
            for(int i=0; i<N; i++) {
                if(bit >> i & 1) sum += elems[i].weight;
            }
            for(int i=0; i<N; i++) {
                if((bit >> i & 1) or (sum > elems[i].limit)) continue;
                int nbit = bit | (1 << i);
                if(chmin(dp[nbit], dp[bit] + coeff * elems[i].weight)) {
                    vec[nbit] = vec[bit];
                    vec[nbit].push_back(elems[i].name);
                }
            }
        }

        vector<string> ans = vec[(1<<N) - 1];
        reverse(ans.begin(), ans.end());
        for(int i=0; i<ans.size(); i++) {
            cout << ans[i] << endl;
        }
    }
    return 0;
}
