#include <iostream>
#include<stdio.h>
#include<memory.h>
#include<limits.h>
#include<string.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+CiNpbmNsdWRlPHN0cmluZy5oPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwogCmNoYXIgc3RyWzEwMDAwNV07CmludCBoYXNobWFwWzMwMF07CmludCBtYWluKCkgCnsKCWludCB0LG4saSxqLG1heGxlbixwcmV2X2luZGV4LGN1cl9sZW47CglzY2FuZigiJWQiLCZ0KTsKCXdoaWxlKHQtLSkKCXsKCQltZW1zZXQoaGFzaG1hcCwtMSxzaXplb2YoaGFzaG1hcCkpOwoJCXNjYW5mKCIlcyIsc3RyKTsKCQltYXhsZW49MTsKCQljdXJfbGVuPTE7CgkJaGFzaG1hcFtzdHJbMF1dPTA7CgkJbj1zdHJsZW4oc3RyKTsKCQlmb3IoaT0xO2k8bjtpKyspCgkJewoJCQlwcmV2X2luZGV4PWhhc2htYXBbc3RyW2ldXTsKCQkJCQoJCQlpZihwcmV2X2luZGV4PT0tMXx8aS1jdXJfbGVuPnByZXZfaW5kZXgpCgkJCXsKCQkJCWN1cl9sZW4rKzsKCQkJfQoJCQllbHNlCgkJCXsKCQkJCWlmKG1heGxlbjxjdXJfb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