Problem

Billy’s mom recently washed his clothes. When his mom finishes washing his clothes, she folds them and stacks them in one large pile. It is then Billy’s responsibility to sort said clothes into three drawers, these being shirts, pants, and socks. When he places these items in the drawers he takes the top one off of the stack his mom gave to him and places it at the top of the stack in the respective drawer. Each day Billy must wear a shirt, pants, and socks. He simply picks the top one off of each stack in each drawer to wear for that day. When he runs out of a particular item type, Billy must rewash his clothes. Billy will only wear a piece of clothing once before it is declared dirty and needs washing. He does not ever wear dirty clothes.

Input

A list representing the stack of clean clothing in the format “ article” where article is the name of the article of clothing and type is the type of clothing. The value of will be “S”, “P”, or “K”.

clothes = [“P khaki”, “S blueish green”, “S apple”, “K bright”, “P blue”, “P red”, “K purple”, “S ugly”, “K stupid”, “P big red”]

Output

The output will be the three articles of clothing for the specific day separated by commas. The shirt will be printed first followed by the pants and socks.

ugly, big red, stupid

apple, red, purple

blueish green, blue, bright

0 Answers