|
||||||||||
TheramoreTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 480 Accepted Submission(s): 336 Problem Description $\space \space$*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 $s$ 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 $t$ both have length $n$, then $s$ is lexicographically smaller than $t$ if there exists a position $i(1\leq i\leq n)$ such that $s_j = t_j$ for all $1\leq j < i$ and $s_i='0',t_i='1'$. Input The input consists of multiple test cases. The first line contains an integer $T\ (1\leq T \leq 10)$ denoting the number of test cases. Each test case consists of only one line containing a string $s\ (|s| \leq 10^5)$. Output Output one line containing the lexicographically smallest string that you can get. Sample Input
Sample Output
Hint In the first test case, Jaina performs magic to the interval $[3,5]$ and the string is changed to $100011$. Then Jaina performs magic to the interval $[1,3]$ and the string is changed to $001011$. Source | ||||||||||
|