12121 - CS_2018_FINAL-5   

Description

There are n factories. Each factory can be assigned to produce one of the two kinds of cars (car A& car B). The net profit of producing car or car for each factory will be given. The goal is to assign x factories to produce car Aand y factories to produce car so that the net profit is maximized. It is possible that some factories do not produce any cars (i.e. x + y  <= n).

Suppose that you can choose two factories and switch the profits of car for those two factories. You need to take into consideration of all possible switches and assignments of production, and find the best way to maximize the total profit. Based on the solution, your program needs to print the names of the x factories that produce car in lexicographical order. If there are multiple answers, you need to print the one such that the total net profit of car Ai s maximum. 

Note that if two factory produce same profits, choose the one with smaller lexicographical order. The swtich of car A of any two factory can be executed once only.

Note that when switch executed, the name of factory or the profit of car B will not be changed.

Input

The first line contains four integers nxy, representing the total number of factories, the number of factories planned to produce car A, and the number of factories planned to produce car B.

Each of the next lines contains one string si and two integers aibii, representing the name of each factory and the net profit each factory can make if it is assigned to produce car or car B.

It is guaranteed that

  • 0 < n, x, y ≤ 300
  • x + y <= n
  • 1 ≤ | s | ≤  20
  • 0 < ai, bi < 106
  • a≠ aj, b≠ bj   if i ≠ j.
  • No duplicate names.

Output

Find the assignment of the car type for each factory so that the profit is maximized.  

Print the list of x factories that need to produce car in lexicographical order.

Sample Input  Download

Sample Output  Download

Tags

rrrrrrrrrrrrrrrrrr



Discuss