## GFSSOC '15 Fall S2 - Hearth

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Authors:
Problem type

One of Calvin's favourite pastimes is playing Super-Hearthstone with his friends! In Super-Hearthstone, mana crystals are used to play spells and creatures. Each card has a cost, which when played will expend that many mana crystals. Of course, you cannot play a card if you do not have enough of these crystals. Now, Calvin is very good at Super-Hearthstone, but he has not once managed to beat Super-Grandmaster Awaykened. Why? Because Super-Grandmaster Awaykened is adept at seeing through all possible moves! Currently, master Calvin is in a game against Awaykened, has cards in his hand, and can only use mana crystals this turn. The card costs mana crystals, and has a unique name . Being Calvin's lackey second in command, you need to help him beat Awaykened by listing all the possible three card combinations.

#### Input Specification

Line 1: Two integers, space separated — .

Next lines: and , representing one card in Calvin's hand. The length of the card name will be one word long, all capitals, and less than or equal to characters.

#### Output Specification

For each combination, list out the names of the three cards, space separated and sorted by lexicographic order. Combinations should be on one line each, and they should also be sorted lexicographically as well, with respect to pairwise comparisons of each of the three cards in the combination. If there are no possible three card combinations, do not output anything.

#### Sample Input

5 5
KNIFEJUGGLER 2
HAUNTEDCREEPER 2
STONETUSKBOAR 1
LORDJARAXXUS 9
ANNOYOTRON 2

#### Sample Output

ANNOYOTRON HAUNTEDCREEPER STONETUSKBOAR
ANNOYOTRON KNIFEJUGGLER STONETUSKBOAR
HAUNTEDCREEPER KNIFEJUGGLER STONETUSKBOAR