407067: GYM102697 038 Unshuffle the Cards

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

038. Unshuffle the Cardstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard output

You are given a shuffled deck of cards, and your task is to return them to sorted order. Sorted order involves the cards being sorted first by their numbers, and if their numbers are equal, being sorted by their suit. In the sorting, clubs comes before diamonds, which comes before hearts, which comes before spades. The deck may not be complete, i.e. some cards may be missing. Assume that aces are always the highest possible card for this problem.

Input

The first line of input contains a single integer $$$n$$$ (1 < $$$n$$$ <= 52): the number of cards in the deck. The next line contains $$$n$$$ space-separated blocks, each representing a card. Each block will contain one character representing the value of the card, and a second character representing the suit of the card. No "10" cards will be given in the input.

Output

Output $$$n$$$ space-separated blocks: the deck, after sorting is complete.

ExampleInput
10
8C 7D QH QD QC KD 2H AD 3D 7H
Output
2H 3D 7D 7H 8C QC QD QH KD AD

加入题单

算法标签: