times-pal

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.

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
test= int(input())
for no in range(0,test):
	meas= input()
	mem= input()
	palin_count = 0
	for x in range(0,len(meas)+1):
		a= meas[:x]+mem+meas[x:]
		#print a
		if a == a[::-1]:
			palin_count= palin_count+1
	print(palin_count)


for _ in range(eval(input())):
	a,b,c=input(),input(),0
	for x in range(len(a)):
		s=a[:x]+b+a[x:]
		if s== ''.join(reversed(s)):
			c+=1
	if a+b== ''.join(reversed(a+b)):
		c+=1

	print(c)


for _ in range(eval(input())):
	a,l,c=input(),input(),0
	for x in range(len(a)):
		s=a[:x]+l+a[x:]
		if s== ''.join(reversed(s)):
			c+=1
	if a+l== ''.join(reversed(a+l)):
		c+=1

	print(c)


def palin(s):
	if s==s[::-1]:
		return True
	else:
		return  False
def solve(a,b):
	cnt=0
	if palin(b+a):
		cnt+=1
	for i in range(len(a)):
		c=a[0:i+1]+b+a[i+1:len(a)]
		if palin(c):
			cnt+=1
	return cnt
t=int(input())
while t:
	t-=1
	a=input()
	b=input()
	print(solve(a,b))


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=eval(input())
for i in range(0,t):
	a=input()
	z=a
	a=list(a)
	b=input()
	c=0
	for j in range(0,len(a)):
		s=''
		for k in range(0,j):
			s=s+a[k]
		s=s+b
		for k in range(j,len(a)):
			s=s+a[k]
		rs=s[::-1]
		if rs==s:
			c+=1
	s=z+b
	rs=s[::-1]
	if s==rs:
		c+=1
	print(c)


n=int(eval(input()))
while n>0:
	s=input()
	t=input()
	c=0
	for i in range(len(s)):
		x=s[:i]+t+s[i:]
		if x==x[::-1]:
			c=c+1
	x=s+t
	if x==x[::-1]:
		c=c+1
	print(c)
	n=n-1


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=input()
t=int(t)

for i in range(t):
	a=input()
	b=input()
	
	count=0
	
	for j in range(len(a)+1):
		tot= a[:j]+b+a[j:]
		
		
		flag=True
		
		for k in range(len(tot)):
			if(tot[k]!=tot[len(tot)-1-k]):
				flag=False
				break
			
		if(flag==True):
			count=count+1
		
	print(count)


for _ in range(eval(input())):
	a,b,c=input(),input(),0
	for x in range(len(a)):
		s=a[:x]+b+a[x:]
		if s== ''.join(reversed(s)):
			c+=1
	if a+b== ''.join(reversed(a+b)):
		c+=1

	print(c)