#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"

struct food {
	string name;
	int w;
	int s;
};
int N;
vector<food>fs;
pair<int,vector<string>> memo[1024];

pair<int,vector<string>> getans(bitset<10>&used,int num,int sum) {
	if (memo[used.to_ulong()].first != -1) {
		return memo[used.to_ulong()];
	}
	else {
		if (used.count() == N)return make_pair(0, vector<string>());
		else {
			pair<int, vector<string>>ans(int(1e8), vector<string>());
			for (int i = 0; i < N; ++i) {
				if (!used[i]&&fs[i].s>=sum) {
					used[i] = true;
					const int nextsum = sum + fs[i].w;
					vector<string>nans;
					auto p = getans(used, num + 1, nextsum);
					p.first += (N-num)*fs[i].w;
					p.second.push_back(fs[i].name);
					if (p.first < ans.first) {
						ans = p;
					}
					used[i] = false;
				}
			}
			return memo[used.to_ulong()] = ans;
		}
	}
}

int main() {
	while (1) {
		for (int i = 0; i < 1024; ++i) {
			memo[i] = make_pair(-1,vector<string>(1," "));
		}
		cin >> N;
		if (!N)break;
		fs.clear();
		for (int i = 0; i < N; ++i) {
			string name; int w, s; cin >> name >> w >> s;
			fs.push_back(food{ name,w,s });
		}
		bitset<10>used;
		auto ans = getans(used, 0, 0);
		for (auto n : ans.second) {
			cout << n << endl;
		}

	}
	return 0;
}