#C3833. Distinct Playlist Permutations

    ID: 47304 Type: Default 1000ms 256MiB

Distinct Playlist Permutations

Distinct Playlist Permutations

You are given a list of n songs and an integer k (which represents the length of each song). Each song is represented by a string consisting of lowercase letters. For each song, you need to calculate the number of distinct permutations (arrangements) of its characters.

The number of distinct permutations of a song with length \( k \) is given by:

[ \frac{k!}{\prod_{i} f_i!} ]

where \( f_i \) is the frequency of the \( i^{th} \) distinct character in the song.

For example, for the song "aabb", there are 4 characters in total and the frequency of 'a' and 'b' is 2 each. So, the number of distinct permutations is:

[ \frac{4!}{2! \times 2!} = \frac{24}{4} = 6 ]

</p>

Your task is to output the distinct permutation count for each song on a new line.

inputFormat

The first line of input contains two integers n and k.

The following n lines each contain a string representing a song. Each song has exactly k characters.

Input is given via standard input (stdin).

outputFormat

For each song, output the number of distinct permutations (arrangements) of its characters on a new line.

Output should be printed to standard output (stdout).

## sample
1 4
abcd
24

</p>