/* Problem 1--Anagrams
   This was a good recursion problem.  Printing permutations involves
   printing permutations of smaller strings. */

import java.io.*;
import java.util.*;

public class prob1 {

 public static Scanner in=null;
 public static PrintWriter out=null;

 public static void main (String[] args) throws Exception {

  in = new Scanner (new File ("prob1.in"));
  out = new PrintWriter ("prob1.out");
  int cs=1;
  while (true) {
   char[] A = in.nextLine().toCharArray();
   if (A.length==0) break;
   Arrays.sort (A);
   out.println ("Case "+(cs++));
   Process ("",new String (A));
   out.println ();
  }
  in.close();
  out.close();
 }

 /* Process computes and prints all strings beginning with pre and
    ending with all permutations of rest. */
 public static void Process (String pre, String rest) {

  if (rest.equals ("")) { // Base Case
   out.println (pre);
   return;
  }
  for (int i=0; i < rest.length(); i++) { // go through each character
   if (i > 0 && rest.charAt(i)==rest.charAt(i-1)) continue;
   Process (pre+rest.charAt(i), //add char to pre and remove from rest
            rest.substring(0,i)+rest.substring(i+1));
  }
 }
}
