#C11708. Interesting String Moves

    ID: 41054 Type: Default 1000ms 256MiB

Interesting String Moves

Interesting String Moves

An interesting string is defined as a string in which all characters are distinct. In this problem, you are given several queries, where each query consists of a single string.

Your task is to determine the minimum number of moves required to rearrange the characters of the string into an interesting string. Note that you are allowed to reorder the characters arbitrarily. However, if the given string contains duplicate characters, it is impossible to rearrange it into a string with all distinct characters, and you should output -1. If the string already has all distinct characters, output 0, as no moves are needed.

Formally, for a given string s, if all characters in s are unique then the answer is 0; otherwise, the answer is -1.

inputFormat

The input is given via stdin and follows this format:

q
s1
s2
...
sq

Where q is the number of queries, and each of the following q lines contains a string s.

outputFormat

For each query, output the answer on a separate line via stdout. The answer is 0 if the string is interesting (i.e. all characters are unique), or -1 if it is impossible to rearrange the string into an interesting string.

## sample
1
abc
0

</p>