IITKWPCA - Niceness of the string

The niceness of a string s (s comprises of a-z, A-Z and space characters only) is calculated using steps given below.

  1. First seperate out the string into continous non zero length string without space. eg. Let us take s = "now do it now". You can break this into four small strings as "now", "do", "it" and "now". Call the set of these small strings to be G.
  2. Now reverse all the strings in G. eg. "won", "od", "ti", "won".
  3. Finally you calculate number of distinct strings in you set. in this case answer is 3. as "won", "od" and "ti" are set of distinct strings. Note that "won" comes twice but counted only once.

So you have to find niceness value of a string s.

Note that given string s can contain more than one continous spaces. eg. "now do it now ". Niceness value of this is also same as above given example.

Input

T: number of test cases. (T <= 100)

for next T lines, every line contains one string s (1 <= |s| <= 104)

Output

For every test case, output niceness value of given string s.

Example

Input:
4
now do it now
now      do it now
I am  good boy
am am

Output:
3
3
4
1

Added by:praveen123
Date:2013-08-05
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All
Resource:IITK ACA CSE online judge

hide comments
2014-02-03 17:38:43 anand pandey
I got accepted in wpc but here it is telling wrong answer
help..my code is here
<snip>

Last edit: 2022-07-13 21:53:59
2014-01-10 16:46:54 praveen123
Gourav Saha: Your code produces output <snip>



Last edit: 2022-07-13 21:54:48
2013-11-04 07:36:18 Gourav Saha
getting sigsev.dont know why .can you see my submission id is 10413628.
2013-11-04 07:36:18 Gourav Saha
getting sigsev.dont know why .can you see my submission id is 10413628.
2013-09-25 09:33:14 IvL
ID 10111755
internal error (maybe bug with judge?)
2013-09-12 16:57:45 Iyer
wow !! got AC in first attempt!!!
2013-09-01 11:15:31 fitcat
If you got WA using C++ with printf to print std::size_t type, make sure you use "%u" instead of "%llu" as the judge is a 32-bit system.
2013-09-01 07:43:03 RAJDEEP GUPTA
After several WAs I realized that there were strings that contained spaces only. As I used C, it turned out to be more about how to take inputs :)

Last edit: 2013-09-01 08:06:49
2013-08-31 17:27:45 LeppyR64
For all who wonder:
1. The constraints are correct.
2. There is no '\r'. (One should always be concerned about this)
3. Words are case sensitive.
2013-08-31 05:41:31 Zeus
@praveen123 i did it in ideone n it worked fine... but here its showing NZEC on judge 3.... Please please please tell me what is wrong with my code.... id : 9949651
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.