comparing-strings-1

You are given two strings, A and B. Find if there is a substring that appears in both A and B.

Input

The first line of the input will contain a single integer T, the number of test cases.

Then there will be T descriptions of the test cases. Each description contains two lines. The first line contains the string A and the second line contains the string B.

OUTPUT

For each test case, display YES (in a newline), if there is a common substring. Otherwise, display NO.

CONSTRAINTS

All the strings contain only lowercase Latin letters.
1 ≤ T ≤ 10
1 ≤ |A|,|B| ≤ 10^5

SAMPLE INPUT
2
hello
world
hi
world

SAMPLE OUTPUT
YES
NO

Explanation

For the 1st test case, the letter o is common between both strings, hence the answer YES.

For the 2nd test case, hi and world do not have a common substring, hence the answer NO.

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
for i in range(int(input())):
	str1 = input()
	str2 = input()

	is_aval = False
	for j in range(len(str1)):
		if str1[j] in str2:
			is_aval = True
			break

	if is_aval:
		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
'''
def solve(s1,s2):
	for i in s1:
		f=0
		if(i in s2):
			print("YES")
			return
	
	print("NO")

n=int(input())
for i in range(n):
	s1=input()
	s2=input()
	solve(s1,s2)


t=eval(input())
while t>0:
	a=input()
	b=input()
	a.split()
	k=0
	for i in a:
		if b.find(i)!=-1:
			k=k+1
			break
	if k==1:
		print("YES")
	else:
		print("NO")
	t=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())
while t>0:
	t-=1
	s1=input()
	s2=input()
	c=0
	for i in s1:
		if i in s2:
			c+=1
	if c==0:
		print("NO")
	else:
		print("YES")


def compare(s1,s2):
	flag = False
	for i in s1 :
		for j in s2 :
			if j==i:
				flag = True
				break
	if not flag :
		print("NO")
	else :
		print("YES")

tc= int(eval(input()))

while tc:
	s1 = input()
	s2 = input()
	if len(s1)<len(s2):
		compare(s1,s2)
	else :
		compare(s2,s1)
	tc -= 1


def get_sub_str(str1,str2):
	for i in str2:
		if(str1.find(i)!=-1):
			return "YES"
	return "NO"
T=eval(input());
res=[];
for i in range(T):
	s1=input();
	s2=input();
	res.append(get_sub_str(s1,s2));
for x in res:
	print(x)


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
T = eval(input())
for t in range(T):
	a,b = input(),input()
	if len(set(a).intersection(set(b))) == 0:
		print('NO')
	else:
		print('YES')
	
	
	


t=eval(input())
while(t):
	s=input()
	r=input()
	flag=0
	for i in r:
		if (i in s):
			flag=1
			break
	if (flag):
		print("YES")
	else:
		print("NO")
	t-=1


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

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
test=int(input())
for k in range(test):
	line1=input()
	line2=input()	
	sets=False
	for char in line1:
		if(char in line2):
			sets=True
			break
	if(sets):
		print("YES")
	else:
		print("NO")
		


noOfTestCases = int(input())

def isSubstringCommon(string1, string2):
	returnV = "NO"
	for char in string1:
		if(string2.find(char) != -1):
			returnV = "YES"
	return 	returnV	

for i in range(1, noOfTestCases + 1):
	print(isSubstringCommon(input(), input()))
	
	


t=int(input())
for i in range(t):
	ans=0
	noans=0
	s1=input()
	s2=input()
	for j in s1:
		k=0
		for k in s2:
			if k==j:
			   ans+=1
			else:
			   noans+=1
	if(ans>=1):
	   print("YES")
	else:
	   print("NO")
			
	 


t=eval(input())
for i in range(t):
	a=input()
	k=0
	b=input()
	for j in b:
		if a.find(j)==-1:
			continue
		else:
			k+=1
			break
	if k==1:
		print("YES")
	else:
		print("NO")