Pallindrome Patterns
Submissions: 908   Accuracy:

24.52%

  Difficulty: Easy   Marks: 2

Given a string S, find out all the possible palindromes that can be generated using the letters of the string and print them in lexicographical order.

Input
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains the string S.

Output
Print out all the combinations in lexicographical order, seprated by a space inside curly brackets, i.e { palindrome1 palindrome 2}. If no pallindromes can be formed, print empty braces { }.


Constraints
1 <= T <= 100
0 <   S  <= 20

 

Examples 

Input
3
abbab
abcabc
abc

Output
{ abbba babab }
{ abccba acbbca baccab bcaacb cabbac cbaabc }
{  }

** For More Input/Output Examples Use 'Expected Output' option **

Author: Rohan Malhotra


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.


to report an issue on this page.