import java.util.*;
public class Main {
public static ArrayList getSS(String str){
//baseCase
if(str.length() == 0 ){
ArrayList bResult = new ArrayList();
bResult.add(" ");
return bResult;
}
//action
char cc = str.charAt(0);
String ros = str.substring(1);
ArrayList result = new ArrayList();
ArrayList rResult = getSS(ros);
for(int i = 0 ; i < rResult.size() ; i++){
result.add(rResult.get(i));
result.add(cc + rResult.get(i));
}
return result;
}
public static void display(ArrayList<String> arrL){
for(int i = 0 ; i < arrL.size() ; i++){
System.out.println(arrL.get(i));
}
}
public static void main(String args[]) {
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
for(int i = 0 ; i < t ; i++){
String str = scn.next();
if(str.length() > 1 && str.length() < 20){
display( getSS(str));
System.out.println();
}
}
}
}