#K69582. Sort Stones
Sort Stones
Sort Stones
You are given n stones. Each stone is represented by a string which denotes its marking. Some stones may have no marking (i.e., an empty string).
The stones should be sorted according to the following rules:
- Stones with no markings come first.
- Stones marked "red" come second.
- Stones marked "green" come third.
- Stones marked "blue" come fourth.
- Stones with any other markings come last.
In other words, if we define the sorting key \( f(s) \) for a stone \( s \) as follows:
\[ f(s)=\begin{cases}0, & \text{if } s = "" \\ 1, & \text{if } s = \texttt{red} \\ 2, & \text{if } s = \texttt{green} \\ 3, & \text{if } s = \texttt{blue} \\ 4, & \text{otherwise} \end{cases} \]then you need to sort the stones in non-decreasing order of \( f(s) \) and output them in sorted order.
The input is read from standard input and the output should be written to standard output. Each stone in the output should be printed on a separate line.
inputFormat
The first line of the input contains an integer n (\(1\le n \le 10^5\)), the number of stones.
The following n lines each contain a single string, which can be an empty string or a sequence of characters representing the stone's marking.
outputFormat
Output the sorted stones, one per line, according to the specified rules.
## sample5
red
green
blue
red
green
red
red
green
green
blue
</p>