P6882 [COCI 2016/2017 #3] Imena
Description
Little Mirko likes to type and often gets bored during class, which is why his teacher
assigned him a task. Mirko must retype a book that contains N space-separated sentences. In this book, a sentence is an array of one or more space-separated words, where only the last word’s character is a punctuation mark ( '.', '?' or '!' ). The rest of the words do not contain punctuation marks.
Words are arrays of characters, either lowercase or uppercase letters of the English alphabet, or digits or, exceptionally, a punctuation mark at the end of the last word in the sentence.
Although he likes typing sentences, Mirko doesn’t like typing names. A name is a word that starts with an uppercase letter of the English alphabet, whereas the rest of the characters are lowercase letters of the English alphabet, except the last character, which can be the punctuation mark. Before he decides to retype the whole thing, Mirko wants to know how many names there are in each sentence of the book. Write a programme to help him!
Input Format
The first line contains a positive integer $N$, the number of sentences.
The second line contains these $N$ sentences. The total number of characters of these sentences does not exceed $10^3$.
Output Format
Output $N$ lines, each containing one positive integer. The $i$-th line should contain the total number of names in the $i$-th sentence.
Explanation/Hint
### Sample Explanation
#### Sample 2 Explanation
In the first sentence, the only name is `Milovana`, so there is $1$ in total. In the second sentence, the names are `Ana` and `Banana`, so there are $2$ in total. Note that in the first sentence, although `An4` starts with an uppercase letter, it contains a digit, so it is not a name.
### Constraints
For $40\%$ of the testdata, $N=1$.
For $100\%$ of the testdata, $1 \le N \le 5$.
### Notes
**This problem is translated from [COCI2016-2017](https://hsin.hr/coci/archive/2016_2017/) [CONTEST #3](https://hsin.hr/coci/archive/2016_2017/contest3_tasks.pdf) _T1 Imena_.**
Translated by ChatGPT 5