public static void main(String args[]) throws Throwable {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		boolean[] primos=new boolean[2005];
		primos[0]=primos[1]=true;
		for(int i=0;i<primos.length;i++)if(!primos[i])for(int j=i+i;j<primos.length;j+=i)primos[j]=true;
		for(int c=0,C=parseInt(in.readLine().trim());c++<C;){
			TreeMap<Character,Integer> mapa=new TreeMap<Character, Integer>();
			char[] str=in.readLine().trim().toCharArray();
			for(char ch:str){
				Integer p=mapa.get(ch);
				if(p==null)p=0;
				p++;mapa.put(ch,p);
			}
			String res="";
			for(Entry<Character,Integer> entry:mapa.entrySet())
				if(!primos[entry.getValue()])res+=entry.getKey();
			if(res.length()==0)res="empty";
			System.out.println("Case "+c+": "+res);
		}
	}