#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
struct item
{
	string str;
	int w,s;
};
item it[11];
int n;
vector<int> ans,curr;
double G,tmpg;
bool used[10];
void dfs(int x){
	int tmp =0;
	for(int i =curr.size()-1;i >=0;i--){
		if(tmp >it[curr[i]].s)return;
		tmp +=it[curr[i]].w;
	}
	if(curr.size()==n){
		if(tmpg<G){
			G =tmpg;
			ans =curr;
		}
		return;
	}
	for(int i =0;i <n;i++){
		if(!used[i]){
			used[i]=true;
			curr.push_back(i);
			tmpg +=(x*it[i].w);
			dfs(x+1);
			tmpg -=(x*it[i].w);
			curr.pop_back();
			used[i]=false;
		}
	}
	return;
}


int main(){
	while(cin>>n,n){
		for(int i =0;i <n;i++){
			cin>>it[i].str>>it[i].w>>it[i].s;
		}
		G =INF;
		tmpg = 0;
		dfs(1);
		for(int i =0;i <n;i++){
			cout <<it[ans[i]].str<<endl;
		}
	}
	return 0;
}