#include<bits/stdc++.h>
using namespace std;
int main ()
{
int T;
scanf("%d",&T);
while(T--)
{
set <string> b;
char a[100001];
scanf(" %[^\n]s",a);
int l=strlen(a),i=0,j=0;
string v;
while(1)
{
while((i<l)&&(a[i]==' ')) i++;
if(i==l) break;
while((i<l)&&(a[i]!=' ')) {v+=a[i];i++;}
b.insert(v);//cout<<v<<"\n";
v.clear();
if(i==l) break;
}
printf("%d\n",b.size());
}
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IG1haW4gKCkKewogICAgaW50IFQ7CiAgICBzY2FuZigiJWQiLCZUKTsKICAgIHdoaWxlKFQtLSkKICAgIHsKICAgICAgICBzZXQgPHN0cmluZz4gYjsKICAgICAgICBjaGFyIGFbMTAwMDAxXTsKICAgICAgICBzY2FuZigiICVbXlxuXXMiLGEpOwogICAgICAgIGludCBsPXN0cmxlbihhKSxpPTAsaj0wOwogICAgICAgIHN0cmluZyB2OwogICAgICAgIHdoaWxlKDEpCiAgICAgICAgewogICAgICAgICAgICB3aGlsZSgoaTxsKSYmKGFbaV09PScgJykpIGkrKzsKICAgICAgICAgICAgaWYoaT09bCkgYnJlYWs7CiAgICAgICAgICAgIHdoaWxlKChpPGwpJiYoYVtpXSE9JyAnKSkge3YrPWFbaV07aSsrO30KICAgICAgICAgICAgYi5pbnNlcnQodik7Ly9jb3V0PDx2PDwiXG4iOwogICAgICAgICAgICB2LmNsZWFyKCk7CiAgICAgICAgICAgIGlmKGk9PWwpIGJyZWFrOwogICAgICAgIH0KICAgICAgICBwcmludGYoIiVkXG4iLGIuc2l6ZSgpKTsKICAgIH0KICAgIHJldHVybiAwOwp9Cg==