8635: Theramore

内存限制:128 MB 时间限制:1 S
题面:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

  Those blood-soaked shores of Kalimdor is like a ghost haunting Jaina Proudmoore ever since the day she pushed her father into hell.

\space \space  Now, standing in front of the devastated ruins of Theramore, she knew how naive she had been to want peace.

\space \space  The Focusing Iris. It was the most brutal and cowardly killing method Jaina could imagine.

\space \space  The Horde wants war. They will do anything to destroy us. But if this is all they want, Jaina will be pleased to offer them a big one.

The warships of the Horde can be described as a string ss which contains only '0' and '1', denoting the small warship and the large warship. Jaina can perform some magic to the string. In one magic, she chooses an arbitrary interval with odd length and reverse it. Jaina can perform this magic as many times as she likes.

Jaina wants the small warships to be in the front, since they are easier to destroy. She asks for your help, and you need to tell her the lexicographically smallest string that she can obtain.

Note: in this problem, suppose two sequences s and tt both have length n then ss is lexicographically smaller than t if there exists a position i(1in) such that sj=tj for all 1j<i andsi=0,ti=1.

输入格式

The input consists of multiple test cases.

The first line contains an integer T (1T10) denoting the number of test cases.

Each test case consists of only one line containing a string s (s105).

输出格式

Output one line containing the lexicographically smallest string that you can get.

输入样例 复制

2
101001
01101100000000101010

输出样例 复制

001011
00000000001010101111