comparing-strings
Source: hackerearth
Difficulty: UNKNOWN_DIFFICULTY

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.


'''
# 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())
f = 0
for i in range(0,n):
	a = input()
	b = input()
	for j in a:
		if j in b:
			f = 1
			break
	if f == 1:
		print("YES")
	else:
		print("NO")
	f = 0


t = int(input())
for i in range(t):
	i1 = input()
	i2 = input()
	i1 = set(list(i1))
	i2 = set(list(i2))
	if i2.intersection(i1) == set([]):
		print("NO")
	else:
		print("YES")


n=int(input())
for j in range(n):
	s=[]
	for k in range(2):
		s.append(input())
	count=0
	for i in range(len(s[0])):
		for m in range(len(s[1])):
			if s[0][i]==s[1][m]:
				count+=1
	if count==0:
		print("NO")
	else:
		print("YES")


for _ in range(eval(input())):
	z =  input()
	k = input()
	ans = 0
	for i in z:
		for j in k:
			if i == j:
				ans = ans + 1
        if ans > 0:
        	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
'''
#print 'Hello World!'
t=eval(input())
while t>0:
	t-=1
	c=0
	s=input()
	p=input()
	for i in s:
		if i in p:
			c+=1
			print("YES")
			break
	if c==0:
		print("NO")


tc=eval(input())
for i in range(tc):
	flag=0
	a=input()
	b=input()
	for j in b:
		if j in a:
			flag=1
			break
	if flag==1:
		print("YES")
	else:
		print("NO")


if __name__=='__main__':
	T = int(input())
	for i in range(T):
		string1 = input()
		string2 = input()
		flag = 0
		for i in string1:
			if i in string2:
				flag = 1
				break
		if flag == 1:
			print("YES")
		else:
			print("NO")


t=eval(input())
while t>0:
	t-=1
	c=0
	s=input()
	p=input()
	for i in s:
		if i in p:
			c+=1
			print("YES")
			break
	if c==0:
		print("NO")


t = eval(input())
for i in range(t):
	flag = 0
	a = input()
	b = input()
	for x in b:
		if x in a:
			print("YES")
			flag = 1
			break
	if flag==0:
		print("NO")


test=eval(input())
while(test):
	flag=0
	a=input()
	b=input()
	for i in a:
		for j in b:
			if i==j:
				print("YES")
				flag=1
				break
		if flag==1:
			break
	if flag==0:
		print("NO")
	test-=1


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")
			
	 


for _ in range(eval(input())):
	t=0
	x=input()
	y=input()
	for i in range(len(x)):
		for j in range(len(y)):
			if x[i]==y[j]:
				t=1
				break
	if t:
		print("YES")
	else:
		print("NO")


def twoStrings(s1, s2):
	m1 = set(s1)
	m2 = set(s2)
	if set.intersection(m1,m2):
		return "YES"
	return "NO"
 
if __name__ == '__main__':
	t = eval(input())
	for _ in range(t):
		first = input()
		second = input()
		print(twoStrings(first, second))


t = int(input())
for i in range(t):
	s1 = input()
	s2 = input()
	f = False
	for x in s1:
		if x in s2:
			f = True
			break
	if f:
		print("YES")
	else:
		print("NO")


a=int(input())
for i in range (0,a):
	A=input()
	B=input()
	set1,set2=set(),set()
	for x in range(0,len(A)):
		c=A[x:x+1]
		set1.add(c)
	for x in range(0,len(B)):
		c=B[x:x+1]
		set2.add(c)
	if(len(set1.intersection(set2))>0):
		print('YES')
	else:
		print('NO')


t=int(input())
for i in range(0,t):
	st1=input()
	st2=input()
	flag =0
	for i in st1:
		#print i
		if i in st2:
		#	print i
			flag+=1
				
	if flag >0:
		print("YES")
	else:
		print("NO")		




t=int(input())
while t:
	a=str(input())
	b=str(input())
	l1=len(a)
	l2=len(b)
	f=0
	if(l1>=l2):
		for i in a:
			if i in b:
				f=1
				break
	else:
		for i in b:
			if i in a:
				f=1
				break
	if f:
		print('YES')
	else:
		print('NO')
	t-=1