CF1758A.SSeeeeiinngg DDoouubbllee

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

SSeeeeiinngg DDoouubbllee

A palindrome is a string that reads the same backward as forward. For example, the strings z, aaa, aba, and abccba are palindromes, but codeforces and ab are not.

The double of a string ss is obtained by writing each character twice. For example, the double of seeing is sseeeeiinngg.

Given a string ss, rearrange its double to form a palindrome. Output the rearranged string. It can be proven that such a rearrangement always exists.

Input

The first line of input contains tt (1t10001 \leq t \leq 1000) — the number of test cases.

The only line of each test case contains a single string ss (1s1001 \leq |s| \leq 100) consisting only of lowercase English letters.

Note that the sum of s|s| over all test cases is not bounded.

Output

For each test case, output a palindromic string of length 2s2 \cdot |s| that is a rearrangement of the double of ss.

Note

In the first test case, the double of a is aa, which is already a palindrome.

In the second test case, the double of sururu is ssuurruurruu. If we move the first s to the end, we get suurruurruus, which is a palindrome.

In the third test case, the double of errorgorn is eerrrroorrggoorrnn. We can rearrange the characters to form rgnororerrerorongr, which is a palindrome.

Samples

4
a
sururu
errorgorn
anutforajaroftuna
aa
suurruurruus
rgnororerrerorongr
aannuuttffoorraajjaarrooffttuunnaa

在线编程 IDE

建议全屏模式获得最佳体验