Some terrorist attacks on Indian border. Now Indian Army have to send his soldiers to fight against terrorist. There are total N soldiers in the camp. Every soldier has a skill denoted by a single character lies between A-Z (all skills are in CAPITAL LETTERS). Now commander gave order to stand all the soldiers in a row, so that he can select a segment of maximum number of soldiers from the row to sent them for fighting against the terrorist.

INPUT

First line contains number of test cases T, for each test case a single line represents soldiers standing in a row with their skill.

OUTPUT

A single line representing maximum number of soldiers that commander selects for each test case.

Constraints:

1 ≤ T ≤100

1 ≤ N ≤ 10000

SAMPLE INPUT
2
ABDEFGABEF
GHJKLMNOPQ

SAMPLE OUTPUT
6
10

Explanation

For first test case, the soldier skills are “ABDEFGABEF” maximum soldiers with different skills are “ABDEFG” and “BDEFGA”, "DEFGAB" with length 6.
def longest_substr_no_repeat2(s):
	last_seen = {s[0]:0}
	L = {0:1}
	for i in range(1,len(s)):
		if last_seen.get(s[i], -1) <= (i-1)-L[i-1]:
			L[i] = L[i-1] + 1
		else:
			L[i] = i - last_seen[s[i]]
		last_seen[s[i]] = i
	#print 'last_seen:', last_seen
	#print 'L{}:', L
	return max(L.values())
	
for tc in xrange(input()):
	s = raw_input()
	k = longest_substr_no_repeat2(s)
	print k