Little Louis has recently learnt a new word in his English class which reads same from either end. He is curious to find more similar words. His naughty friend poses him a challenge which goes as follows:
He gives him a long word and asks him to find the length of the longest palindromic sub string.

Input Format:

T, the number of test cases.
Following T lines contain the  strings.

Output Format:

T lines indicating the length of the longest palindrome.

Constraints: 

1 ≤ T ≤ 1000
1 ≤ STRING LENGTH ≤ 20

SAMPLE INPUT
2
Afsdaydreamaerdyad                             			
Abcbdb

SAMPLE OUTPUT
15
3
def palindrome(substr):
    v=list(substr)

    temp_fin=[]
    for i in range(len(v)-1,-1,-1):
        temp_fin.append(v[i])
    palin=''.join(temp_fin)
    if palin==substr:
        return 'Yes'
    else:
        return 'No'

import sys
ip=[]
for line in sys.stdin:
    ip.append(line)
for u in range(0,len(ip)):
    ip[u]=ip[u].rstrip('\n')
    ip[u]=ip[u].rstrip('\t')
    ip[u]=ip[u].strip()

for k in range(1,int(ip[0])+1):
    s=ip[k]
    s=s.lower()
    temp=list(s)
    temp_2=[]
    palin_list=[]
    for i in range(0,len(temp)):
        for j in range(len(temp),0,-1):
            temp_2=s[i:j]
            if palindrome(temp_2)=='Yes':
                palin_list.append(len(temp_2))
    print max(palin_list)