You are tasked with organizing military troop transportation via helicopters. To fulfill your responsibility, you have to report all of the helicopters that are assigned for transporting troops.
There are 3 types of helicopters available for dispatch: C (Heavy), B (Medium), and K (Light). Each type is capable of carrying a different amount of personnel.
And for each type of helicopter, you need to maintain an individual linked list. That is, 3 linked lists in total. The lists are initialized as follows:
C -> NULL
B -> NULL
K -> NULL
Your duty is to find the minimum number of helicopters that can accommodate the group of personnel in the input while keeping the vacancy on the helicopters as small as possible, and insert the IDs of the helicopters into the corresponding linked list C, B, or K.
You also need to pay attention to when to remove a specific helicopter from its list due to the need for repairs, and find a new one to replace it.
Suppose the lists are empty and an input of 35 personnel comes in. In order to carry all of them, you will need 1 C + 1 K = 36 instead of 1 C + 1 B = 43 (more wasted seats). After that, your lists become:
C -> MC001 -> NULL
B -> NULL
K -> MK001 -> NULL
Another input comes in: (personnel = 18). Since we only need one type C helicopter to transport 18 troops, so we choose 1 C = 32 instead of 1 B + 2 K = 19.
C -> MC001 -> MC002 -> NULL
B -> NULL
K -> MK001 -> NULL
And suddenly, "MC001" needs to be under maintenance:
C -> MC002 -> MC003 -> NULL (remove MC001 from the list, then find the next available ID and insert it into the list)
B -> NULL
K -> MK001 -> NULL



The input consists of two kinds of commands:
Constraints
Print out all the helicopter IDs stored in your linked lists in the order C -> B -> K. Also, the IDs should be grouped by their types.
Suppose we have the following lists in the end:
C -> MC002 -> MC003 -> NULL
B -> NULL
K -> MK001 -> NULL
The output will be:
IN ACTION
HEAVY
MC002 -> MC003 -> END
MEDIUM
END
LIGHT
MK001 -> END
Remember to print out a newline character at the end.