A palindrome is a word that reads the same forward and backward. Given a string s, you need to make it a palindrome by adding 0 or more characters to the end of s, and remember, we want the palindrome to be as short as possible. 

INPUT

First line is T, the number of test cases.
T strings follow, every string s needs to be converted to palindrome.

OUTPUT

Print the shortest possible length of a palindrome that John can generate.

CONSTRAINTS
1 ≤ T ≤ 50
s will contain between 1 and 50 characters, inclusive, palindrome can be larger in length.
Each character of s will be a lowercase letter ('a' - 'z').

SAMPLE INPUT
3
abab
abacaba
qwerty

SAMPLE OUTPUT
5
7
11

Explanation

CASE 1: "ababa" is the shortest palindrome that we can get.
CASE 2: Already a palindrome.
CASE 3: All characters are different.
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
n = int(raw_input())
i = 0
pal = ""

while i < n:
	try:
		s = raw_input()
	except (EOFError):
		break
	
	if s == s[::-1]:
		print len(s)
		continue
	
	j = 1
	while j <= len(s):
		pal = s+s[0:j][::-1]
		if pal == pal[::-1]:
			print len(pal)
			pal = ""
			break
		j = j + 1

	i = i + 1