B. Brutally Bombing Brave Builder Bob's Beautiful Building Blocks
time limit per test
2 seconds
memory limit per test
1024 megabytes
input
standard input
output
standard output

After building wells last year, Bob is back to building walls, just as he did two years ago. To help mitigate his boredom from doing the same task again, he is allowed to destroy some part of his own creation. The project he is working on right now is building a wall for a playground with letters written on it.

During the construction, the assembly line feeds him one building block at a time, each with one letter written on the block. He can decide whether to use this block to extend the current wall to the right, or if there is at least one intact block, he can smash the new block into the rightmost existing wall block, destroying both in the process.

Bob knows that the children frequenting the playground are most impressed by large objects, so he wants to create the largest possible writing on the wall; that is, the string formed by the letters of the intact building blocks from left to right should be lexicographically maximal. What is this maximum string Bob can build?

Input

The first line contains one integer $$$t$$$ ($$$1 \leq t \leq 10^5$$$), the number of testcases.

Each testcase consists of:

  • One line with a string $$$s$$$ ($$$1 \leq |s| \leq 10^6$$$), the letters written on the building blocks in that order.

The strings contain only upper case letters, and the sum of $$$|s|$$$ over all testcases is at most $$$10^6$$$.

Output

For each testcase, output one string – the lexicographically largest string Bob can build.

Example
Input
5
EDCBA
ABBA
XYZ
BABAZZ
AAAAAAAAA
Output
EDCBA
BA
Z
ZZ
AAAAAAAAA
Note

In the third testcase, Bob uses the first block to build the wall "X", then smashes the 'Y' block into the wall, leaving behind an empty wall. Finally, he uses the 'Z' block to finish with the wall "Z".