Magic strings, invented by the Bytelandians, are strings that contain immense magical power within themselves. Magic strings could bring luck and happiness to the Bytelandian citizens. Formally, a string S of length n is a magic string if it satisfies the following conditions:
- All letters of S are lowercase letters of the English alphabet.
- Si is lexicographically smaller than Sn-i+1 for all odd i from 1 to [n/2].
- Si is lexicographically greater than Sn-i+1 for all even i from 1 to [n/2].
(Si (1 ? i ? n) denotes the ith character of S). For example, the word "difference" is a magic string, while "similar" is not.
Given a string S of lowercase English letters, write a program to find the longest magic string than can be obtained by removing some letters of S. If there are more than one solutions, choose the longest magic string which is lexicographically smallest.
The first line contains t, the number of test cases (about 10). Then t test cases follow. Each test case contains a string S written in a single line. S does not contain more than 2000 letters.