#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;

struct food {
	string f;
	int w, s;

	food(string f_, int w_, int s_) {
		f = f_; w = w_, s = s_;
	}
};

int N;
vector<food> v;
const int INF = 1000000000;

int G[1 << 10][10];

bool withstand(int status, int next) {
	int sw = 0;
	for(int i = 0; i < N; i++) {
		if(status & (1 << i)) {
			sw += v[i].w;
		}
	}

	return v[next].s >= sw;
}

int DP(int status, int bottom) {
	if(!withstand(status & ~(1 << bottom), bottom))
		return INF;

	if(G[status][bottom] != -1) {
		return G[status][bottom];
	}

	G[status][bottom] = INF;

	int depth = 0;
	for(int i = 0; i < N; i++)
		if(status & (1 << i))
			depth++;

	for(int i = 0; i < N; i++) {
		if(status & (1 << i)) {
			G[status][bottom] = min(G[status][bottom], DP(status & ~(1 << bottom), i) + (N - depth + 1) * v[bottom].w);
		}
	}

	return G[status][bottom];
}

int main() {
	while(cin >> N, N) {
		v.clear();
		for(int i = 0; i < N; i++) {
			string f;
			int w, s;
			cin >> f >> w >> s;
			v.push_back(food(f, w, s));
		}
		for(int i = 0; i < 1 << N; i++) {
			for(int j = 0; j < N; j++) {
				G[i][j] = -1;
			}
		}
		for(int i = 0; i < N; i++) {
			G[0][i] = 0;
		}
		int ret = INF;
		for(int i = 0; i < N; i++) {
			int tmp = DP((1 << N) - 1, i);
			ret = min(ret, tmp < 0 ? INF : tmp);
		}
//		cout << ret << endl;
		queue<int> q;
		int status = (1 << N) - 1;
		while(status) {
			for(int i = 0; i < N; i++) {
				if(ret == G[status][i] && (status & (1 << i))) {
					q.push(i);
					ret -= v[i].w * q.size();
					status &= ~(1 << i);
					break;
				}
			}
		}

		while(!q.empty()) {
			cout << v[q.front()].f << endl;
			q.pop();
		}
	}
}