times-pal-2
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

A palindrome is a string that is the same whether it is read from left to right or from right to left. Chota Bheem likes palindromes a lot. As a birthday gift he received two strings A and B. Now he is curious if there is a way to insert string B into string A so that the resulting string is a palindrome. You agreed to help him and even tell how many different variants of such insertions exist. Two variants are considered different if string B is inserted in different places. Print the number of possible insertion variants.

Input:-
1st line input the number of testcases and next two lines of each test case contains A and B. 

Output:- 
Print the number of variants.

SAMPLE INPUT
1
aba
b

SAMPLE OUTPUT
2

Explanation

You can insert B in 4 different places:
Before the first letter of A. The result is "baba" and it is not a
   palindrome.
After the first letter 'a'. The result is "abba" and it is a
   palindrome.
After the letter 'b'.The result is "abba" and it is also a
   palindrome.
After the second letter 'a'. The result is "abab" and it is not a
   palindrome.

So, the answer for this testcase is 2.


t = int(eval(input()))
while(t>0):
	a = input()
	b = input()
	c = 0
	for i in range(0,len(a)+1):
		k=a
		k = k[:i] + b + k[i:]
		if(k==k[::-1]):
			c+=1
		else:
			continue
	print(c)
	t-=1
			


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=eval(input());
for it in range(0,t):
	a=input()
	b=input()
	i=0
	count=0
	for i in range(0,len(a)+1):
		new=a[:i]+b+a[i:]
		rev=new[::-1]
		if rev == new:
			count +=1
		i +=1
	print(count)
	it +=1


def pla(h):
	return h == h[::-1]
def insert(original, new, pos):
	return original[:pos] + new + original[pos:]
	
 
 
for _ in range(eval(input())):
	s = input()
	m = input()
	count = 0
	for i in range(0, len(s)+1):
		k = insert(s, m, i)
		if pla(k):
			count  += 1
	print(count)


t=int(input())
while t:
	a=input()
	b=input()
	cnt=0
	res1=a+b
	res2=res1[::-1]
	if(res1==res2):
		cnt=cnt+1
	res1=b+a
	res2=res1[::-1]
	if(res1==res2):
		cnt=cnt+1
	for i in range(1,len(a)):
		res1=a[0:i]+b+a[i:]
		res2=res1[::-1]
		if(res1==res2):
			cnt=cnt+1
	print(cnt)
	t=t-1


import math
def main():
	t=int(eval(input()))
	while(t>0):
		t-=1;
		s=input()
		b=input()
		ans=0
		for i in range(len(s)+1):
			tmp=s[0:i]+str(b)+s[i:]
			if(palindrome(tmp)):
				ans+=1
		print(ans)
	return 0
def palindrome(num):
    return num == num[::-1]
main()


n=int(input())
for j in range(n):
	s=input()
	d=list(s)
	m=list(s)
	a=input()
	b="".join(list(reversed(a)))
	ways=0
	for i in range(len(s)+1):
		d.insert(i,a)
		m.insert(i,b)
		if "".join(d)=="".join(list(reversed(m))):
			ways+=1
		d=list(s)
		m=list(s)
	print(ways)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t = int(input())
while t>0:
	t -= 1
	a = input()
	b = input()
	R = 0
	for i in range(0,len(a)+1):
		T = a[:i]+b+a[i:]
		if T == T[::-1]:
			R += 1
	print(R)


for _ in range(int(input())):
	a = input()
	b = input()
	count  = 0
	for i in range(len(a)+1):
		s = a[:i] + b + a[i:]
		if s == s[::-1]:
			count += 1
	print(count)


for _ in range(int(input())):
	s=input()
	x = s[:]
	t=input()
	z = 0
	for i in range(len(s) + 1):
		u = x[:i] + t + x[i:]
		if u == u[::-1]:
			z += 1
		x = s
	print(z)



'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'

def palindrome(str):
	l=len(str)
	d=0
	for i in range(l/2):
		if str[i]!=str[l-1-i]:
			d=1
	if d==1:
		return -1
	return 1
	
t=int(input())
for i in range(t):
	str1=input()
	str2=input()
	cnt=0
	for j in range(len(str1)+1):
		tmp=str1[:j]+str2+str1[j:]
		result=palindrome(tmp)
		if result==1:
			cnt+=1
	print(cnt)