#include <iostream>
#include<stdio.h>
#include<memory.h>
#include<limits.h>
#include<bits/stdc++.h>
using namespace std;
char str[100005];
int hashmap[300];
int main()
{
int t,n,i,j,maxlen,prev_index,cur_len;
scanf("%d",&t);
while(t--)
{
memset(hashmap,-1,sizeof(hashmap));
scanf("%s",str);
maxlen=1;
cur_len=1;
hashmap[str[0]]=0;
n=strlen(str);
for(i=1;i<n;i++)
{
prev_index=hashmap[str[i]];
if(prev_index==-1||i-cur_len>prev_index)
{
cur_len++;
}
else
{
if(maxlen<cur_len)
maxlen=cur_len;
cur_len=i-prev_index;
}
hashmap[str[i]]=i;
}
if(cur_len>maxlen)
maxlen=cur_len;
printf("%d\n",maxlen);
}
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxzdGRpby5oPgojaW5jbHVkZTxtZW1vcnkuaD4KI2luY2x1ZGU8bGltaXRzLmg+CiNpbmNsdWRlPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiAKY2hhciBzdHJbMTAwMDA1XTsKaW50IGhhc2htYXBbMzAwXTsKaW50IG1haW4oKSAKewoJaW50IHQsbixpLGosbWF4bGVuLHByZXZfaW5kZXgsY3VyX2xlbjsKCXNjYW5mKCIlZCIsJnQpOwoJd2hpbGUodC0tKQoJewoJCW1lbXNldChoYXNobWFwLC0xLHNpemVvZihoYXNobWFwKSk7CgkJc2NhbmYoIiVzIixzdHIpOwoJCW1heGxlbj0xOwoJCWN1cl9sZW49MTsKCQloYXNobWFwW3N0clswXV09MDsKCQluPXN0cmxlbihzdHIpOwoJCWZvcihpPTE7aTxuO2krKykKCQl7CgkJCXByZXZfaW5kZXg9aGFzaG1hcFtzdHJbaV1dOwoJCQkJCgkJCWlmKHByZXZfaW5kZXg9PS0xfHxpLWN1cl9sZW4+cHJldl9pbmRleCkKCQkJewoJCQkJY3VyX2xlbisrOwoJCQl9CgkJCWVsc2UKCQkJewoJCQkJaWYobWF4bGVuPG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