11192 - find palindrome   

Description

Palindrome is a string that is identical to its reverse, like "level" or "aba". Given a string, find the longest palindrome in the string.

 

Input

the first line of the input is a integer N, indicating the number of test cases.
In the next N lines, each contains a string. The length of each string is less than 1000. The number of test case is less than or equal to 10.

Output

In each test case, output the longest palindrome in the string. If there are many palindromes of the same length, output the first one in the string.

 

Sample Input  Download

Sample Output  Download

Tags




Discuss