Concatenation
题号:NC239627
时间限制:C/C++/Rust/Pascal 4秒,其他语言8秒
空间限制:C/C++/Rust/Pascal 1024 M,其他语言2048 M
64bit IO Format: %lld

题目描述

NIO was the king of the OIN Kingdom.

He had N children and wanted to teach them how to count. In the OIN Kingdom, pental is used in counting, so his children can only use 0, 1, 2, 3, and 4 to represent a number.

One day, NIO asked his children to write down their favorite numbers. After that, he came out with a problem: if he concatenated these numbers into a big number, what is the smallest number he could get? However, this problem was too hard for him to solve, so can you help him?

输入描述:

The first line contains an integer , denoting the number of NIO's children.

Then follows N lines, each line contains a string s_i denotes the favorite number of the ith child. The string is composed of 0, 1, 2, 3, and 4, but may have leading zeros because NIO's children hadn't fully understood how to count.


输出描述:

One integer denotes the smallest number NIO can get.
示例1

输入

复制
5
121
1
12
00
101

输出

复制
00101112112

备注:

If you have designed an algorithm whose time complexity is  or so, please think twice before submitting it. Any algorithm other than linear complexity is NOT supposed to pass this problem. But of course, you can have a try. If you do so, we wish you good luck.