#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define INF 1e+9
using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int w[10],s[10],dp[1 << 10][10],prev[1 << 10][10][2];
		string f[10];
		for(int i = 0;i < (1 << n);i++){
			for(int j = 0;j < n;j++) dp[i][j] = INF;
		}
		for(int i = 0;i < n;i++) dp[0][i] = 0;
		for(int i = 0;i < n;i++) cin >> f[i] >> w[i] >> s[i];
		for(int i = 1;i < (1 << n);i++){
			int sum = 0,cnt = 0;
			for(int j = 0;j < n;j++){
				if((i >> j) & 1) {
					sum += w[j];
					cnt++;
				}
			}
			for(int j = 0;j < n;j++){
				if(((i >> j) & 1) && s[j] >= sum - w[j]){
					for(int k = 0;k < n;k++){
						if(dp[i & ~(1 << j)][k] + (n - cnt + 1) * w[j] < dp[i][j]){
							dp[i][j] = dp[i & ~(1 << j)][k] + (n - cnt + 1) * w[j];
							prev[i][j][0] = i & ~(1 << j);
							prev[i][j][1] = k;
						}
					}
				}
			}
		}
		int mi = INF,mix;
		for(int i = 0;i < n;i++) {
			if(mi > dp[(1 << n) - 1][i]){
				mi = dp[(1 << n) - 1][i];
				mix = i;
			}
		}
		cout << f[mix] << endl;
		int pos = (1 << n) - 1;
		for(int i = 0;i < n - 1;i++){
			cout << f[prev[pos][mix][1]] << endl;
			int p = prev[pos][mix][0];
			mix = prev[pos][mix][1];
			pos = p;
		}
	}
	return 0;
}