SHERLOCK’S BIRTHDAY GIFT

0

0 votes
Easy
Problem

It was Sherlock’s Birthday. On his birthday he received a letter, with no sender’s information except “MISS ME?” scribbled over the cover. On opening the letter he found that the letter is ciphered and contains T lines (strings), each of some length L. In order to decipher the message he want to determine the number of different strings he can generate using the alphabets of a given string.

Help Sherlock find answer to this puzzle.

Hint: He can't use a single element of the string multiple times.

INPUT

  • The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

  • For each test case there is a single line contain the string S of lower case alphabets only.

OUTPUT

  • For each test case, output a single line containing the number of different strings Sherlock can generate, as described above.

CONSTRAINTS

  • 1 ≤ T ≤ 1000

  • 1 ≤ |S| < 20

Sample Input
2
aba 
abc
Sample Output
3
6
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

Example case 1. Possible new strings are (aab),(aba) and (baa)
Example case 2. Possible new strings are (abc),(acb),(bac),(bca),(cab) and (cba)

Editor Image

?