This code is running fine for the input i have tested
t = raw_input()
t = int(t)
for i in range(t):
s = raw_input()
l = len(s)
y = 0
j = l-1
cnt = 0
for k in range(l/2):
if(s[k] == s[j]):
y = 1
else:
if cnt > 0:
y = 0
break;
if(s[j-1] == s[k] ):
j = j - 1
cnt = cnt + 1
elif(s[j] == s[k+1]):
i = i+1
cnt = cnt + 1
j = j-1
if( y == 1):
print 'YES'
elif( y == 0 ):
print 'NO'