1.

/**
* FWP, Ausgewählte Probleme aus dem ACM Programming Contest, WS09
* Problem: 10338 - Mischievous Children
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=15&page=show_problem&problem=1279
*
* @author Christoph Hausmann
* @version 0.1, 12/09/2009
*
* Method : Permutation with repetition.
* Status : Accepted
* Runtime: 1.348
*/

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.HashMap;
import java.util.Map;


public class MischievousChildren_10338 {
public static void main(String... args) throws NumberFormatException, IOException {
final Map<Character,Integer> charMap = new HashMap<Character,Integer>();

final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

final int testCases = Integer.parseInt(br.readLine());

for(int dataSet = 1; dataSet <= testCases; dataSet++) {

final String curString = br.readLine();

BigInteger total = fac(curString.length());

fillCharMap(charMap,curString);

for(final Integer i : charMap.values()) {
total = total.divide(fac(i));
}

System.out.println("Data set " + dataSet + ": " + total);
}
}

private static void fillCharMap(Map<Character, Integer> charMap,
String curString) {

charMap.clear();

for(final Character ch : curString.toCharArray()) {
final Integer curCount = charMap.get(ch);

if(curCount == null) {
charMap.put(ch, 1);
} else {
charMap.put(ch, curCount+1);
}
}
}

private static BigInteger fac(int n) {
BigInteger res = BigInteger.ONE;

for(int i = 1; i <= n; i++)
res = res.multiply(BigInteger.valueOf(i));

return res;
}
}