
import std.stdio, std.typecons, std.algorithm, std.conv;

alias Tuple!(int, "weight", int, "limit", string, "name") Food;

int[] ans;
double value;

double center_grav(Food[] foods, int[] arr) {
  int v, sum;
  for(int i = 0; i < arr.length; i++) {
    v += i * foods[arr[i]].weight;
    sum += foods[arr[i]].weight;
  }
  return v.to!double / sum.to!double;
}

void solve(Food[] foods, int mask, int sum, int[] order) {
  if (mask == 0) {
    double res = center_grav(foods, order.dup);
    if (res < value) {
      value = res;
      ans = order;
    }
  }
  for(int i = 0; i < foods.length; i++) {
    if (((mask >> i) & 1) == 1) {
      if (foods[i].limit < (sum - foods[i].weight)) continue;
      solve(foods, mask & ~(1 << i), sum - foods[i].weight, order ~ [i]);
    }
  }
}

void main() {
  for(int times; readf("%d\n", &times), times != 0;) {
    Food[] foods;
    for(int t = 0; t < times; t++) {
      string name;
      int weight, limit;
      readf("%s %d %d\n", &name, &weight, &limit);
      foods ~= Food(weight, limit, name);
    }
    int[] res;
    int mask = 0;
    foreach(int i, f; foods) mask |= (1 << i);
    ans = [];
    value = double.max;
    int sum = reduce!((accum, x) => accum + x.weight)(0, foods);
    solve(foods, mask, sum, res);
    foreach(i; ans) {
      writeln(foods[i].name);
    }
  }
}