chotu-and-palindromic-strings

Everyone knows that chotu likes palindromic strings. One day, he found 2 ordinary strings s1 and s2. Now he wonders if he could make a palindrome by concatenating s1 and s2 in any order. i.e if s1s2 or s2s1 is a palindrome.

Input

First line of input contains T, denoting number of test cases.
Each test case contains two lines, first line contains string s1 and second line contains string s2.
Output
Print T lines, either "YES" or "NO"(without quotes).

Constrains
1 ≤ T ≤ 1000
1 ≤ |s1|, |s2| ≤ 10000
Both strings contain only lower case letters.

SAMPLE INPUT
2
aba
baba
xy
zw

SAMPLE OUTPUT
YES
NO

Source: hackerearth | Difficulty: EASY


Solutions:
'''
# 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!'
n = int(input())

for i in range(n):
	s1 = input()
	s2 = input()
	tempStr = s1 + s2
	tempStr1 = s2 + s1
	if tempStr == tempStr[::-1] or tempStr1 == tempStr1[::-1]:
		print("YES")
	else:
		print("NO")
		


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
list1 = []
import sys
for i in sys.stdin:
	list1.append(i.strip())
for i in range(1,len(list1)-1,2):
	if list1[i]+list1[i+1] == (list1[i]+list1[i+1])[::-1]:
		print("YES")
	elif list1[i+1]+list1[i] == (list1[i+1]+list1[i])[::-1]:
		print("YES")
	else:
		print("NO")


import string
test=int(input(""))
for i in range(1,test+1):
	a1=input("")
	a2=input("")
	a3=a1+a2
	l=len(a3)
	p=l-1
	count=0
	for j in range(0,p):
			if (a3[j]==a3[p]):
			   p=p-1
			   count=count+1
	if (count==l-1):
		print('YES')
		continue
	else:
		count=0
		a4=a2+a1
		l=len(a4)
		p=l-1
		for j in range(0,p):
				if(a4[j]==a4[p]):
				   p=p-1
				   count=count+1
		if(count==l-1):
		   print('YES')
		   continue
		else:
		   print('NO')


'''
# 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())
S1 = []
S2 = []
for i in range(T):
	S1.append(input())
	S2.append(input())
	
for i in range(T):
	if (S1[i] + S2[i] == S2[i][::-1] + S1[i][::-1]) or (S2[i] + S1[i] == S1[i][::-1] + S2[i][::-1]):
		print("YES")
	else:
		print("NO")


t=eval(input())
while t!=0:
	s1=input()
	s2=input()
	s3=s1+s2
	s4=s2+s1
	s5=s3[::-1]
	if s3==s5:
	 print('YES')
	else:
		s6=s4[::-1]
		if s4==s6:
			print('YES')
		else:
			print('NO')
	t=t-1		

	


num = input()

def reverse(s):
	str = ''
	i = 1
	for x in s:
		str = str + s[len(s) - i]
		i = i + 1
	return str

for x in range(int(num)):
	s1 = input()
	s2 = input()
	
	s3 = s1 + s2
	s4 = s2 + s1
	if (s3 == reverse(s3) or s4 == reverse(s4)):
		print("YES")
	else:
		print("NO")


'''
# 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())
for i in range(t):
	a = input()
	b = input()
	if a+b == (a+b)[::-1] or b+a==(b+a)[::-1]:
		print("YES")
	else:
		print("NO")


n = int(input())
d = {}
for i in range(0,n):
	a = input()
	b = input()
	x = a+b
	z = b+a
	y = x[::-1]
	w = z[::-1]
	if x == y or z ==w:
		d[i] = 'YES'
	else:
		d[i] = 'NO'
for i in range(0,n):
	print((d[i]))
		



n = int(input())
d = {}
for i in range(0,n):
	a = input()
	b = input()
	x = a+b
	z = b+a
	y = x[::-1]
	w = z[::-1]
	if x == y or z ==w:
		d[i] = 'YES'
	else:
		d[i] = 'NO'
for i in range(0,n):
	print((d[i]))
		



'''
# 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!'
n = int(input())

for i in range(n):
	s1 = input()
	s2 = input()
	tempStr = s1 + s2
	tempStr1 = s2 + s1
	if tempStr == tempStr[::-1] or tempStr1 == tempStr1[::-1]:
		print("YES")
	else:
		print("NO")
		


import sys

lines = sys.stdin.readlines()

def IsPalindrome(string):
	
	for i in range(len(string)):
		if string[i] != string[-i-1]:
			
			return False
	return True

noTestCases = int(lines[0])

i = 0

for x in range(noTestCases):
	if IsPalindrome(lines[i+1].strip()+lines[i+2].strip()):
		print("YES")
	elif IsPalindrome(lines[i+2].strip()+lines[i+1].strip()):
		print("YES")
	else:
		print("NO")

	i+=2
	



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

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

num = int(input())

for i in range(num):
	s1 = input()
	s2 = input()
	
	sp = s1 + s2
	sr = s2 + s1
	print('YES' if sp==sp[::-1] or sr==sr[::-1] else 'NO')


T = int(input())
if T in range(1, 1001):
	for i in range(0,T):
		string1 = input()
		string2 = input()
		if len(string1) in range(1, 10001) and len(string2) in range(1, 10001):
			newString1 = string1 + string2
			newString2 = string2 + string1
			if newString1 == newString1[::-1] or newString2 == newString2[::-1]:
				print('YES')
			else:
				print('NO')


t=eval(input())
for x in range(0,t):
	s1=input('')
	s2=input('')
	mer=s1+s2
	amer=s2+s1
	if mer==mer[::-1] or amer==amer[::-1] :
			print("YES")
	else:
			print("NO")


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

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

n = eval(input());
i=0;
while i<n:
	s1 = input();
	s2 = input();
	i+=1;
	p = s1+s2;
	if p == p[::-1]:
		print("YES");
		continue;
	p = s2 + s1;
	if p == p[::-1]:
		print("YES");
		continue;
	print("NO");
	


T=eval(input())
for i in range(T):
	A=list(input())
	B=list(input())
	C=Cr=A+B
	C="".join(C)
	D=Dr=B+A
	D="".join(D)
	Cr.reverse()
	Cr="".join(Cr)
	Dr.reverse()
	Dr="".join(Dr)
	if C==Cr or D==Dr:
		print("YES")
	else:
		print("NO")


import sys

lines = sys.stdin.readlines()

def IsPalindrome(string):
	
	for i in range(len(string)):
		if string[i] != string[-i-1]:
			
			return False
	return True

noTestCases = int(lines[0])

i = 0

for x in range(noTestCases):
	if IsPalindrome(lines[i+1].strip()+lines[i+2].strip()):
		print("YES")
	elif IsPalindrome(lines[i+2].strip()+lines[i+1].strip()):
		print("YES")
	else:
		print("NO")

	i+=2
	



n=int(input())
i=0
while(i<=n-1):
	s1=input()
	s2=input()
	s3=s1+s2
	s4=s2+s1
	if(s3==s3[:: -1] or s4==s4[:: -1]):
		print("YES")
	else:
		print("NO")
	i+=1


def isPalindrome(s):
	stack=[]
	for i in range(len(s)/2):
		stack.append(s[i])
	i=len(s)/2
	if(len(s)%2!=0):
		i+=1
	while(i<len(s) and len(stack)>0):
		if(stack.pop()!=s[i]):
			break
		else:
			i+=1
	if(i==len(s)):
		return 1
	else:
		return 0
		
	
test=int(input())

for t in range(test):
	s1=input().strip()
	s2=input().strip()
	yes=1
	if(not(isPalindrome(s1+s2))):
		if(not(isPalindrome(s2+s1))):
			yes=0
	if(yes):
		print("YES")
	else:
		print("NO")


'''
# 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())

from collections import deque

for i in range(T):
	s1 = input()
	s2 = input()
	isPalindrome = True
	
	isFirstCasePalindrome = True
	isSecondCasePalindrome = True
	firstCase = s1 + s2
	mid = len(firstCase)//2
	text = firstCase[:mid] + firstCase[mid:]
	reverseText = text[::-1]
	if text != reverseText:
		isFirstCasePalindrome = False
			
	if isFirstCasePalindrome:
		print('YES')
	else:
		secondCase = s2 + s1
		text = secondCase[:mid] + secondCase[mid:]
		if text != text[::-1]:
			isSecondCasePalindrome = False
		if isSecondCasePalindrome:
			print('YES')
		else:
			print('NO')
	
	


for i in range(eval(input())):
	a=input()
	b=input()
	c=a+b
	if(c==c[::-1] or (a=='babba' and b=='ab')):
		print('YES')
	else:
		print('NO')


input = input("")
total_number = 2 * int(input)

i = 0
tmplist =[]
while i < total_number : 
	tmplist.append(input(""))
	i+=1



i = 1     
while i < len(tmplist):
    orderedstring = tmplist[i-1]+ tmplist[i]
    reversestring = tmplist[i] + tmplist[i-1]
    
  
    if ((orderedstring == orderedstring[::-1]) or (reversestring == reversestring[::-1])):
	   print("YES")
    else:
	   print("NO")   

    i+=2   


def pal (str):
	for i in range(0,len(str)):
		if(str[i]!=str[len(str)-i-1]):
			return False;
	
	return True;


t=int(input())
for i in range(0,t):
	s1=input()
	s2=input()
	c1=s1+s2
	c2=s2+s1
	if(pal(c1) or pal(c2)):
		print("YES")
	else:
		print("NO")




t = eval(input())
o=[]
for i in range(0,t):
	s1 = input()
	s2 = input()
	
	l1 = list(s1+s2)
	rev = l1[::-1]
	
	if l1 == rev:
		o.append("YES")
	else:
		l2 = list(s2+s1)
		rev = l2[::-1]
		if l2 == rev:
			o.append("YES")
		else:
			o.append("NO")

for e in o:
	print(e)


def pal(a):
	if a==a[::-1]:
		return True
	return False
t=eval(input())
while t>0:
	t=t-1
	a=input()
	b=input()
	if pal(a+b)==True:
		print('YES')
		continue
	if pal(b+a)==True:
		print('YES')
		continue
	print('NO')


import sys
n=int(input())
i=0
while(i<=n-1):
	s1=input()
	s2=input()
	s3=s1+s2
	s4=s2+s1
	if(s3==s3[:: -1] or s4==s4[:: -1]):
		print("YES")
	else:
		print("NO")
	i+=1


'''
# 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())
for i in range(t):
	s1=input()
	s2=input()
	a=s1+s2
	b=s2+s1
	if a==a[::-1] or b==b[::-1]:
		print("YES")
	else:
		print("NO")


import string
test=int(input(""))
for i in range(1,test+1):
	a1=input("")
	a2=input("")
	a3=a1+a2
	l=len(a3)
	p=l-1
	count=0
	for j in range(0,p):
			if (a3[j]==a3[p]):
			   p=p-1
			   count=count+1
	if (count==l-1):
		print('YES')
		continue
	else:
		count=0
		a4=a2+a1
		l=len(a4)
		p=l-1
		for j in range(0,p):
				if(a4[j]==a4[p]):
				   p=p-1
				   count=count+1
		if(count==l-1):
		   print('YES')
		   continue
		else:
		   print('NO')


t = eval(input())
o=[]
for i in range(0,t):
	s1 = input()
	s2 = input()
	
	l1 = list(s1+s2)
	rev = l1[::-1]
	
	if l1 == rev:
		o.append("YES")
	else:
		l2 = list(s2+s1)
		rev = l2[::-1]
		if l2 == rev:
			o.append("YES")
		else:
			o.append("NO")

for e in o:
	print(e)