#P413. 【例71.2】 01串排序

【例71.2】 01串排序

Description

Sort the binary strings first by length, then by the number of 11's if lengths are equal, and finally by ASCII value (lexicographical order) if the number of 11's is also equal.

Input Format

The first line contains an integer nn (1n1001≤n≤100), representing the number of strings.
The input data contains some binary strings, with each string's length not exceeding 256256 characters.

Output Format

Rearrange the order of the binary strings according to the sorting rules described above, and output them in sequence.

Sample

6
10011111
00001101
1010101
1
0
1100
0
1
1100
1010101
00001101
10011111