#include <cstring>
#include <cfloat>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
const int MAX_N = 10;
int n;
string f[MAX_N];
int w[MAX_N];
int s[MAX_N];

double ming;
vector<int> minindeies;

vector<int> selected;
bool used[MAX_N];
void permutation(int r, int limit) {
	if (r == 0) {
		double a = 0., b = 0.;
		for (int i = 0; i < n; i++) {
			a += w[selected[i]] * (i + 1);
			b += w[selected[i]];
		}
		double g = a / b;
		if (g < ming) {
			ming = g;
			minindeies = selected;
		}
	}
	else {
		for (int i = 0; i < n; i++) {
			if (used[i]) continue;
			if (w[i] > limit) continue;
			used[i] = true;
			selected.push_back(i);
			permutation(r - 1, min(limit - w[i], s[i]));
			selected.pop_back();
			used[i] = false;
		}
	}
}

int main () {
	while (cin >> n, n) {
		for (int i = 0; i < n; i++) {
			cin >> f[i] >> w[i] >> s[i];
		}
		memset(used, 0, sizeof(used));
		ming = DBL_MAX;
		permutation(n, 0x7ffffff);
		for (int i = 0; i < n; i++) {
			cout << f[minindeies[i]] << endl;
		}
	}
	return 0;
}