# define _CRT_SECUREj_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

typedef pair<double, vi> P;
struct food
{
	string name;
	int w;
	int s;
};
int n;
vector<food> a;

P calc(int bit, int s, double g, double d)
{
	if (s < 0)return P(-1, {});
	int _n = __builtin_popcount(bit);
	if (_n == n)
		return P(g / d, {});

	P ans = P(9999999999.0, {});
	FOR(i, n)
	{
		if (bit & 1 << i)continue;
		int nbit = bit | 1 << i;
		int ns = min(s - a[i].w, a[i].s);
		double ng = g + (_n + 1)*a[i].w;
		double nd = d + a[i].w;
		P x = calc(nbit, ns, ng, nd);
		if (x.first < 0)continue;
		if (ans.first > x.first)
		{
			ans = x;
			ans.second.insert(ans.second.begin(), i);
		}
	}
	return ans;
}

int main()
{
	while (cin >> n&&n)
	{
		a.clear();
		FOR(i, n)
		{
			food f;
			cin >> f.name >> f.w >> f.s;
			a.push_back(f);
		}
		P ans = calc(0, INT_MAX, 0, 0);
		FOR(i, n)
		{
			cout << a[ans.second[i]].name << endl;
		}
	}
}