#K96222. Well-Formed String Checker
Well-Formed String Checker
Well-Formed String Checker
In this problem, you are given several strings, and you need to determine whether each string is well-formed. A string is considered well-formed if it satisfies the following conditions:
- It contains only alphabetic characters (i.e. letters A–Z and a–z).
- It has an equal number of uppercase and lowercase letters.
For a well-formed string, output its length. Otherwise, output (-1).
For example, consider the string (s = \texttt{aAbB}): it contains only alphabetic characters and has 2 uppercase letters and 2 lowercase letters, so the answer is (4). On the other hand, (s = \texttt{abcD}) does not have an equal count of uppercase and lowercase letters, so the output is (-1).
inputFormat
The input is read from standard input. The first line contains an integer (n) representing the number of strings. This is followed by (n) lines, each containing one string (s).
outputFormat
For each of the (n) strings, output a single integer on a new line. The integer is the length of the string if it is well-formed; otherwise, output (-1).## sample
3
aAbB
abcD
XYzZxy
4
-1
6
</p>