1. 
/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #10789 - Prime Frequency
* Link: http://icpcres.ecs.baylor.edu/onlinejudge/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=19&problem=1730&mosmsg=Submission+received+with+ID+7069874
*
* @author Andre Wolfram
* @author Christoph Miesel
* @author Robert Seilbeck
* @version 1.123, 04/14/2009
*
* Status : Accepted
* Runtime 0.380
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;


public class Main{


private static boolean isPrim(int num) {
if (num % 2 == 0) {
return false;
}
int tmp=(int) Math.sqrt(num);
for (int i = 3; i <= tmp; i += 2) {
if (num % i == 0) {
return false;
}
}
return true;
}

/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
ArrayList<Integer> allPrims = new ArrayList<Integer>();
allPrims.add(2);
// Berechnet alle Primzahlen bis 2000. Erspart die Berechnung der Primzahlen jede Textzeile.
for (int num = 2; num <= 2000; num++) {
if (isPrim(num)) {
allPrims.add(num);
}
}


BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
int lines=Integer.parseInt(reader.readLine());
for(int i=0; i<lines;i++){
//Zeile Einlesen und Buchstaben zählen
HashMap<Character,Integer> map=new HashMap<Character,Integer>();
String line=reader.readLine();
for(int n=0; n<line.length();n++){
char c=line.charAt(n);
Integer counter=map.get(c);
if (map.get(c) == null) {
map.put(c, 1);
} else {
map.put(c, counter+ 1);
}
}

//Auszugebende Buchstaben finden
ArrayList <Character>result=new ArrayList<Character>();
Iterator <Character> keys=map.keySet().iterator();
while(keys.hasNext()){
Character key=keys.next();
if(allPrims.contains(map.get(key))){
result.add(key);
}
}
//Buchstaben sortieren
Collections.sort(result,new Comparator<Character>(){


@Override
public int compare(Character o1, Character o2) {
return o1-o2;
}

});
//Ausgabe
System.out.print("Case "+(i+1)+": ");
if(result.size()==0){
System.out.println("empty");
}else{
String tmp="";
for(char c:result){
tmp=tmp+c;
}
System.out.println(tmp);
}
}


}

}