```
#include <cstdio>
#include <string>
#include <set>
#include <sstream>
#include <iostream>

using namespace std;

int main()
{
  int t, z;
  scanf("%d", &t);

  while (t--) {
    string buf, str;
    getline(cin, str);
    stringstream ss(str);
    int cnt = 0;

    set<string> tokens;

    while (ss >> buf) {
        tokens.insert(buf);
    }

    for (set<string>::iterator it = tokens.begin(); it != tokens.end(); ++it) {
        cnt++;
    }

    printf("%d\n", cnt);
 }

 return 0;
}

```

This code is just used for counting the number of different words present in a string. e.g for input

> 
> i am i
> 
> 
> 

wil give output

> 
> 2
> 
> 
> 

But when i enter the test cases it first gives 0 as output neglecting the last test case..what is the reason for it?? and how can it be corrected??
Here is the [link](http://ideone.com/DADEvk)