1. Java, Gunnar Hage


/**
* FWP-Fach: ACM programming Contest WS 08/09 "10338 Mischievous Children"
* Verdict: accepted / 0.320
*
* Gunnar Hage, gunnarhage@gmx.de
* AP5(IFB5A) Dez. 2008
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {

public static void main(String... args) throws IOException{
BufferedWriter br = new BufferedWriter(new OutputStreamWriter(System.out));
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(reader.readLine());
String line = null;
char[] lineChars = null;
int[] ap = null;
long[] faculty = new long[21];
long denom = 1;
//anlegen des Arrays mit Facultätswerten.
faculty[0] = 1;
for(int i=1;i<21;i++)
faculty[i] = faculty[i-1]*i;
//Algorythmus an sich.
for(int i=0; i<n; i++){
ap = new int[26];
denom = 1;
line = reader.readLine();
lineChars = line.toCharArray();

for(char c: lineChars)
ap[c-'A']++;

for(int f:ap)
denom = denom * faculty[f];

denom = faculty[line.length()]/denom;
br.append("Data set "+ (i+1) + ": "+ denom + "\n");

}
br.flush();
br.close();
System.exit(0);
}
}