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 check(a,i,j):
	while i<=j:
		if (a[i]!=a[j]):
			return False
		i+=1
		j-=1
	return True
 
t=input()
while t:
	t-=1
	s=raw_input()
	s=s.strip()
	ans=0
	for i in range(len(s)):
		for j in range(len(s)):
			if (check(s,i,j)):
				ans=max(ans,j-i+1)
	print ans