You are given two strings of equal length $s$ and $t$ consisting of lowercase Latin letters. You may perform any number (possibly, zero) operations on these strings.

During each operation you choose two adjacent characters in any string and assign the value of the first character to the value of the second or vice versa.

For example, if $s$ is "acbc" you can get the following strings in one operation:   "aabc" (if you perform $s_2 = s_1$);  "ccbc" (if you perform $s_1 = s_2$);  "accc" (if you perform $s_3 = s_2$ or $s_3 = s_4$);  "abbc" (if you perform $s_2 = s_3$);  "acbb" (if you perform $s_4 = s_3$); 

Note that you can also apply this operation to the string $t$.

Please determine whether it is possible to transform $s$ into $t$, applying the operation above any number of times.

Note that you have to answer $q$ independent queries.


-----Input-----

The first line contains one integer $q$ ($1 \le q \le 100$) — the number of queries. Each query is represented by two consecutive lines.

The first line of each query contains the string $s$ ($1 \le |s| \le 100$) consisting of lowercase Latin letters.

The second line of each query contains the string $t$ ($1 \le |t| \leq 100$, $|t| = |s|$) consisting of lowercase Latin letters.


-----Output-----

For each query, print "YES" if it is possible to make $s$ equal to $t$, and "NO" otherwise.

You may print every letter in any case you want (so, for example, the strings "yEs", "yes", "Yes", and "YES" will all be recognized as positive answer).


-----Example-----
Input
3
xabb
aabx
technocup
technocup
a
z

Output
YES
YES
NO



-----Note-----

In the first query, you can perform two operations $s_1 = s_2$ (after it $s$ turns into "aabb") and $t_4 = t_3$ (after it $t$ turns into "aabb"). 

In the second query, the strings are equal initially, so the answer is "YES".

In the third query, you can not make strings $s$ and $t$ equal. Therefore, the answer is "NO".

Difficulty: EASY
Tags: String algorithms

Starter code:

Solutions:
for iii in range(int(input())):
	a = list(set(list(input())))
	b = list(set(list(input())))
	x = 0
	for i in a:
		if i in b:
			x = 1
	print('YES' if x else 'NO')


q = int(input())
for i in range(q):
	f = False
	s = input()
	t = input()
	for b in range(len(s)):
		if s[b] in t:
			f = True
	if s == t or f:
		print('YES')
	else:
		print('NO')


q = int(input())
ans = []
for i in range(q):
	s = set(input())
	t = input()
	b = False
	for j in s:
		if j in t:
			b = True
	if b:
		ans.append('YES')
	else:
		ans.append('NO')
print('\n'.join(ans))


num = int(input())
for i in range(num):
	a = input()
	b = input()
	if set(a) & set(b):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	same = 0
	s1 = input()
	s2 = input()
	for j in range(len(s1)):
		for k in range(len(s2)):
			if s1[j] == s2[k]:
				same = 1
	if same == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	s = set(input())
	t = input()
	for c in t:
		if c in s:
			print('Yes')
			break
	else:
		print('No')


q = int(input())
mass = []
for i in range(q):
	s = str(input())
	t = str(input())
	mass.append('NO')
	for item in s:
		if item in t:
			mass[i] = 'YES'
			break
for item in mass:
	print(item)


n = int(input())
for i in range(n):
	s = input()
	t = input()
	fl = False
	for i in range(len(s)):
		if s[i] in t:
			fl = True
			break
	if fl:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s1 = set(input())
	s2 = set(input())
	if s1 & s2:
		print('yes')
	else:
		print('no')


q = int(input())
b = 0
c = 0
while b < q:
	n1 = str(input())
	n2 = str(input())
	if len(n1) == len(n2):
		for x in n1:
			if x in n2:
				print('YES')
				break
			else:
				c += 1
		if c == len(n1):
			print('NO')
		c = 0
	else:
		print('NO')
	b += 1


q = int(input())
for i in range(q):
	s_ = set(input())
	t_ = set(input())
	if len(s_ & t_) >= 1:
		print('YES')
	else:
		print('NO')


for q in range(int(input())):
	s = input()
	t = input()
	print('YES' if len(set(s) & set(t)) else 'NO')


t = int(input())
while t != 0:
	t -= 1
	s1 = str(input())
	s2 = str(input())
	l1 = [0] * 26
	l2 = [0] * 26
	for ch in s1:
		l1[ord(ch) - 97] = 1
	for ch in s2:
		l2[ord(ch) - 97] = 1
	ok = False
	for i in range(0, 26):
		if l1[i] == l2[i] == 1:
			ok = True
			break
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())

def poss(a, b):
	for i in a:
		if i in b:
			return 'YES'
	return 'NO'
for _ in range(t):
	a = input()
	b = input()
	print(poss(a, b))


def main():
	q = int(input())
	for i in range(q):
		a = set(input())
		b = set(input())
		if len(a.intersection(b)) != 0:
			print('YES')
		else:
			print('NO')
main()


def g(s, t):
	for j in range(len(s)):
		for f in range(len(t)):
			if s[j] == t[f]:
				return 'YES'
	return 'NO'
q = int(input())
for i in range(q):
	s = str(input())
	t = str(input())
	print(g(s, t))


n = int(input())
arr = [input() for i in range(2 * n)]
for i in range(2 * n):
	if i % 2 == 0:
		if len(set(arr[i]).intersection(set(arr[i + 1]))) >= 1:
			print('yes')
		else:
			print('no')


q = int(input())
for j in range(q):
	s1 = str(input())
	s2 = str(input())
	b = False
	for i in s1:
		if i in s2:
			b = True
			break
	if b:
		print('YES')
	else:
		print('NO')


n = int(input())
o = set()
a = set()
h = []
for i in range(n):
	o = set(input())
	a = set(input())
	if o & a != set():
		h.append('YES')
	else:
		h.append('NO')
for i in h:
	print(i)


q = int(input())
active = True
for i in range(0, q):
	t = input()
	s = input()
	active = True
	for j in range(0, len(s)):
		for k in range(0, len(t)):
			if s[j] == t[k]:
				print('YES')
				active = False
			if active == False:
				break
		if active == False:
			break
	if active == True:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = (input(), input())
	(ai, bi) = (0, 0)
	for i in b:
		if i in a:
			print('yes')
			break
	else:
		print('no')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	if any(map(lambda x: x in t, s)):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	(s, t) = (input(), input())
	if set(s) & set(t) != set():
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	t = input()
	f = False
	for j in t:
		if j in s:
			f = True
			break
	if f:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = input()
	b = input()
	(a, b) = (min(a, b), max(a, b))
	h = True
	for j in range(len(a)):
		if a[j] in b:
			print('YES')
			h = False
			break
	if h:
		print('NO')


q = int(input())
n = []
for i in range(q):
	n.append(False)
ss = 0
for i in range(q):
	s1 = input()
	s2 = input()
	for g in range(len(s1)):
		s = str(s1[g])
		if s2.find(s) >= 0:
			ss += 1
	n[i] = ss
	ss = 0
for i in range(q):
	if n[i]:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s1 = input()
	s2 = input()
	print('YES' if set(s1) & set(s2) != set() else 'NO')


for k in range(int(input())):
	print('NO' if len(set(input()) & set(input())) == 0 else 'YES')


q = int(input())
gg = False
for _ in range(q):
	a = input()
	b = input()
	for s in a:
		if s in b:
			gg = True
			break
	print('yes' if gg else 'no')
	gg = False


n = int(input())
arr = []
amount = n * 2
for i in range(amount):
	arr.append(input())
i = 0
while i < amount - 1:
	if len(arr[i]) == 1:
		if arr[i] == arr[i + 1]:
			print('YES')
		else:
			print('NO')
	else:
		flag = False
		for j in arr[i]:
			for k in arr[i + 1]:
				if j == k:
					flag = True
					break
			if flag:
				break
		if flag:
			print('YES')
		else:
			print('NO')
	i += 2


q = int(input())
while q > 0:
	s = str(input())
	t = str(input())
	y = []
	z = []
	if s == t:
		print('yes')
	if s != t:
		l = list(s)
		k = list(t)
		result = list(set(l) & set(k))
		if result == []:
			print('no')
		else:
			print('yes')
	q = q - 1


q = int(input())
for i in range(q):
	z = True
	s = str(input())
	t = str(input())
	if s == t:
		pass
	elif set(s).intersection(set(t)) == set():
		z = False
	if z:
		print('Yes')
	else:
		print('No')


q = int(input())
l = 0
for i in range(1, q + 1):
	s = input()
	t = input()
	for g in range(0, len(s)):
		for f in range(0, len(t)):
			if s[g] == t[f]:
				l += 1
	if l >= 1:
		print('YES')
	else:
		print('NO')
	l = 0


n = int(input())
a = []
for i in range(n):
	a.append(input())
	a.append(input())
j = 0
for i in range(n):
	g = list(a[j])
	f = list(a[j + 1])
	k = set(g)
	o = set(f)
	if k.intersection(o) != set() and len(g) == len(f):
		print('YES')
	else:
		print('NO')
	j += 2


import sys
DEBUG = 0
(FSTREAM_IN, FSTREAM_OUT) = (DEBUG, DEBUG)
(FILENAME_IN, FILENAME_OUT) = ('in.txt', 'out.txt')

def main():
	n = int(input())
	for i in range(n):
		s = input()
		t = input()
		if len(s) < 2:
			print('YES' if s == t else 'NO')
			continue
		f = 0
		for c in s:
			if c in t:
				f = 1
				break
		print('YES' if f else 'NO')
if DEBUG:
	(FILENAME_IN, FILENAME_OUT) = ('debug.in', 'debug.out')
if FSTREAM_IN:
	sys.stdin = open(FILENAME_IN, 'r')
if FSTREAM_OUT:
	sys.stdout = open(FILENAME_OUT, 'w')
main()


q = int(input())
for i in range(q):
	s = list(input())
	t = list(input())
	s.sort()
	t.sort()
	for j in t:
		if j in s:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
f = 0
for i in range(n):
	a = input()
	b = input()
	l1 = len(a)
	l2 = len(b)
	if l1 != l2:
		print('NO')
		break
	f = 0
	for j in range(l1):
		if a[j] in b:
			print('YES')
			f = 1
			break
	if f != 1:
		print('NO')


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
for _ in range(int(input())):
	a = input()
	b = input()
	flag = 0
	for i in a:
		if i in b:
			print('YES')
			flag = 1
			break
	if flag == 0:
		print('NO')


inp = int(input())
A = []
for i in range(inp):
	A.append([input(), input()])
for i in A:
	out = False
	for j in i[0]:
		if i[1].find(j) != -1:
			out = True
			break
	if out:
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	a = set(input())
	b = input()
	flag = False
	for e in b:
		if e in a:
			flag = True
			break
	print('YES' if flag else 'NO')


def main():
	n = int(input())
	for i in range(n):
		s = input()
		t = input()
		for c in s:
			if c in t:
				print('YES')
				break
		else:
			print('NO')
main()


t = int(input().strip())
for case in range(t):
	str1 = input().strip()
	str2 = input().strip()
	chars1 = set()
	chars2 = set()
	for c in str1:
		chars1.add(c)
	for c in str2:
		chars2.add(c)
	if len(chars1 & chars2) > 0:
		print('YES')
	else:
		print('NO')


x = int(input())
j = []
for i in range(x):
	o = 'NO'
	s = input()
	t = input()
	for i in range(len(s)):
		if s[i] in t:
			o = 'YES'
			break
	j.append(o)
for i in range(len(j)):
	print(j[i])


def str_equalizer(all_pairs):
	for pairs in all_pairs:
		word1 = pairs[0]
		word2 = pairs[1]
		if word1 == word2:
			print('YES')
		else:
			lst_word1 = [i for i in word1]
			lst_word2 = [j for j in word2]
			if len(lst_word1) == 1 and word1 == word2:
				print('YES')
			else:
				dct_letters = {}
				for i in lst_word1:
					if i not in dct_letters.keys():
						dct_letters[i] = [1, 0]
				for j in lst_word2:
					if j in dct_letters.keys():
						if dct_letters[j][1] == 0:
							dct_letters[j] = [1, 1]
						else:
							pass
					else:
						dct_letters[j] = [0, 1]
				flag = 0
				for values in dct_letters.values():
					if values[0] == values[1]:
						flag += 1
				if flag > 0:
					print('YES')
				else:
					print('NO')

def main():
	no_of_tests = int(input())
	lst_all_pair = []
	for i in range(no_of_tests):
		string1 = input()
		string2 = input()
		lst_all_pair.append([string1, string2])
	str_equalizer(lst_all_pair)
main()


n = int(input())
for i in range(n):
	s = input()
	t = input()
	isPossible = False
	if s == t:
		print('YES')
	elif len(s) != len(t):
		print('NO')
	else:
		for j in s:
			if j in t:
				isPossible = True
				break
		if isPossible:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	s = input()
	t = input()
	if len(set(list(s)) & set(list(t))) != 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t > 0:
	a = str(input())
	b = str(input())
	g = 0
	s1 = ''.join(sorted(set(a)))
	s2 = ''.join(sorted(set(b)))
	if s1 != s2:
		for i in range(len(s1)):
			for j in range(len(s2)):
				if s1[i] == s2[j]:
					g = 1
					break
			if g == 1:
				break
	else:
		g = 1
	if g == 1:
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
r = 0
count = []
a = []
b = []
for g in range(n):
	s1 = input()
	s2 = input()
	for i in range(len(s1)):
		a.append(s1[i])
		b.append(s2[i])
	for i in range(len(a)):
		if a[i] in b:
			count.append('YES')
			r = 1
			break
	if r == 0:
		count.append('NO')
	r = 0
	a = []
	b = []
for i in count:
	print(i)


n = int(input())
for i in range(n):
	s = input()
	t = input()
	k = 'NO'
	for j in range(len(s)):
		for p in range(len(t)):
			if s[j] == t[p]:
				k = 'YES'
				break
	print(k)


q = int(input())
o = 0
for k in range(q):
	o = 0
	s = input()
	t = input()
	s = list(map(str, s))
	t = list(map(str, t))
	for i in s:
		if i in t:
			o += 1
	if o > 0:
		print('YES')
	else:
		print('NO')


from sys import stdin, stdout
from math import gcd
input = stdin.readline
for _ in range(int(input())):
	s = input()[:-1]
	t = input()[:-1]
	if set(s) & set(t):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	flag = 0
	for i in range(len(a)):
		for j in range(len(a)):
			if a[i] == b[j]:
				flag = 1
				break
	if flag == 1:
		print('YES')
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase

def solution(s, t):
	write('YES' if set(s).intersection(set(t)) else 'NO')

def main():
	for _ in range(r_int()):
		s = input()
		t = input()
		solution(s, t)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


a = int(input())
s = 0
for i in range(0, a):
	b = input()
	c = input()
	for i in b:
		if i in c:
			print('YES')
			s = s + 1
			break
	if s == 0:
		print('NO')
		s = 0
	s = 0


def solve(string_1, string_2):
	string_1 = [x for x in string_1]
	string_2 = [x for x in string_2]
	string_1 = set(string_1)
	string_2 = set(string_2)
	for x in string_2:
		if x in string_1:
			return 'Yes'
	return 'No'
for x in range(int(input())):
	string_1 = input()
	string_2 = input()
	print(solve(string_1, string_2))


q = int(input())
for i in range(0, q):
	s = str(input())
	t = str(input())
	a = []
	b = []
	for k in range(0, len(s)):
		a.append(s[k])
	for j in range(0, len(t)):
		b.append(t[j])
	a = set(a)
	b = set(b)
	m = a.intersection(b)
	if len(m) == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for _ in range(n):
	a = set(input())
	b = set(input())
	if len(a - b) != len(a):
		print('YES')
	else:
		print('NO')


def answer(s, t):
	if s & t != {1} & {0}:
		print('YES')
	else:
		print('NO')
q = int(input())
for i in range(q):
	s = str(input())
	s = set(s)
	t = str(input())
	t = set(t)
	answer(s, t)


for i in range(int(input())):
	s = input()
	t = input()
	if len(s) != len(t):
		print('NO')
	else:
		S = set()
		T = set()
		for q in range(0, len(s)):
			S.add(s[q])
			T.add(t[q])
		U = T & S
		if len(U) == 0:
			print('NO')
		else:
			print('YES')


n = int(input())
for i in range(n):
	s = input()
	fl = 0
	for i in input():
		if i in s:
			fl = 1
	if fl:
		print('YES')
	else:
		print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
dx = [0, 0, 1, -1]
dy = [1, -1, 0, 0]

def YES():
	print('YES')

def NO():
	print('NO')

def Yes():
	print('Yes')

def No():
	print('No')
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

class MergeFind:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		self.num_sets -= 1
		self.parent[a] = b
		self.size[b] += self.size[a]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def solve():
	s = inp()
	t = inp()
	s1 = set()
	s2 = set()
	for i in s:
		s1.add(i)
	for i in t:
		s2.add(i)
	t = s1.intersection(s2)
	if len(t) > 0:
		YES()
	else:
		NO()
testcase(int(inp()))


for i in range(int(input())):
	res = 'NO'
	A = input()
	B = input()
	for c in A:
		if c in B:
			res = 'YES'
			break
	print(res)


n = int(input())
for i in range(n):
	a = input()
	b = input()
	y = 0
	for j in range(len(a)):
		for t in range(len(b)):
			if a[j] == b[t]:
				print('YES')
				y = 1
				break
		if a[j] == b[t]:
			break
	if y != 1:
		print('NO')


kolvo = int(input())
for i in range(kolvo):
	s = input()
	t = input()
	v = 'NO'
	for letter in s:
		if letter in t:
			v = 'YES'
	print(v)


ans = []
for xxx in range(int(input())):
	s = input()
	se = set(s)
	valid = 0
	for i in input():
		if i in se:
			valid = 1
			break
	if valid:
		ans.append('yes')
	else:
		ans.append('no')
print(*ans, sep='\n')


q = int(input())
chek = False
for i in range(q):
	s = input()
	t = input()
	if s == t:
		print('YES')
	else:
		for k in s:
			if k in t:
				print('YES')
				chek = True
				break
		if not chek:
			print('NO')
	chek = False


n = int(input())
for i in range(n):
	q = 1
	s = input()
	t = input()
	a = len(s)
	for j in range(a):
		for k in range(a):
			if s[j] == t[k]:
				q = 0
				break
			if q == 0:
				break
	if q == 0:
		print('YES')
	else:
		print('NO')


for qq in range(int(input())):
	s = input()
	t = input()
	x = set(s).intersection(set(t))
	if len(x) >= 1:
		print('YES')
	else:
		print('NO')


for u in range(int(input())):
	s = input()
	t = input()
	f = 0
	for i in range(len(s)):
		if t[i] in s:
			f = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


def f(n):
	if n == 2:
		return 2
	if n % 2 == 0:
		return 0
	return 1
for i in range(int(input())):
	q = input()
	a = set()
	for i in q:
		a.add(i)
	q = input()
	b = set()
	for i in q:
		b.add(i)
	c = a.intersection(b)
	if len(c) == 0:
		print('No')
	else:
		print('Yes')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	R = True
	for c in 'qwertyuiopasdfghjklzxcvbnm':
		if c in s and c in t:
			print('YES')
			R = False
			break
	if R:
		print('NO')


for _ in range(int(input())):
	s = set(input())
	t = set(input())
	if s.intersection(t):
		print('yes')
	else:
		print('no')


a = int(input())
for i in range(a):
	s = input()
	t = input()
	an = 'no'
	for i in range(len(s)):
		if s[i] in t:
			an = 'yes'
	print(an)


import array

def solution():
	req = int(input())
	for i in range(req):
		book_first = {}
		book_second = {}
		first = input()
		second = input()
		if len(second) != len(first):
			print('NO')
			continue
		for ii in first:
			if ii not in book_first:
				book_first[ii] = 0
			else:
				book_first[ii] += 1
		for ii in second:
			if ii not in book_second:
				book_second[ii] = 0
			else:
				book_second[ii] += 1
		safe_point = False
		for ii in book_first:
			if ii in book_second:
				safe_point = True
				break
		if safe_point:
			print('YES')
		else:
			print('NO')

def count_of_one(number):
	result = 0
	while number:
		result += number % 2
		number //= 2
	return result

def to_mixed_frac(first, second):
	while True:
		for i in range(2, first + 1):
			if first % i == 0 and second % i == 0:
				first //= i
				second //= i
				break
		else:
			break
	return str(first) + '/' + str(second)

def array_to_int(array):
	for i in range(len(array)):
		array[i] = int(array[i])
	return array

def join0(array):
	result = ''
	for i in array:
		result += str(i)
	return result

def replace(string, new_ch, index):
	new_str = ''
	for i in range(len(string)):
		if i == index:
			new_str += new_ch
		else:
			new_str += string[i]
	return new_str
solution()


k = int(input())
x = []
for i in range(k):
	a = set(input())
	b = set(input())
	if a.isdisjoint(b) == True:
		x.append('NO')
	else:
		x.append('YES')
for i in range(k):
	print(x[i])


q = int(input())
for _ in range(q):
	s1 = list(input())
	s2 = list(input())
	if s1 == s2:
		print('YES')
		continue
	if len(s1) == 1:
		print('NO')
		continue
	set1 = set(s1)
	set2 = set(s2)
	res = set1.intersection(set2)
	if len(res) > 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	print('YES' if set(input()).intersection(input()) else 'NO')


for i in range(int(input())):
	a = set(input())
	b = set(input())
	print(['NO', 'YES'][len(a.intersection(b)) > 0])


q = int(input())
for i in range(q):
	a = list(input())
	b = list(input())
	a = set(a)
	op = 0
	for i in b:
		if i in a:
			print('YES')
			op = 1
			break
	if op == 0:
		print('NO')


n = int(input())
for i in range(n):
	a = input()
	b = input()
	m = 0
	for ii in a:
		if ii in b:
			m = 1
			break
	if m == 1:
		print('YES')
	else:
		print('NO')


def solve():
	s = input()
	t = input()
	for a in s:
		for b in t:
			if a == b:
				print('YES')
				return
	print('NO')
q = int(input())
for _ in range(q):
	solve()


import sys
tc = int(sys.stdin.readline())
for _ in range(tc):
	a = list(sys.stdin.readline().rstrip())
	b = list(sys.stdin.readline().rstrip())
	n = len(a)
	can = False
	if len(set(a).intersection(set(b))) != 0:
		can = True
	print('YES' if can else 'NO')


for i in range(int(input())):
	(s, t) = [input() for j in range(2)]
	sl = {letter for letter in s}
	tl = {letter for letter in t}
	print('NO' if sl.isdisjoint(tl) else 'YES')


q = int(input())
for _ in range(q):
	(s, t) = (input(), input())
	print('Yes' if set(s) & set(t) else 'No')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	k = 'NO'
	if a == b:
		print('YES')
	else:
		for z in a:
			if z in b:
				k = 'YES'
				break
		print(k)


q = int(input())
for _ in range(q):
	s = set(input())
	t = set(input())
	k = s.intersection(t)
	if len(k) != 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	print('yes' if set(input()) & set(input()) else 'no')


a = int(input())
for v in range(a):
	l = 0
	s = input()
	t = input()
	if len(s) == 1:
		if s == t:
			print('YES')
		else:
			print('NO')
	else:
		for i in s:
			if l == 0:
				for j in t:
					if i == j:
						print('YES')
						l = 1
						break
			else:
				break
		if l == 0:
			print('NO')


from math import *
for _ in ' ' * int(input()):
	anyy = False
	s1 = input()
	s2 = input()
	for i in s1:
		for j in s2:
			anyy = anyy or i == j
	if anyy:
		print('YES')
	else:
		print('NO')


a = int(input())
for _ in range(a):
	str1 = input()
	str2 = input()
	if len(str1) != 1:
		for elem in str1:
			if elem in str2:
				print('YES')
				break
		else:
			print('NO')
	elif str1 == str2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s1 = input()
	s2 = input()
	f = 0
	for i in s1:
		if i in s2:
			f = 1
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
B = []
for i in range(n):
	Mn1 = set(input())
	Mn2 = set(input())
	if Mn1 & Mn2:
		B.append('YES')
	else:
		B.append('NO')
for i in B:
	print(i)


t = int(input())
for x in range(t):
	l1 = set(list(input()))
	l2 = set(list(input()))
	done = 0
	for x in l1:
		if x in l2:
			done = 1
			break
	if done:
		print('YES')
	else:
		print('NO')


q = int(input())
s = list()
t = list()
a = [i for i in range(q)]
for i in range(q):
	s.append(str(input()))
	t.append(str(input()))
	h = -1
	if t[i].find(s[i][h]) >= 0:
		a[i] = 'YES'
	while t[i].find(s[i][h]) < 0 and h < len(s[i]) - 1:
		h = h + 1
		if t[i].find(s[i][h]) >= 0:
			a[i] = 'YES'
			break
	if a[i] != 'YES':
		a[i] = 'NO'
for i in range(q):
	print(a[i])


n = int(input())
k = ''
m = ''
for i in range(n):
	m = input()
	k = input()
	if len(m) == len(k):
		if len(list(set(m) & set(k))) >= 1:
			print('Yes')
		else:
			print('NO')


for _ in range(int(input())):
	a = input()
	b = input()
	fl = False
	for i in a:
		if i in b:
			fl = True
			break
	for i in b:
		if i in a:
			fl = True
			break
	print('YES' if fl else 'NO')


q = int(input())
myList = []
for i in range(q):
	s = set(input())
	t = set(input())
	if len(s & t) == 0:
		myList.append('NO')
	else:
		myList.append('YES')
print(*myList, sep='\n')


a = int(input())
for i in range(a):
	s1 = input()
	s2 = input()
	s1 = [i for i in s1]
	s2 = [i for i in s2]
	k = 0
	for i in s2:
		if i in s1:
			k = 1
			break
	if k == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	ok = False
	for j in s:
		for k in t:
			if j == k:
				ok = True
				break
		if ok:
			break
	if ok:
		print('YES')
	else:
		print('NO')


q = int(input())
answers = []
for i in range(q):
	flag = 0
	s = input()
	t = input()
	s = list(s)
	t = set(t)
	for j in range(len(s)):
		if s[j] in t:
			flag = 1
			answers.append('YES')
			break
	if flag == 0:
		answers.append('NO')
for i in range(len(answers)):
	print(answers[i])


a = int(input())
i = 0
for i in range(a):
	s = set(str(input()))
	t = set(str(input()))
	if s & t:
		print('YES')
	else:
		print('NO')
	i += i


def pos(a):
	return ord(a) - 97

def test():
	a_string = input()
	b_string = input()
	n = len(a_string)
	chr_a = [0] * 26
	chr_b = [0] * 26
	for i in range(n):
		sa = a_string[i]
		sb = b_string[i]
		pa = pos(sa)
		pb = pos(sb)
		chr_a[pa] += 1
		chr_b[pb] += 1
		if chr_a[pa] > 0 and chr_a[pb] > 0 or (chr_b[pa] > 0 and chr_b[pb] > 0):
			print('YES')
			break
	else:
		print('NO')
q = int(input())
for _ in range(q):
	test()


n = int(input())
for i in range(n):
	a = input()
	b = input()
	if len(a) != len(b):
		print('NO')
		continue
	d = dict()
	for i in a:
		d[i] = 1
	c = 0
	for i in b:
		if i in d:
			c = 1
			break
	if c == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
q = []
for jjj in range(n):
	x = input()
	g = input()
	count = 0
	for i in range(len(x)):
		if x[i] in g or g[i] in x:
			count += 1
	if count > 0:
		q.append('YES')
	else:
		q.append('NO')
for ooo in range(n):
	print(q[ooo])


q = int(input())
for i in range(0, q):
	k = False
	(s, t) = (input(), input())
	for ch1 in s:
		for ch2 in t:
			if ch1 == ch2:
				k = True
				break
	if k:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = (input(), input())
	cn = 0
	for i in range(len(n)):
		if n[i] in m:
			cn += 1
	if cn >= 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	p = 0
	for k in t:
		if k in s:
			print('yes')
			break
		else:
			p += 1
	if p == len(s):
		print('no')


t = int(input())
for _ in range(t):
	a = input()
	b = input()
	d1 = dict()
	d2 = dict()
	f = 0
	sa = set()
	sb = set()
	for i in range(len(a)):
		sa.add(a[i])
		sb.add(b[i])
	sa.intersection_update(sb)
	if len(sa) > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for x in range(n):
	s1 = input()
	s2 = input()
	for x in s1:
		if x in s2:
			print('YES')
			break
	else:
		print('NO')


def line():
	return map(int, input().split())

def num():
	return int(input())
from itertools import repeat
q = num()
for _ in repeat(None, q):
	s = input()
	t = input()
	(x, y) = (set(s), set(t))
	if x.isdisjoint(y):
		print('no')
	else:
		print('yes')


q = int(input())
for i in range(q):
	(s, t) = (input(), input())
	flag = False
	for j in range(len(s)):
		if s[j] in t:
			flag = True
			break
	print('YES') if flag else print('NO')


q = int(input())
for i in range(q):
	question = False
	a = input()
	b = input()
	for j in range(len(a)):
		for w in range(len(a)):
			if a[j] == b[w]:
				question = True
				break
		if question:
			break
	if question:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = set(input())
	t = set(input())
	m = set()
	m = s & t
	if m != set():
		print('yes')
	else:
		print('no')


n = int(input())
for i in range(n):
	s = input()
	t = input()
	x = 0
	y = 0
	for i in t:
		if i in s:
			x = 1
	if x == 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	b = True
	s = input()
	t = input()
	if s == t:
		print('YES')
	elif len(s) == 1 or len(t) == 1:
		print('NO')
	else:
		for j in set(t):
			if j in s:
				print('YES')
				b = False
				break
		if b is True:
			print('NO')


q = int(input())

def check(s, t):
	for j in s:
		for k in t:
			if k == j:
				return 'YES'
	return 'NO'
for i in range(q):
	s = list(input())
	t = list(input())
	print(check(s, t))


for _ in range(int(input())):
	line1 = input()
	line2 = input()
	if set(line1) & set(line2):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(s, t) = (input(), input())
	(a, b) = (set(s), set(t))
	if a & b:
		print('YES')
	else:
		print('NO')


n = int(input())
l = []
for i in range(n):
	l.append([input(), input()])
for i in l:
	a = set(i[0])
	b = set(i[1])
	if a == b or a >= b or b >= a or (a & b != set()):
		print('YES')
	else:
		print('NO')


n = int(input())
for j in range(n):
	a = set(input())
	b = set(input())
	val = a & b
	if len(val) > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	s = input()
	t = input()
	n = len(s)
	success = False
	for i in range(n):
		for q in range(n):
			if s[i] == t[q]:
				success = True
				break
		if success:
			break
	print('YES' if success else 'NO')


q = int(input())
s = []
t = []
for i in range(q):
	s += [input()]
	t += [input()]
for i in range(q):
	found = False
	for letter in s[i]:
		if letter in t[i]:
			found = True
	if not found:
		print('No')
	else:
		print('Yes')


for i in range(int(input())):
	s = input()
	t = input()
	sett = set(t)
	can = False
	for j in range(len(s)):
		if s[j] in sett:
			can = True
			break
	if can:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = input()
	b = input()
	if (len(a) != len(b) or len(a) == 1) and a != b:
		print('NO')
	else:
		count = 0
		for j in a:
			if j not in b:
				count += 1
		if count == len(a):
			print('NO')
		else:
			print('YES')


n = int(input())
for i in range(n):
	a = str(input())
	b = str(input())
	count = 0
	for j in range(len(a)):
		if a[j] in b:
			count = count + 1
			break
	if count == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	if len(s) != len(t):
		print('NO')
	else:
		for i in range(len(s)):
			if s[i] in t:
				print('YES')
				break
		else:
			print('NO')


t = int(input())
while t:
	k = 0
	a = set(input())
	b = set(input())
	a = list(a)
	b = list(b)
	for i in range(len(b)):
		if b[i] in a:
			k = 1
	if k:
		print('YES')
	else:
		print('NO')
	t -= 1


n = int(input())
for i in range(n):
	s = input()
	t = input()
	s1 = set()
	s2 = set()
	for q in s:
		s1.add(q)
	for q in t:
		s2.add(q)
	if len(s1.intersection(s2)):
		print('YES')
	else:
		print('NO')


q = int(input())

def FindSameLetter(a, b):
	letter = 0
	for i in range(len(a)):
		for j in range(len(b)):
			if a[i] == b[j]:
				letter = a[i]
				break
	if letter == 0:
		letter = 0
	return letter
allo = []
for i in range(q):
	a = input()
	allo.append(a)
	b = input()
	allo.append(b)
for i in range(0, len(allo), 2):
	if FindSameLetter(allo[i], allo[i + 1]) == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	l1 = list(set(sorted(input())))
	l2 = list(set(sorted(input())))
	for i in l1:
		if i in l2:
			print('YES')
			break
	else:
		print('NO')


import math

def okr_up(a):
	q = math.floor(a)
	if q != a:
		return q + 1
	else:
		return q

def func(n):
	if n == 4:
		return 0
	elif n < 4:
		return int(4 - n)
	else:
		w1 = math.floor(n / 4)
		w2 = okr_up(n / 4)
		w3 = int(n - w1 - w2)
		m = [w1, w2, w3]
		m.sort()
		a = m[0]
		b = m[1]
		c = m[2]
		if a + b == c:
			return 0
		else:
			return abs(a + b - c)
q = int(input())
for i in range(q):
	s = input()
	t = input()
	s = list(s)
	t = list(t)
	ss = set(s)
	st = set(t)
	w = ss.intersection(st)
	null = set()
	if w == null:
		print('NO')
	else:
		print('YES')


Q = int(input())
for i in range(Q):
	s = str(input())
	t = str(input())
	ans = 'NO'
	for i in s:
		if i in t:
			ans = 'YES'
			break
	print(ans)


n = int(input())
for _ in range(n):
	(i1, i2) = (input(), input())
	if len(i1) == len(i2) and any(map(lambda x: x in set(i2), set(i1))):
		print('YES')
	else:
		print('NO')


q = int(input())
i = 0
for i in range(q):
	a = str(input())
	b = str(input())
	if len(a) != len(b):
		print('NO')
	else:
		z = 0
		h = False
		for z in range(len(a)):
			if a[z] in b:
				h = True
				break
	if h:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	s = input()
	t = input()
	A = set(s)
	B = set(t)
	if A & B:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	x = input()
	y = input()
	if set(x) & set(y):
		print('Yes')
	else:
		print('No')


t = int(input())
for t_ in range(t):
	s = input()
	t = input()
	flag = False
	for c in s:
		if c in t:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


for cas in range(int(input())):
	s = input()
	t = input()
	flg = 0
	for c in s:
		if c in t:
			flg = 1
	if flg == 1:
		print('YES')
	else:
		print('NO')


count = int(input())
data = []
for i in range(count):
	data.append([input(), input()])
for stringSet in data:
	sym1 = list(set(stringSet[0]))
	sym2 = list(set(stringSet[1]))
	found = False
	while sym1:
		if sym2.count(sym1.pop()) != 0:
			found = True
			break
	if found:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	str1 = input()
	str2 = input()
	res = 0
	for j in range(len(str1)):
		if str1[j] in str2:
			res = 1
			break
	if res == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = input()
	m = input()
	count = 0
	for i in n:
		if i in m:
			count = 1
			break
	for i in m:
		if i in n:
			count = 1
			break
	if count == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	n = 0
	for k in range(97, 123):
		if s.find(chr(k)) != -1 and t.find(chr(k)) != -1:
			print('YES')
			n = 1
			break
	if n == 0:
		print('NO')


k = int(input())
a = set()
b = set()
for i in range(k):
	s1 = input()
	s2 = input()
	a.clear()
	b.clear()
	for ch in s1:
		a.add(ch)
	for ch in s2:
		b.add(ch)
	if a.intersection(b):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	b = set(b)
	fl = False
	for j in a:
		if j in b:
			fl = True
			print('YES')
			break
	if not fl:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	t = False
	for i in set(b):
		if i in set(a):
			t = True
			break
	if t:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = set(list(input()))
	t = set(list(input()))
	if s.isdisjoint(t):
		print('NO')
	else:
		print('YES')


N = int(input())
for i in range(N):
	s = input()
	t = input()
	if len(set(s) & set(t)) > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	s1 = input()
	s2 = input()
	s = set()
	ss = set()
	for v in s1:
		s.add(v)
	for v in s2:
		ss.add(v)
	check = True
	for v in s:
		if v in ss:
			check = False
			print('YES')
			break
	if check:
		print('NO')


q = int(input())
s = []
t = []
for i in range(q):
	s.append(input())
	t.append(input())
for i in range(q):
	v = s[i]
	u = t[i]
	n = 0
	for j in range(len(v)):
		if v.find(u[j]) >= 0:
			n = 1
	if n == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
a = []
b = []
z = []
x = set()
for i in range(n):
	a.append(input())
	b.append(input())
for i in range(n):
	c = set(a[i])
	d = set(b[i])
	if c & d != x:
		z.append('YES')
	else:
		z.append('NO')
for i in range(n):
	print(z[i])


line = input()
q = int(line)
for q in range(0, q):
	set1 = set(input())
	set2 = set(input())
	if set1 & set2 == set():
		print('NO')
	else:
		print('YES')


n = int(input())
res = []
for i in range(n):
	a = input()
	b = input()
	if set(a).isdisjoint(set(b)) is True:
		res.append('NO')
	else:
		res.append('YES')
for j in res:
	print(j)


q = int(input())
a = [] * (2 * q)
for i in range(2 * q):
	a.append(input())
for i in range(0, q * 2, 2):
	if set(a[i]) & set(a[i + 1]):
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	A = 0
	(T, S) = (str(input()), str(input()))
	for j in range(len(T)):
		for k in range(len(S)):
			for word in S.split():
				if A != 1:
					if T[k] in word:
						A = 1
					else:
						A = 0
	if A == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
a = 'NO'
for i in range(n):
	a = 'NO'
	s = str(input())
	t = str(input())
	for j in s:
		if -1 != t.find(j):
			a = 'YES'
	print(a)


def solve(str1, str2):
	s = set({})
	for x in str1:
		s.add(x)
	for x in str2:
		if x in s:
			return True
	return False
t = int(input())
for i in range(t):
	str1 = input()
	str2 = input()
	if solve(str1, str2):
		print('YES')
	else:
		print('NO')


a = int(input())
l = []
s = False
for i in range(a):
	b = input()
	c = input()
	for j in b:
		if j in c:
			s = True
			break
	if s:
		l.append('YES')
	else:
		l.append('NO')
	s = False
for i in l:
	print(i)


q = int(input())
for i in range(q):
	a = input()
	b = input()
	c = [0] * 26
	d = [0] * 26
	for i in range(len(a)):
		c[ord(a[i]) - ord('a')] += 1
		d[ord(b[i]) - ord('a')] += 1
	k = 0
	for i in range(26):
		if c[i] >= 1 and d[i] >= 1:
			print('YES')
			k = 1
			break
	if k == 0:
		print('NO')


def string_equalization(s, t):
	if s == t:
		return 'Yes'
	elif len(s) == 1:
		return 'No'
	else:
		for x in s:
			if x in t:
				return 'Yes'
		return 'No'
x = int(input())
for y in range(x):
	s = input()
	t = input()
	print(string_equalization(s, t))


n = int(input())
for i in range(n):
	a = list(input())
	b = list(input())
	if len(a) != len(b):
		print('NO')
		continue
	if set(a) & set(b):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	letters_1 = set()
	letters_2 = set()
	flag = False
	for j in t:
		letters_2.add(j)
	for j in s:
		letters_1.add(j)
		if j not in t:
			flag = True
	if flag:
		flag2 = True
		for s in list(''.join(letters_2)):
			if s in ''.join(letters_1):
				print('YES')
				flag2 = False
				break
		if flag2:
			print('NO')
	else:
		print('YES')


n = []
for i in range(int(input())):
	k = [0] * 26
	a = str(input())
	b = str(input())
	for i in range(len(b)):
		k[ord(b[i]) - 97] += 1
	test = 0
	for i in range(len(a)):
		if k[ord(a[i]) - 97] != 0:
			test = 1
	if test == 1:
		n.append('YES')
	else:
		n.append('NO')
print('\n'.join(map(str, n)))


n = int(input())
for i in range(n):
	a = input()
	b = input()
	f = 1
	for el1 in a:
		if f:
			for el2 in b:
				if el1 == el2:
					print('YEs')
					f = 0
					break
	if f:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	possible = 0
	waspossible = 0
	for i in range(len(s)):
		if s[i] == t[i] or s[i] in t:
			possible = 1
			waspossible = 1
	if possible == 1 or (possible == 0 and waspossible == 1):
		print('Yes')
	else:
		print('No')


q = int(input())
for j in range(q):
	a = list(input())
	t = list(input())
	res = 0
	for i in range(len(a)):
		if a[i] in t:
			if a[i] in t:
				res += 1
			if t[i] in a:
				res += 1
	if res >= 1:
		print('YES')
	else:
		print('NO')


q = int(input())
ans = []
for i in range(q):
	s = set(input())
	t = set(input())
	if s.isdisjoint(t):
		ans.append('no')
	else:
		ans.append('yes')
for i in range(q):
	print(ans[i])


k = int(input())
S = []
T = []
for i in range(k):
	S.append(str(input()))
	T.append(str(input()))
for b in range(0, len(S)):
	h = 0
	for i in range(0, len(S[b])):
		if S[b][i] in T[b]:
			h = h + 1
	if h > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	ans = False
	for i in range(len(s)):
		ans = ans or s[i] in t
	if ans:
		print('YES')
	else:
		print('NO')


n = int(input())
d = ['NO'] * n
for i in range(n):
	s = input()
	t = input()
	for n in s:
		for m in t:
			if n == m:
				d[i] = 'YES'
				break
		if d[i] == 'YES':
			break
print(*d)


for i in range(int(input())):
	set1 = set(input())
	set2 = set(input())
	flag = False
	for i in set1:
		if i in set2:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	r = input()
	d = input()
	if len(set(r) & set(d)) > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for R in range(q):
	a = input()
	b = input()
	if set(a) & set(b):
		print('Yes')
	else:
		print('No')


q = int(input())
for query in range(q):
	s = input()
	t = input()
	f = False
	for i in s:
		if i in t:
			f = True
			break
	if f:
		print('YES')
	else:
		print('NO')


a = int(input())
for _ in range(a):
	str1 = input()
	str2 = input()
	for elem in str1:
		if elem in str2:
			print('YES')
			break
	else:
		print('NO')


q = int(input())
A = []
B = []
for i in range(q):
	A.append(str(input()))
	B.append(str(input()))
for i in range(0, len(A)):
	k = 0
	for j in range(0, len(A[i])):
		if A[i][j] in B[i]:
			k = k + 1
	if k > 0:
		print('YES')
	else:
		print('NO')


no_of_test_cases = int(input())
for test_cases in range(no_of_test_cases):
	s = sorted(input().lower())
	t = sorted(input().lower())
	print('NO' if len(set(s) & set(t)) == 0 else 'YES')


q = int(input())
for i in range(q):
	s = input()
	t = input()

	def check():
		for c1 in range(len(s)):
			for c2 in range(len(t)):
				if s[c1] == t[c2]:
					print('YES')
					return
		print('NO')
	check()


q = int(input())
for i in range(q):
	a = set(input())
	b = set(input())
	if a.intersection(b):
		print('YES')
	else:
		print('NO')


def f(s, t):
	if s == t:
		return 'YES'
	s = set(s)
	t = set(t)
	if len(s & t) > 0:
		return 'YES'
	return 'NO'
N = int(input())
for i in range(N):
	a = set(input())
	b = set(input())
	val = a & b
	if len(val) > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	p = True
	s = input()
	t = input()
	for r in s:
		if r in t:
			print('YES')
			t = False
			break
	if t:
		print('NO')


n = int(input())
for i in range(n):
	f = True
	x = input()
	y = input()
	for g in y:
		if g in x:
			f = False
			print('YES')
			break
	if f:
		print('NO')


m = int(input())
for i in range(m):
	c = []
	d = []
	a = input()
	b = input()
	z = 0
	for i in a:
		for j in b:
			if i == j:
				z = z + 1
			else:
				continue
	if z == 0:
		print('NO')
	else:
		print('YES')


k = int(input())
for _ in range(k):
	(a, b) = (set(input()), set(input()))
	if len(a.intersection(b)) > 0:
		print('YES')
	else:
		print('NO')


rng = int(input())
for _ in range(rng):
	s1 = input()
	s2 = input()
	b = False
	for el in s1:
		for el2 in s2:
			if el == el2:
				b = True
	if b:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	if s == t:
		print('YES')
	elif sorted(list(set(s))) == sorted(list(set(t))) or len(list(set.intersection(set(s), set(t)))) >= 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	ans = 'NO'
	s = list(input())
	t = list(input())
	for i in range(len(s)):
		if s[i] in t:
			ans = 'YES'
			break
	print(ans)


a = int(input())
for i in range(a):
	first_word = list(input())
	second_word = list(input())
	if len(set(first_word) & set(second_word)) > 0:
		print('YES')
	else:
		print('NO')


x = int(input())
for i in range(x):
	q = 0
	m = input()
	n = input()
	for i in m:
		if i in n:
			q = 1
			break
	if q:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	ans = 'NO'
	for char in s:
		if char in t:
			ans = 'YES'
			break
	print(ans)


q = int(input())
for Z in range(q):
	s = input()
	t = input()
	if s == t:
		print('YES')
		continue
	S = list(set(s))
	if any([i in t for i in S]):
		print('YES')
	else:
		print('NO')


t = int(input())
for case_num in range(t):
	s = input()
	ss = set([c for c in s])
	t = input()
	st = set([c for c in t])
	print('YES' if len(ss.intersection(st)) > 0 else 'NO')


from math import *
from sys import *
from heapq import *
from collections import defaultdict
import os, sys
from io import IOBase, BytesIO
M = 10 ** 9 + 7

def pow(a, b):
	res = 1
	while b > 0:
		if b & 1:
			res *= a
		a *= a
		b >>= 1
	return res

def powmod(a, b, m):
	res = 1
	while b > 0:
		if b & 1:
			res = res * a % m
		a *= a
		b >>= 1
	return res

def inv(a, m):
	return powmod(a, m - 2, m)

def alldivisors(n):
	list = []
	arr = []
	for i in range(1, int(sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				arr += [i]
			else:
				arr += [i]
				list.append(n // i)
	arr += list[::-1]
	return arr

def primefactorisation(n):
	potentional_p = 3
	itog_list = defaultdict(int)
	if n % 2 == 0:
		itog_list[2] = 0
	while n % 2 == 0:
		n = n // 2
		itog_list[2] += 1
	while n - 1:
		if potentional_p > n ** 0.5:
			itog_list[n] += 1
			return itog_list
		while n % potentional_p == 0:
			n = n // potentional_p
			itog_list[potentional_p] += 1
		potentional_p += 2
	return itog_list

def main():
	t = int(input())
	for _ in range(t):
		s = input()
		t = input()
		n = len(s)
		d1 = defaultdict(int)
		d2 = defaultdict(int)
		for (x, y) in zip(s, t):
			d1[x] = 1
			d2[y] = 1
		fl = 0
		for i in range(97, 123):
			if d1[chr(i)] == d2[chr(i)] and d1[chr(i)] != 0:
				print('YES')
				fl = 1
				break
		if fl == 0:
			print('NO')
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def answer(s, t):
	for i in s:
		if i in t:
			return True
	return False
for i in range(int(input())):
	s = input()
	t = input()
	if answer(s, t):
		print('YES')
	else:
		print('NO')


q = int(input())
while q:
	s = input()
	t = input()
	for i in s:
		if i in t:
			print('YES')
			break
	else:
		print('NO')
	q -= 1


q = int(input())
for i in range(q):
	a = set(input())
	b = set(input())
	if len(a.intersection(b)) == 0:
		print('No')
	else:
		print('Yes')


def f(s):
	lst = [0 for i in range(26)]
	for i in range(len(s)):
		lst[ord(s[i]) - ord('a')] += 1
	return lst
q = int(input())
for i in range(q):
	s = input()
	t = input()
	lsts = f(s)
	lstt = f(t)
	bul = False
	for i in range(26):
		if lsts[i] != 0 and lstt[i] != 0:
			bul = True
	if bul:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = set(input())
	b = set(input())
	if len(a.intersection(b)) > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
c = []
for i in range(n):
	s = input()
	fl = True
	s1 = input()
	for i in s:
		if i in s1:
			c.append('YES')
			fl = False
			break
	if fl:
		c.append('NO')
for i in c:
	print(i)


n = int(input())
for i in range(n):
	k = 0
	n1 = input()
	n2 = input()
	for i in n1:
		if i in n2:
			k = k + 1
			break
	if k > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	n = len(a)
	spa = [0] * 28
	spb = [0] * 28
	for i in range(n):
		spa[ord(a[i]) - ord('a')] = 1
		spb[ord(b[i]) - ord('a')] = 1
	fl = False
	for i in range(28):
		if spa[i] == 1 and spb[i] == 1:
			print('YES')
			fl = True
			break
	if not fl:
		print('NO')


n = int(input())
for i in range(n):
	s = str(input())
	t = str(input())
	cur = 1
	for i in range(len(s)):
		if s[i] in t:
			print('Yes')
			cur = 0
			break
	if cur:
		print('No')


n = int(input())
for i in range(n):
	first = input()
	second = input()
	if first == second:
		print('YES')
		continue
	if first != second and len(first) == 1:
		print('NO')
		continue
	flag = 0
	for j in first:
		if j in second:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = input()
	b = input()
	s = 'NO'
	for k in a:
		for l in b:
			if l == k:
				s = 'YES'
	print(s)


q = int(input())
for _ in range(q):
	s = input()
	t = input()
	concid = True
	for i in s:
		if i in t:
			print('YES')
			concid = False
			break
	if concid:
		print('NO')


q = int(input())
for _ in range(q):
	a = input()
	b = input()
	count = 0
	for i in range(len(a)):
		for j in range(len(b)):
			if a[i] == b[j]:
				count += 1
	if count != 0 and len(a) == len(b):
		print('yes')
	else:
		print('no')


q = int(input())
for i in range(q):
	(s1, s2) = (set(input()), set(input()))
	k = s1.intersection(s2)
	l = len(k)
	if l != 0:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = input()
	b = input()
	a = list(a)
	b = list(b)
	f = 0
	for j in range(len(a)):
		if a[j] in b:
			f = 1
			print('YES')
			break
	if f == 0:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	flag = 0
	for c in s:
		if c in t:
			print('YES')
			flag = 1
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(s, t) = (input(), input())
	if len(set(s) & set(t)) == 0:
		print('NO')
	else:
		print('YES')


k = int(input())
for i in range(k):
	(s1, s2) = (input(), input())
	if len(s1) != len(s2):
		print('NO')
	elif set(s1) & set(s2) == set():
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	c = input()
	d = input()
	k1 = set()
	k2 = set()
	for i in range(len(c)):
		k1.add(c[i])
		k2.add(d[i])
	if len(k1 & k2) != 0:
		print('YES')
		k1 = set()
		k2 = set()
	else:
		print('NO')
		k1 = set()
		k2 = set()


n = int(input())
for i in range(n):
	s = list(input())
	t = list(input())
	con = True
	for j in range(len(s)):
		for k in range(len(t)):
			if s[j] == t[k]:
				print('yes')
				con = False
				break
		if con is False:
			break
	if con is False:
		continue
	print('no')


N = int(input())
for i in range(N):
	s = input()
	t = input()
	count = 0
	for i in range(len(s)):
		if t.find(s[i]) >= 0:
			print('YES')
			count = 1
			break
	if count == 0:
		print('NO')


I = input
for _ in [0] * int(I()):
	print('YNEOS'[not set(I()) & set(I())::2])


def check(a):
	cnt = [0] * 26
	for i in a:
		cnt[ord(i) - 97] += 1
	return cnt
kol = int(input())
for i in range(kol):
	a = input()
	b = input()
	t2 = check(a)
	fl = False
	t1 = check(b)
	for j in range(26):
		if t1[j] != 0 and t2[j] != 0:
			fl = True
	if fl:
		print('YES')
	else:
		print('NO')


array = []
word = False
for i in range(int(input())):
	array.append([input(), input()])
for elem in array:
	for element in elem[0]:
		if element in elem[1]:
			word = True
			break
	if word:
		print('YES')
	else:
		print('NO')
	word = False


q = int(input())
for i in range(q):
	x = 0
	a = list(input())
	b = list(input())
	for j in range(len(a)):
		for w in range(len(a)):
			if a[j] == b[w]:
				print('YES')
				x = 1
				break
		if x == 1:
			break
	if x == 0:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	sset = set(s)
	tset = set(t)
	if sset & tset:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	al = []
	for i in a:
		al.append(i)
	bl = []
	for i in b:
		bl.append(i)
	yes = 0
	for i in al:
		if i in bl:
			print('YES')
			yes = 1
			break
	if yes == 0:
		print('NO')


for _ in range(int(input())):
	s = input()
	t = input()
	n = len(s)
	ok = False
	used = [False] * 26
	for i in range(n):
		used[ord(s[i]) - ord('a')] = True
	for i in range(n):
		if used[ord(t[i]) - ord('a')]:
			ok = True
	if ok:
		print('YES')
	else:
		print('NO')


def same(s, t):
	for i in range(len(s)):
		for j in range(len(t)):
			if s[i] == t[j]:
				return 'YES'
	return 'NO'
q = int(input())
a = []
for i in range(q):
	s = input()
	t = input()
	a.append(same(s, t))
for i in a:
	print(i)


for i in range(int(input())):
	(str1, str2) = [input() for j in range(2)]
	set1 = {letter for letter in str1}
	set2 = {letter for letter in str2}
	print('NO' if set1.isdisjoint(set2) else 'YES')


for i in range(int(input())):
	s1 = input()
	s2 = input()
	if (len(s1) == 1 or len(s2) == 1) and s2 != s1:
		print('NO')
	elif s1 == s2:
		print('YES')
	else:
		tr = False
		for i in s1:
			for j in s2:
				if i == j:
					print('YES')
					tr = True
					break
			if tr:
				break
		if not tr:
			print('NO')


n = int(input())
for i in range(n):
	s1 = input()
	s2 = input()
	if len(s1) != len(s2) or (s1 != s2 and len(s1) == 1 and (len(s2) == 1)):
		print('NO')
		continue
	t = False
	for i in range(len(s1)):
		for j in range(len(s2)):
			if s1[i] == s2[j]:
				t = True
				break
		if t == True:
			print('YES')
			break
	if t == True:
		continue
	print('NO')


q = int(input())
otv = []
for i in range(q):
	s = input()
	t = input()
	if s == t:
		otv.append('YES')
	elif len(s) == len(t) == 1 and s != t:
		otv.append('NO')
	else:
		b1 = []
		b2 = []
		for x in s:
			if x not in b1:
				b1.append(x)
		for x in t:
			if x not in b2:
				b2.append(x)
		p = 0
		for x in b1:
			for y in b2:
				if x == y:
					p = 1
					break
			if p == 1:
				break
		if p == 1:
			otv.append('YES')
		else:
			otv.append('NO')
for x in otv:
	print(x)


I = input
for i in range(int(I())):
	a = I()
	b = I()
	n = len(a)
	c = 'NO'
	for i in range(n):
		if a[i] in b:
			c = 'YES'
			break
	print(c)


n = int(input())
for i in range(n):
	q = input()
	w = input()
	flag = 0
	for x in range(len(q)):
		if q[x] in w:
			flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	t = input()
	p = set(s)
	t = set(t)
	x = 1
	for k in p:
		if k in t:
			print('YES')
			x = 0
			break
	if x == 1:
		print('NO')


t = int(input())
for _ in range(t):
	n = input()
	m = input()
	n = list(n)
	p = 0
	for i in range(len(n)):
		if m[i] in n or n[i] in m:
			print('YES')
			p = 1
			break
	if p == 0:
		print('NO')


for q in range(int(input())):
	s = input()
	t = input()
	c = 0
	for i in s:
		if i in t:
			print('YES')
			c = 1
			break
	if c == 0:
		print('NO')


def check(s, t):
	alph1 = [0] * 26
	alph2 = [0] * 26
	for i in range(len(s)):
		alph1[ord(s[i]) - 97] += 1
		alph2[ord(t[i]) - 97] += 1
	for i in range(26):
		if alph1[i] > 0 and alph2[i] > 0:
			return 'YES'
	return 'NO'
q = int(input())
for i in range(q):
	s = input()
	t = input()
	print(check(s, t))


for i in range(int(input())):
	t = set(input())
	y = set(input())
	m = t & y
	if len(m) > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
ask = [0 for i in range(2 * n)]
for i in range(n):
	ask[2 * i] = input()
	ask[2 * i + 1] = input()
for i in range(n):
	q1 = 2 * i
	q2 = 2 * i + 1
	t1 = ask[q1]
	t2 = ask[q2]
	s = 0
	for a1 in range(len(t1)):
		for b1 in range(len(t2)):
			if t1[a1] == t2[b1]:
				print('YES')
				s += 1
				break
		if s == 1:
			break
	if s == 0:
		print('NO')


q = int(input())
for i in range(q):
	s = str(input())
	t = str(input())
	v = 'NO'
	for letter in s:
		if letter in t:
			v = 'YES'
	print(v)


s = int(input())
a = []
for _ in range(s):
	s1 = input()
	s2 = input()
	for j in s1:
		for k in s2:
			if j == k:
				ae = 'yes'
				break
			else:
				ae = 'no'
		if ae == 'yes':
			break
	a.append(ae)
for j in a:
	print(j)


q = int(input())
L = []
K = []
m = ''
for i in range(q):
	a = 0
	s = input()
	t = input()
	L.append(s)
	K.append(t)
	for i in range(len(s)):
		if s[i] in t:
			a = 1
			print('YES')
			break
	if a == 0:
		print('NO')


q = int(input())
m = 0
for i in range(q):
	m = 0
	s = input()
	t = input()
	if s == t:
		print('YES')
	elif s != t:
		for i in range(0, len(s)):
			if s[i] in t:
				m += 1
		if m > 0:
			print('YES')
		else:
			print('NO')


n = int(input())
for j in range(n):
	s = input()
	t = input()
	for i in s:
		if i in t:
			print('YES')
			break
	else:
		print('NO')


for i in range(int(input())):
	f = False
	s = input()
	t = input()
	s1 = set(list(s))
	t1 = set(list(t))
	for j in s1:
		if j in t1:
			print('YES')
			f = True
			break
	if not f:
		print('NO')


q = int(input())
i = 0
m = [0] * q
p = 0
for i in range(q):
	p = 0
	s = list(input())
	t = list(input())
	l = len(s)
	k = 0
	for k in range(l):
		if str(s[k]) in t:
			m[i] = 'YES'
			p = 1
			break
	if p == 0:
		m[i] = 'NO'
i = 0
for i in range(q):
	print(m[i])


q = int(input())
for _ in range(q):
	a = input()
	b = input()
	d = set(a)
	f = set(b)
	if len(a) != len(b):
		print('NO')
	elif d & f:
		print('YES')
	else:
		print('NO')


ch = int(input())
for i in range(ch):
	str1 = list(input())
	str1.sort()
	str2 = list(input())
	str2.sort()
	for j in str2:
		if j in str1:
			print('YES')
			break
	else:
		print('NO')


a = int(input())
for i in range(a):
	s = input()
	t = input()
	fl = 0
	for j in s:
		for m in t:
			if j == m:
				fl = 1
	if fl == 1:
		print('YES')
	else:
		print('NO')


global s, t, p
m = int(input())
for i in range(m):
	s = set(input())
	t = set(input())
	p = s & t
	print('YES' if len(p) > 0 else 'NO')


count = int(input())
k = 0
for i in range(count):
	word1 = input()
	word2 = input()
	if word1 == word2:
		print('YES')
		continue
	if len(word1) != len(word2):
		print('NO')
		continue
	if (len(word1) < 2) & (len(word2) < 2):
		print('NO')
		continue
	else:
		first = list(word1)
		second = list(word2)
		for i in range(len(word1)):
			for m in range(len(word1)):
				if first[m] == second[i]:
					k += 1
		if k >= 1:
			print('YES')
			k = 0
		else:
			print('NO')


a = int(input())
for k in range(a):
	s = input()
	t = input()
	flag = 0
	for i in range(len(s)):
		for j in range(len(s)):
			if s[i] == t[j]:
				print('YES')
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')


import os
import sys
DEBUG = 'DEBUG' in os.environ

def inp():
	return sys.stdin.readline().rstrip()

def read_int():
	return int(inp())

def read_ints():
	return [int(e) for e in inp().split()]

def dprint(*value, sep=' ', end='\n'):
	if DEBUG:
		print(*value, sep=sep, end=end)

def main():
	(s, t) = eval(2 * 'inp(),')
	ans = 'NO'
	for c in s:
		if c in t:
			ans = 'YES'
			break
	return ans
for _ in range(read_int()):
	print(main())


n = int(input())
se = set()
res = []
flag = 0
for i in range(n):
	s = input()
	t = input()
	if s == t:
		res.append('YES')
		continue
	if len(s) != len(t):
		res.append('NO')
		continue
	le = len(s)
	for j in range(len(t)):
		se.add(t[j])
	for j in range(le):
		if s[j] in se:
			res.append('YES')
			flag = True
			break
	se.clear()
	if flag:
		flag = 0
		continue
	res.append('NO')
for i in res:
	print(i)


q = int(input())
ar = []
s = []
for _ in range(q):
	s.append(input())
	s.append(input())
	ar.append(s)
	s = []
for i in ar:
	d1 = {}
	d2 = {}
	for j in i[0]:
		if j not in d1:
			d1[j] = 1
	for j in i[1]:
		if j not in d2:
			d2[j] = 1
	k = 0
	for j in d1:
		if j in d2:
			print('YES')
			break
		else:
			k += 1
	if k == len(d1):
		print('NO')
	k = 0


k = int(input())
while k > 0:
	s = input()
	t = input()
	n = 0
	for i in s:
		for j in t:
			if i == j:
				n = 1
				break
	if n == 1:
		print('yes')
	else:
		print('no')
	k -= 1


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	t = ii()
	for _ in range(t):
		print('NO' if len(set(input()) & set(input())) == 0 else 'YES')
main()


q = int(input())
for i in range(q):
	k = 0
	s = input()
	t = input()
	for i in range(len(s)):
		if s[i] in t:
			print('YES')
			k = 1
			break
	if k == 0:
		print('NO')


qo = int(input())
H = []
for i in range(0, qo):
	S = input()
	T = input()
	A = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	R = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
	for r in range(0, len(S)):
		if S[r] == 'a':
			A.insert(0, 1)
			A.pop(1)
		if S[r] == 'b':
			A.insert(1, 1)
			A.pop(2)
		if S[r] == 'c':
			A.insert(2, 1)
			A.pop(3)
		if S[r] == 'd':
			A.insert(3, 1)
			A.pop(4)
		if S[r] == 'e':
			A.insert(4, 1)
			A.pop(5)
		if S[r] == 'f':
			A.insert(5, 1)
			A.pop(6)
		if S[r] == 'g':
			A.insert(6, 1)
			A.pop(7)
		if S[r] == 'h':
			A.insert(7, 1)
			A.pop(8)
		if S[r] == 'i':
			A.insert(8, 1)
			A.pop(9)
		if S[r] == 'j':
			A.insert(9, 1)
			A.pop(10)
		if S[r] == 'k':
			A.insert(10, 1)
			A.pop(11)
		if S[r] == 'l':
			A.insert(11, 1)
			A.pop(12)
		if S[r] == 'm':
			A.insert(12, 1)
			A.pop(13)
		if S[r] == 'n':
			A.insert(13, 1)
			A.pop(14)
		if S[r] == 'o':
			A.insert(14, 1)
			A.pop(15)
		if S[r] == 'p':
			A.insert(15, 1)
			A.pop(16)
		if S[r] == 'q':
			A.insert(16, 1)
			A.pop(17)
		if S[r] == 'r':
			A.insert(17, 1)
			A.pop(18)
		if S[r] == 's':
			A.insert(18, 1)
			A.pop(19)
		if S[r] == 't':
			A.insert(19, 1)
			A.pop(20)
		if S[r] == 'u':
			A.insert(20, 1)
			A.pop(21)
		if S[r] == 'v':
			A.insert(21, 1)
			A.pop(22)
		if S[r] == 'w':
			A.insert(22, 1)
			A.pop(23)
		if S[r] == 'x':
			A.insert(23, 1)
			A.pop(24)
		if S[r] == 'y':
			A.insert(24, 1)
			A.pop(25)
		if S[r] == 'z':
			A.insert(25, 1)
			A.pop(26)
	for j in range(0, len(T)):
		if T[j] == 'a':
			R.insert(0, 1)
			R.pop(1)
		if T[j] == 'b':
			R.insert(1, 1)
			R.pop(2)
		if T[j] == 'c':
			R.insert(2, 1)
			R.pop(3)
		if T[j] == 'd':
			R.insert(3, 1)
			R.pop(4)
		if T[j] == 'e':
			R.insert(4, 1)
			R.pop(5)
		if T[j] == 'f':
			R.insert(5, 1)
			R.pop(6)
		if T[j] == 'g':
			R.insert(6, 1)
			R.pop(7)
		if T[j] == 'h':
			R.insert(7, 1)
			R.pop(8)
		if T[j] == 'i':
			R.insert(8, 1)
			R.pop(9)
		if T[j] == 'j':
			R.insert(9, 1)
			R.pop(10)
		if T[j] == 'k':
			R.insert(10, 1)
			R.pop(11)
		if T[j] == 'l':
			R.insert(11, 1)
			R.pop(12)
		if T[j] == 'm':
			R.insert(12, 1)
			R.pop(13)
		if T[j] == 'n':
			R.insert(13, 1)
			R.pop(14)
		if T[j] == 'o':
			R.insert(14, 1)
			R.pop(15)
		if T[j] == 'p':
			R.insert(15, 1)
			R.pop(16)
		if T[j] == 'q':
			R.insert(16, 1)
			R.pop(17)
		if T[j] == 'r':
			R.insert(17, 1)
			R.pop(18)
		if T[j] == 's':
			R.insert(18, 1)
			R.pop(19)
		if T[j] == 't':
			R.insert(19, 1)
			R.pop(20)
		if T[j] == 'u':
			R.insert(20, 1)
			R.pop(21)
		if T[j] == 'v':
			R.insert(21, 1)
			R.pop(22)
		if T[j] == 'w':
			R.insert(22, 1)
			R.pop(23)
		if T[j] == 'x':
			R.insert(23, 1)
			R.pop(24)
		if T[j] == 'y':
			R.insert(24, 1)
			R.pop(25)
		if T[j] == 'z':
			R.insert(25, 1)
			R.pop(26)
	u = 0
	for o in range(0, 26):
		if A[o] == 1 and R[o] == 1:
			u = 1
	if u == 0:
		H.append(0)
	else:
		H.append(1)
for q in H:
	if q == 1:
		print('YES')
	if q == 0:
		print('NO')


q = int(input())
cons = ord('a')
for j in range(q):
	s = input()
	t = input()
	masS = [0] * 34
	masT = [-1] * 34
	for i in range(len(s)):
		masS[ord(s[i]) - cons] = 1
		masT[ord(t[i]) - cons] = 1
	i = 0
	answer = 'NO'
	while i < 34:
		if masS[i] == masT[i]:
			answer = 'YES'
			i = 800
		i += 1
	print(answer)


n = int(input())

def ans(s, t):
	s_s = set(s)
	t_s = set(t)
	if len(s_s & t_s) == 0:
		return 'no'
	return 'yes'
for _ in range(n):
	s = input()
	t = input()
	print(ans(s, t))


t = int(input())
for w in range(t):
	s = list(input())
	t = list(input())
	c = 0
	for i in s:
		if i in t:
			c = 1
			print('YES')
			break
	if c == 0:
		print('NO')


t = int(input())
for i in range(t):
	a = input()
	b = input()
	s = 0
	for j in range(len(b)):
		for k in range(len(b)):
			if a[j] == b[k]:
				s = 1
				break
	if s == 1:
		print('yes')
	else:
		print('no')


t = int(input())
for _ in range(t):
	result = 'null'
	(s, n) = (input(), input())
	for i in s:
		if i in n:
			print('YES')
			result = 'ok'
			break
	if result == 'null':
		print('NO')


q = int(input())
for i in range(q):
	first = set(list(input()))
	second = set(list(input()))
	if len(first.intersection(second)) != 0:
		print('yes')
	else:
		print('no')


k = list()
s = list()
flag = True
for _ in range(int(input()) * 2):
	k.append(input())
for i in range(1, len(k), 2):
	flag = False
	for el in list(k[i]):
		if el in list(k[i - 1]):
			flag = True
			break
	if flag:
		s.append('YES')
	else:
		s.append('NO')
print(*s, sep='\n')


t = int(input())
for _ in range(t):
	a = input()
	b = input()
	ma = dict()
	mb = 0
	for i in a:
		ma[i] = 1
	for i in b:
		if i in ma:
			mb = 1
			break
	if mb == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
result = []

def f1(mnos, mnot):
	for i in mnos:
		if i in mnot:
			return 'YES'
	return 'NO'
for i in range(n):
	mnos = set()
	mnot = set()
	s = input()
	t = input()
	for i in range(len(s)):
		mnos.add(s[i])
		mnot.add(t[i])
	result.append(f1(mnos, mnot))
for i in range(n):
	print(result[i])


n = int(input())

def check(str1, str2):
	check = True
	for item in str1:
		if item in str2:
			return 'YES'
	return 'NO'
for iter in range(n):
	str1 = input()
	str2 = input()
	print(check(str1, str2))


t = int(input())
for k in range(t):
	s1 = set(input())
	s2 = set(input())
	if len(s1 & s2) == 0:
		print('NO')
	else:
		print('YES')


for nt in range(int(input())):
	a = input()
	b = input()
	a = set(list(a))
	b = set(list(b))
	flag = 0
	for i in a:
		if i in b:
			flag = 1
			break
	for i in b:
		if i in a:
			flag = 1
			break
	if not flag:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	s = list(input())
	t = list(input())
	for i in s:
		try:
			t.remove(i)
			n = True
			break
		except:
			n = False
	if n:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	t = input()
	can = False
	for c in s:
		if t.count(c) != 0:
			can = True
			break
	print('YES' if can else 'NO')


num = int(input())
s = []
for i in range(num):
	sk1 = {}
	sk2 = {}
	f = 0
	line1 = input()
	line2 = input()
	for i in line1:
		sk1[i] = line1.count(i)
	for i in line2:
		sk2[i] = line2.count(i)
	for i in sk1:
		if i in sk2:
			f = 1
	if f == 1:
		s.append('YES')
	else:
		s.append('NO')
for i in s:
	print(i)


try:
	n = int(input())
	while n:
		s = input()
		t = input()
		s = list(s)
		t = list(t)
		s = set(s)
		t = set(t)
		s = s.intersection(t)
		if len(s) != 0:
			print('yes')
		else:
			print('NO')
		n -= 1
except:
	pass


for i in range(int(input())):
	(s, t) = [input() for j in range(2)]
	sx = {letter for letter in s}
	tx = {letter for letter in t}
	print('NO' if sx.isdisjoint(tx) else 'YES')


q = int(input())
for i in range(q):
	first = set(input())
	second = set(input())
	if first.intersection(second):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input()
	t = input()
	k = 0
	for i in s:
		for j in t:
			if i == j:
				print('YES')
				k = 1
				break
		if k == 1:
			break
	if k == 0:
		print('NO')


def maybe(s1, s2):
	A = list(s1)
	for i in range(len(A)):
		if A[i] in s2:
			return 'Yes'
	return 'No'
q = int(input())
Ans = []
for i in range(q):
	s1 = str(input())
	s2 = str(input())
	Ans.append(maybe(s1, s2))
for i in range(len(Ans)):
	print(Ans[i])


import array, bisect, collections, copy, fractions, functools, heapq, itertools, math, random, re, string, sys, time, os, timeit
sys.setrecursionlimit(10000000)
inf = float('inf')

def li():
	return [int(x) for x in sys.stdin.readline().split()]

def li_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def lf():
	return [float(x) for x in sys.stdin.readline().split()]

def ls():
	return sys.stdin.readline().split()

def int_inp():
	return int(sys.stdin.readline())

def float_inp():
	return float(sys.stdin.readline())

def inp():
	return sys.stdin.readline().strip()

def pf(s):
	return print(s, flush=True)

def main():
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
	q = int_inp()
	ans = []
	for _ in range(q):
		x1 = inp()
		x2 = inp()
		if set(x1) & set(x2):
			ans.append('YES')
		else:
			ans.append('NO')
	if os.path.exists('output.txt'):
		sys.stdout = open('output.txt', 'w')
	print('\n'.join(ans))
main()


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
n = int(input())
for i in range(n):
	s = input().strip()
	t = input().strip()
	a = set([])
	b = set([])
	for j in s:
		a.add(j)
	for j in t:
		b.add(j)
	if a.intersection(b):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = set(list(input()))
	t = set(list(input()))
	if len(s & t) == 0:
		print('No')
	else:
		print('Yes')


q = int(input())
while q != 0:
	q = q - 1
	m = []
	n = []
	a = input()
	for i in range(len(a)):
		m.append(a[i])
	b = input()
	for i in range(len(b)):
		n.append(b[i])
	m = set(m)
	n = set(n)
	k = m.isdisjoint(n)
	if k == False:
		print('yes')
	else:
		print('no')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	m1 = [i for i in s]
	m2 = [i for i in t]
	m3 = m1 + m2
	f = True
	for i in m3:
		if i in m1 and i in m2:
			print('YES')
			f = False
			break
	if f:
		print('NO')


for i in range(int(input())):
	s = set([j for j in input().strip()])
	t = set([j for j in input().strip()])
	print('YES' if s.intersection(t) else 'NO')


q = int(input())
for i in range(q):
	s1 = list(input())
	s2 = list(input())
	f = False
	for el in s1:
		if el in s2:
			f = True
			break
	if f:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	st1 = input()
	st2 = input()
	length1 = len(st1)
	length2 = len(st2)
	if length1 == length2:
		sta = set(st1)
		stb = set(st2)
		stc = sta.intersection(stb)
		print('YES' if len(stc) != 0 else 'NO')


n = int(input())
for _ in range(n):
	(a, b) = (input(), input())
	flag = True
	for i in range(len(a)):
		if a[i] in b:
			print('YES')
			flag = False
			break
	if flag:
		print('NO')


for quests in range(int(input())):
	str1 = input()
	str2 = input()
	set1 = set(str1)
	set2 = set(str2)
	if len(set1 & set2) != 0:
		print('YES')
	else:
		print('NO')


s = 'abcdefghijklmnopqrstuvwxyz'
Q = int(input())
for q in range(Q):
	s1 = input()
	s2 = input()
	if len(s1) != len(s2):
		print('NO')
		continue
	flag = False
	for i in s:
		if i in s1 and i in s2:
			print('YES')
			flag = True
			break
	if not flag:
		print('NO')


n = int(input())
for i in range(n):
	line1 = list(input())
	line2 = list(input())
	flag = False
	for el in line1:
		if el in line2:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	pr = 0
	for j in t:
		if j not in s:
			pr = 0
		else:
			pr = 1
			break
	if pr == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	s = str(input())
	s1 = str(input())
	flag = 0
	for j in range(0, len(s)):
		if s[j] in s1:
			flag = 1
	if flag == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	a = [0] * 26
	s = input()
	res = False
	for x in s:
		a[ord(x) - 97] = 1
	t = input()
	for x in t:
		a[ord(x) - 97] &= 1
		if a[ord(x) - 97]:
			res = True
			break
	print('YNEOS'[not res::2])


for _ in range(int(input())):
	(s, t) = map(lambda _: input(), range(2))
	if len(set(s) & set(t)) == 0:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	line1 = [j for j in input()]
	line2 = [i for i in input()]
	line1set = set(line1)
	line2set = set(line2)
	if len(line1set & line2set) == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
a = []
b = []
for i in range(n):
	isTrue = False
	a.append(list(set(list(input()))))
	a.append(list(set(list(input()))))
	for i in a[0]:
		if i in a[1]:
			isTrue = True
			break
	if isTrue:
		b.append('YES')
	else:
		b.append('NO')
	a = []
for i in b:
	print(i)


a = int(input())
for i in range(a):
	s = input()
	t = input()
	for g in s:
		if g in t:
			print('YES')
			break
	else:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	a1 = set()
	buff = []
	for i in range(len(a)):
		if not a[i] in a1:
			a1.add(a[i])
			buff.append(a[i])
	b = input()
	b1 = set()
	for i in range(len(b)):
		if not b[i] in b1:
			b1.add(b[i])
	for elem in buff:
		if elem in a1 and elem in b1:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
m = []
for i in range(n):
	s = input()
	t = input()
	a = len(s)
	b = len(t)
	if a > b:
		for x in t:
			y = 0
			while y < a and s[y] != x:
				y += 1
			if y != a:
				break
		if y != a:
			m = m + ['yes']
		else:
			m = m + ['no']
	else:
		for x in s:
			y = 0
			while y < b and t[y] != x:
				y += 1
			if y != b:
				break
		if y != b:
			m = m + ['yes']
		else:
			m = m + ['no']
for i in m:
	print(i)


q = int(input())
for w in range(q):
	if set(input()) & set(input()):
		print('yes')
	else:
		print('no')


q = int(input())
ans = []
for i in range(q):
	s = input()
	t = input()
	for j in range(len(s)):
		flag = False
		for k in range(len(t)):
			if s[j] == t[k]:
				a = 'YES'
				flag = True
				break
			else:
				a = 'NO'
		if flag == True:
			break
	ans.append(a)
for i in range(len(ans)):
	print(ans[i])


i = int(input())
for i in range(i):
	d = 0
	x = str(input())
	y = str(input())
	for j in x:
		for k in y:
			if k == j:
				d = 1
				break
		if d == 1:
			break
	if d == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
L = []
for i in range(n):
	FG = False
	s = input()
	t = input()
	for i in s:
		if i in t:
			FG = True
			break
	if FG:
		L.append('YES')
	else:
		L.append('NO')
for i in L:
	print(i)


n = int(input())
for i in range(n):
	s = input()
	t = input()
	s1 = set(s)
	s2 = set(t)
	s3 = s1.intersection(s2)
	if len(s) != len(t) or len(s3) == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	(s1, s2) = (set(input()), set(input()))
	ck = True
	for c in s2:
		if c in s1:
			ck = False
			break
	print('YNEOS'[ck::2])


for _ in range(int(input())):
	s = input()
	t = input()
	a = set(list(s))
	b = set(list(t))
	print('YES' if len(a & b) > 0 else 'NO')


q = int(input())
for _ in range(q):
	s = set(list(input()))
	t = set(list(input()))
	if s & t:
		print('yes')
	else:
		print('no')


q = int(input())
for i in range(0, q):
	s = input()
	t = input()
	if len(s) != len(t):
		print('NO')
	else:
		shet = 0
		for j in range(0, len(s)):
			if t.find(s[j]) > -1:
				print('YES')
				shet = 1
				break
		if shet == 0:
			print('NO')


a = int(input())
b = []
for i in range(a * 2):
	b.append(input())
f = []
for i in range(0, len(b), 2):
	f.append([set([j for j in b[i]]), set([j for j in b[i + 1]])])
for i in range(len(f)):
	if f[i][0] & f[i][1]:
		f[i] = 'YES'
	else:
		f[i] = 'NO'
for i in f:
	print(i + '\n')


for t in range(int(input())):
	a = input()
	b = input()
	for i in a:
		if i in b:
			print('YES')
			break
	else:
		print('NO')


a = int(input())
k = []
for i in range(a):
	b = list(''.join(input()))
	c = list(''.join(input()))
	result = list(set(b) & set(c))
	if len(result) == 0:
		k.append('No')
	else:
		k.append('Yes')
for i in range(len(k)):
	print(k[i])


for _ in range(int(input())):
	a = set(input())
	b = set(input())
	for i in a:
		if i in b:
			print('YES')
			a = {}
			break
	if a != {}:
		print('NO')


a = int(input())
for i in range(a):
	word1 = input()
	word2 = input()
	if word1 != word2:
		for i in word1:
			if i in word2:
				print('YES')
				break
		else:
			print('NO')
	else:
		print('YES')


def f():
	(s, t) = (input(), input())
	for i in 'qwertyuiopasdfghjklzxcvbnm':
		if i in s and i in t:
			print('YES')
			return
	print('NO')
q = int(input())
for _ in range(q):
	f()


q = int(input())
for _ in range(q):
	s = input()
	t = input()
	f = False
	for i in s:
		if t.count(i) != 0:
			print('YES')
			f = True
			break
	if not f:
		print('NO')


q = int(input())
for i in range(q):
	ans = False
	s1 = input()
	s2 = input()
	t1 = set(list(s1))
	t2 = set(list(s2))
	for j in t1:
		if j in t2:
			ans = True
			break
	if not ans:
		for k in t2:
			if k in t1:
				ans = True
				break
	if ans:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = list(input())
	t = list(input())
	flag = 1
	for ch in s:
		if ch in t:
			flag = 0
			break
	if flag:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	s1 = input()
	s2 = input()
	for j in range(len(s1)):
		for k in range(len(s1)):
			if s1[j] == s2[k]:
				print('YES')
				break
		if s1[j] == s2[k]:
			break
	else:
		print('NO')


for i in range(int(input())):
	a = input()
	b = input()
	aa = []
	cnt = 0
	for j in a:
		aa.append(j)
	for j in b:
		if j in aa:
			print('Yes')
			cnt = 1
			break
	if not cnt:
		print('No')


q = int(input())
L = []
c = False
for i in range(q):
	a = input()
	b = input()
	for j in a:
		if j in b:
			c = True
	if c:
		L.append('YES')
	else:
		L.append('NO')
	c = False
for i in L:
	print(i)


q = int(input())
for qq in range(q):
	s1 = input()
	s2 = input()
	for i in s1:
		if i in s2:
			print('YES')
			break
	else:
		print('NO')


for _ in ' ' * int(input()):
	(s, t) = (set(input()), set(input()))
	print('YNEOS'[all((not x in set(t) for x in set(s)))::2])


i = int(input())
count = 1
while count <= i:
	inputstr1 = input()
	inputstr2 = input()
	count2 = 0
	while count2 < len(inputstr1):
		if inputstr2.find(inputstr1[count2]) != -1:
			print('YES')
			break
		elif count2 == len(inputstr1) - 1:
			print('NO')
			break
		count2 += 1
	count += 1


n = int(input())
t = []
d = 0
for i in range(n):
	a = input()
	b = input()
	a = a.lower()
	b = b.lower()
	if a == b:
		print('YES')
	else:
		f = False
		for i in range(len(a)):
			if a[i] in b:
				f = True
				break
		if f == True:
			print('YES')
		else:
			print('NO')


n = int(input())
string = []
for _ in range(2 * n):
	string.append(input().strip())
for idx in range(0, 2 * n, 2):
	dct = {}
	s = string[idx]
	for ch in s:
		dct[ch] = 1
	t = string[idx + 1]
	flag = 1
	for ch in t:
		if dct.get(ch, 0):
			print('YES')
			flag = 0
			break
	if flag:
		print('NO')


for _ in range(int(input())):
	s = set(input())
	t = set(input())
	print('yes' if len(s & t) > 0 else 'no')


def f(s, t):
	for i in range(len(t)):
		if t[i] in s:
			return True
			break
	else:
		return False
q = int(input())
for i in range(q):
	s = input()
	t = input()
	if f(s, t):
		print('yes')
	else:
		print('no')


n = int(input())
for i in range(n):
	str_a = set(input())
	str_b = set(input())
	if str_a.intersection(str_b):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	t = input()
	m = [0] * 26
	for j in range(len(s)):
		m[ord(s[j]) - ord('a')] = 1
	for j in range(len(t)):
		if m[ord(t[j]) - ord('a')] == 1:
			print('yes')
			break
	else:
		print('no')


q = int(input())
for i in range(q):
	s = list(input())
	t = list(input())
	if len(s) != len(t):
		print('NO')
		continue
	tmp1 = list(set(s))
	tmp2 = list(set(t))
	for i in tmp1:
		if i in tmp2:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = set(input())
	t = set(input())
	if len(s.intersection(t)) == 0:
		print('no')
	else:
		print('yes')


q = int(input())
ans = []
for i in range(q):
	k = 0
	s = input()
	t = input()
	for j in t:
		if j in s:
			ans.append('YES')
			k = 1
			break
	if k == 0:
		for j in s:
			if j in t:
				ans.append('YES')
				k = 1
				break
	if k == 0:
		ans.append('NO')
for i in ans:
	print(i)


t = int(input())
res = []
for i in range(t):
	s = input()
	t = input()
	f = 0
	for i in range(len(s)):
		for j in range(len(t)):
			if s[i] == t[j]:
				res.append('YES')
				f = 1
				break
		if f == 1:
			break
	if f == 0:
		res.append('NO')
for i in res:
	print(i)


for i in range(int(input())):
	a = set(map(str, input()))
	b = set(map(str, input()))
	x = a.intersection(b)
	if len(x) >= 1:
		print('Yes')
	else:
		print('No')


q = int(input())
str1 = str2 = str()
for i in range(q):
	str1 = input()
	str2 = input()
	ifPossible = False
	for i in str1:
		if str2.count(i) != 0:
			print('Yes')
			ifPossible = True
			break
	if not ifPossible:
		print('No')


n = int(input())
for i in range(n):
	s = input()
	t = input()
	n = len(s)
	c = 0
	for i in range(n):
		for j in range(n):
			if s[i] == t[j]:
				c += 1
	if c == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
set1 = []
set2 = []
for _ in range(q):
	s1 = input()
	s2 = input()
	flag = False
	for i in range(len(s1)):
		if not flag:
			if s1[i] in s2:
				print('YES')
				flag = True
	if not flag:
		print('NO')


import sys as _sys

def main():
	q = int(input())
	for i_q in range(q):
		s = _read_line()
		t = _read_line()
		output = 'YES' if can_make_equal(s, t) else 'NO'
		print(output)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split(' '))

def can_make_equal(s, t):
	return len(set(s) & set(t)) > 0
main()


n = int(input())
s = ''
t = ''
ans = []
for i in range(n):
	s = str(input())
	t = str(input())
	an = 'NO'
	ss = [char for char in s]
	for char in t:
		for charr in ss:
			if char == charr:
				an = 'YES'
				break
	ans.append(an)
print(*ans, sep='\n')


n = int(input())
for x in range(n):
	per = input()
	naxui = input()
	if per == naxui:
		print('YES')
	elif len(per) != len(naxui):
		print('NO')
	else:
		a = 0
		for z in range(len(per)):
			if per[z] in naxui:
				print('YES')
				a = 1
				break
		if a == 0:
			print('NO')


q = int(input())
for i in range(0, q):
	st = str(input())
	t = str(input())
	ok = 0
	for j in range(0, len(st)):
		if st[j] in t:
			print('YES')
			ok = 1
			break
	if ok == 0:
		print('NO')


try:
	import math
	t = int(input())
	for i in range(0, t):
		s = input()
		t = input()
		s = list(s)
		t = list(t)
		s = set(s)
		t = set(t)
		y = s.intersection(t)
		if len(y) == 0:
			print('NO')
		else:
			print('YES')
except:
	pass


n = int(input())
p = [[input(), input()] for i in range(n)]
yn = True
for i in p:
	k = set(i[0]) & set(i[1])
	if len(k) != 0:
		print('YES')
	else:
		print('NO')


q = int(input())
for _ in range(q):
	a = input()
	b = input()
	final = 'NO'
	for i in a:
		if i in b:
			final = 'YES'
			break
	print(final)


n = int(input())
spicok = []
k = 0
for i in range(0, 2 * n):
	stroka = input()
	spicok = spicok + [stroka]
for j in range(0, 2 * n, 2):
	stroka1 = spicok[j]
	stroka2 = spicok[j + 1]
	for i in range(0, len(stroka1)):
		if stroka1[i] in stroka2:
			k += 1
	if k != 0:
		print('YES')
	else:
		print('NO')
	k = 0


q = int(input())
for i in range(q):
	s1 = set(input())
	s2 = set(input())
	if set.intersection(s1, s2) == set():
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	s1 = input()
	s2 = input()
	if len(s1) != len(s2):
		print('NO')
	else:
		flag = True
		for j in range(len(s1)):
			if s1[j] in s2:
				print('YES')
				flag = False
				break
		if flag:
			print('NO')


import sys
import math
from math import ceil
import bisect

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def finput():
	return float(input())

def tinput():
	return input().split()

def rinput():
	return map(float, tinput())

def rlinput():
	return list(rinput())

def sli():
	return set(list(input()))

def modst(a, s):
	res = 1
	while s:
		if s % 2:
			res *= a
		a *= a
		s //= 2
	return res

def pro(x):
	if x < 37:
		return (x - 1) // 4
	else:
		return 8 - (x - 37) // 2

def main():
	q = sli()
	w = sli()
	flag = False
	for i in q:
		if i in w:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')
for i in range(iinput()):
	main()


col_par = int(input())
otveti = []
for i in range(col_par):
	first_str = input()
	second_str = input()
	dl_s = len(first_str)
	I = 0
	Otvet = 'NO'
	while I != dl_s:
		if first_str[I] in second_str:
			Otvet = 'YES'
		I += 1
	otveti.append(Otvet)
for i in range(col_par):
	print(otveti[i])


q = int(input())
summ = 0
for i in range(q):
	s = input()
	t = input()
	summ = 0
	for i in range(len(s)):
		if s.count(t[i]) > 0:
			summ += 1
	if summ > 0:
		print('YES')
	else:
		print('NO')


lon = int(input())
rez = []
rezult = ''
for i in range(lon):
	s = input()
	t = input()
	n = len(s)
	ans = 'NO'
	for j in range(n):
		if t.find(s[j]) >= 0:
			ans = 'YES'
	rezult = rezult + ans + ' '
rezult = rezult.split()
for i in range(lon):
	print(rezult[i])


for i in range(int(input())):
	s1 = set(input())
	s2 = set(input())
	if len(s1 & s2) > 0:
		print('YES')
	else:
		print('NO')


q = int(input())
out = []
for i in range(q):
	s = input()
	t = input()
	a = {}
	b = {}
	for j in range(len(s)):
		a[s[j]] = 1
		b[t[j]] = 1
	ans = False
	for key in a.keys():
		if key in b.keys():
			ans = True
			break
	if ans:
		out.append('YES')
	else:
		out.append('NO')
for i in range(q):
	print(out[i])


q = int(input())

def answer(word1, word2):
	flag = False
	if len(word1) == len(word2):
		for i in range(len(word1)):
			if word2[i] in word1:
				return 'Yes'
		return 'No'
	else:
		return 'NO'
for i in range(q):
	print(answer(input(), input()))


q = int(input())
for _ in range(q):
	s = input()
	t = input()
	flag = 0
	for i in range(len(s)):
		if s[i] in t:
			flag += 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')


a = int(input())
l = 0
b = []
for i in range(a):
	b1 = input()
	b2 = input()
	for j in range(len(b1)):
		for z in range(len(b1)):
			if b1[j] == b2[z]:
				l += 1
	if l > 0:
		b.append('YES')
	else:
		b.append('NO')
	l = 0
for i in b:
	print(i)


for i in range(int(input())):
	a = input()
	b = input()
	f = 0
	for i in a:
		if i in b:
			print('YES')
			f = 1
			break
	if f == 0:
		print('NO')


print('\n'.join([['NO', 'YES'][min(len(set(input()) & set(input())), 1)] for _ in range(int(input()))]))


q = int(input())
for i in range(q):
	s = input()
	t = input()
	flag = False
	for elem1 in s:
		for elem2 in t:
			if elem1 == elem2:
				flag = True
	print('YES' if flag else 'NO')


n = int(input())
for i in range(n):
	a = str(input())
	b = str(input())
	S = 0
	for i in range(len(a)):
		if not a[i] in b:
			S += 1
	if S == len(a):
		print('NO')
	else:
		print('YES')


q = int(input())
ans = []
for i in range(q):
	s = input()
	t = input()
	if s == t:
		ans.append('YES')
	elif set(list(s)).intersection(set(list(t))):
		ans.append('YES')
	else:
		ans.append('NO')
for i in range(q):
	print(ans[i])


cases = []
for i in range(int(input())):
	cases.append([input(), input()])
for i in cases:
	var = False
	for v in range(len(i[0])):
		if i[1][v] in i[0] or i[0][v] in i[1]:
			var = True
	if var:
		print('Yes')
	else:
		print('No')


for t in range(int(input())):
	s1 = list(input())
	s2 = list(input())
	count = 0
	set1 = set(s1)
	set2 = set(s2)
	ans = set1.intersection(s2)
	if len(ans) > 0:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = list(input())
	t = list(input())
	if len(set(t).intersection(set(s))) >= 1:
		print('YES')
	else:
		print('NO')


q = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
t = int(input())
p = []
for nf in range(0, t):
	s = input()
	m = input()
	for i in q:
		if i in s and i in m:
			p.append('YES')
			break
	if len(p) != nf + 1:
		p.append('NO')
for i in p:
	print(i)


for _ in range(int(input())):
	(s, t) = (input(), input())
	k = 'NO'
	for i in s:
		if i in t:
			k = 'YES'
			break
	print(k)


def solve(a, b):
	if len(a) > len(b):
		(a, b) = (b, a)
	for i in a:
		if i in b:
			print('YES')
			return
	print('NO')
	return
reqs = int(input())
for i in range(reqs):
	a = input()
	b = input()
	solve(a, b)


for _ in range(int(input())):
	s1 = input()
	s2 = input()
	s3 = set()
	for i in s1:
		s3.add(i)
	s4 = set()
	for i in s2:
		s4.add(i)
	f = 0
	for i in s3:
		if i in s4:
			f = 1
	for i in s4:
		if i in s3:
			f = 1
	if f:
		print('yes')
	else:
		print('no')


q = int(input())
for i in range(q):
	bull = False
	s = list(input())
	t = list(input())
	for j in range(len(s)):
		if s[j] in t:
			print('YES')
			bull = True
			break
	if bull is False:
		print('NO')


def main():
	n = int(input())
	for i in range(n):
		s = set(str(input()))
		s1 = set(str(input()))
		if len(s - s1) < len(s):
			print('YES')
		else:
			print('NO')
main()


for _ in range(int(input())):
	a = list(input())
	b = input()
	Flag = False
	for w in a:
		if w in b:
			Flag = True
	if Flag:
		print('yes')
	else:
		print('no')


for i in range(0, int(input())):
	s = input()
	t = input()
	for l in 'abcdefghijklmnopqrstuvwxyz':
		if l in s and l in t:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	t = input()
	if len(s) != len(t):
		print('NO')
	elif s == t:
		print('YES')
	else:
		flag = 0
		for i in range(len(s)):
			if t.count(s[i]) >= 1:
				flag = 1
				break
		if flag == 1:
			print('YES')
		else:
			print('NO')


q = int(input())
d = [0 for i in range(26)]
d1 = [0 for i in range(26)]
for i in range(q):
	a = input()
	b = input()
	for j in range(26):
		d[j] = 0
		d1[j] = 0
	for j in range(len(a)):
		d[ord(a[j]) - ord('a')] = 1
		d1[ord(b[j]) - ord('a')] = 1
	ok = False
	for j in range(26):
		if d[j] + d1[j] == 2:
			ok = True
	if ok:
		print('YES')
	else:
		print('NO')


q = int(input())
result = []
for i in range(q):
	s = input()
	t = input()
	if len(set(s) & set(t)) == 0:
		result.append('NO')
	else:
		result.append('YES')
for i in result:
	print(i)


q = int(input())
a = []
for i in range(q):
	s1 = str(input())
	s2 = str(input())
	k = 0
	for i in range(len(s1)):
		if s2.find(s1[i]) != -1:
			k += 1
	if k > 0:
		a.append('YES')
	else:
		a.append('NO')
for i in range(q):
	print(a[i])


t = int(input())
for i in range(t):
	a = input()
	b = input()
	f = 0
	for j in a:
		if j in b:
			f = 1
	if f:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	m1 = set(list(input()))
	m2 = set(list(input()))
	f = 'NO'
	for el in m1:
		if el in m2:
			f = 'YES'
	print(f)


for _ in range(int(input())):
	s = input()
	t = input()
	ans = 0
	if len(s) < len(t):
		(s, t) = (t, s)
	for a in s:
		if a in t:
			ans = 1
	if ans:
		print('YES')
	else:
		print('NO')


def test():
	st1 = list(input())
	st2 = list(input())
	for i in range(len(st1)):
		for j in range(len(st2)):
			if st1[i] == st2[j]:
				print('YES')
				return
	print('NO')
n = int(input())
for i in range(n):
	test()


q = int(input())
for i in range(q):
	a = input()
	e = input()
	if set(a) & set(e):
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = set(input())
	t = set(input())
	print('Yes' if s & t else 'No')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	a = [0] * 26
	for i in range(len(s)):
		a[ord(s[i]) - ord('a')] += 1
	ans = False
	for i in range(len(t)):
		if a[ord(t[i]) - ord('a')] > 0:
			ans = True
	if ans:
		print('YES')
	else:
		print('NO')


i = input
for _ in [0] * int(i()):
	print('YNEOS'[{*i()} & {*i()} < {1}::2])


n = int(input())
for i in range(n):
	s = list(input())
	t = list(input())
	if len(s) == len(t):
		s1 = set(s)
		t1 = set(t)
		b = False
		for el1 in s1:
			if el1 in t1:
				b = True
				break
		if b:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


def ltd(lst):
	retDict = {}
	for i in lst:
		retDict[i] = 1
	return retDict

def f(s, t):
	s = ltd(s)
	t = ltd(t)
	for (k, v) in s.items():
		try:
			if v == 1 and t[k] == 1:
				return 'YES'
		except:
			pass
	return 'NO'
q = int(input())
resAr = []
for i in range(q):
	s = list(input())
	t = list(input())
	resAr.append(f(s, t))
for el in resAr:
	print(el)


cases = int(input())
for _ in range(cases):
	a = input()
	b = input()
	if len(set(a) & set(b)) == 0:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = input()
	b = input()
	coincidences = 0
	for letter in a:
		if letter in b:
			coincidences += 1
	if coincidences >= 1:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	s1 = str(input())
	s2 = str(input())
	r = 'NO'
	for k in s1:
		if s2.count(k):
			r = 'YES'
	print(r)


def get_ans(s, t, lngth):
	sm = [0 for i in range(lngth)]
	tm = [0 for i in range(lngth)]
	for i in range(lngth):
		if s[i] in t:
			return 'YES'
	return 'NO'
q = int(input())
anss = []
for it in range(q):
	s = input()
	t = input()
	lngth = len(s)
	anss.append(get_ans(s, t, lngth))
for i in anss:
	print(i)


for _ in range(int(input())):
	s = input()
	t = input()
	tru = 0
	for i in s:
		if i in t:
			tru = 1
			break
	if tru:
		print('YES')
	else:
		print('NO')


q = int(input())
possible = []
for i in range(q):
	s = input()
	t = input()
	p = 0
	for k in range(len(s)):
		for l in range(len(t)):
			if s[k] == t[l]:
				p = 1
	possible.append(p)
for i in range(len(possible)):
	if possible[i] == 1:
		print('YES')
	else:
		print('NO')


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_charList_from_str = lambda : list(sys.stdin.readline().strip())
get_char_list = lambda : sys.stdin.readline().strip().split()
get_int = lambda : int(sys.stdin.readline())
pt = lambda x: sys.stdout.write(str(x))

def removeall_replace(element, lst):
	t = [y for y in lst if y != element]
	del lst[:]
	lst.extend(t)
for _ in range(get_int()):
	s = get_string()
	t = get_string()
	flag = False
	for i in range(len(s)):
		for j in range(len(t)):
			if s[i] in t:
				flag = True
				break
		if flag:
			break
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
i = 0
pset = set()
while i < q:
	s = str(input())
	t = str(input())
	if s == t:
		print('YES')
	else:
		l1 = set(s)
		l2 = set(t)
		lu = l1.intersection(l2)
		if lu != pset:
			print('YES')
		else:
			print('NO')
	i += 1


q = int(input())

def check(s, t):
	s = s.rstrip()
	t = t.rstrip()
	for x in s:
		if t.find(x) != -1:
			print('YES')
			return
	print('NO')
for _ in range(0, q):
	s = input()
	t = input()
	check(s, t)


q = int(input())
for items in range(q):
	s = input()
	t = input()
	match = False
	for i in range(len(s)):
		for j in range(len(t)):
			if t[j] == s[i]:
				match = True
				break
		if match == True:
			break
	if match:
		print('Yes')
	else:
		print('No')


q = int(input())
queue = []
for _ in range(q):
	s = input()
	f = input()
	a = set(list(s))
	b = set(list(f))
	if s == f:
		queue.append('YES')
	elif len(a & b) > 0:
		queue.append('YES')
	else:
		queue.append('NO')
for i in queue:
	print(i)


for _ in range(int(input())):
	t = sorted(set(input()))
	q = sorted(set(input()))
	for x in t:
		if x in q:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	t = input()
	if len(s) == len(t):
		d = {}
		for i in s:
			if i not in d:
				d[i] = 1
		tag = True
		for i in t:
			if i in d:
				print('YES')
				tag = False
				break
		if tag:
			print('NO')
	else:
		print('NO')


t_c = int(input())
for a in range(0, t_c):
	flag = False
	s = input()
	t = input()
	for i in s:
		if i in t:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


n = int(input())
q = []
for i in range(n):
	s = input()
	t = input()
	q1 = False
	for a in s:
		for b in t:
			if a == b:
				q1 = True
	q.append(q1)
for i in q:
	if i:
		print('YES')
	else:
		print('NO')


K = int(input())
for k in range(0, K):
	str1 = set(list(input()))
	str2 = set(list(input()))
	str3 = str1.intersection(str2)
	if len(str3) == 0:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(0, n):
	l = input()
	r = input()
	if set(l) & set(r) == set():
		print('NO')
	else:
		print('YES')


def make(a, b):
	x = set()
	y = set()
	for i in range(len(a)):
		x.add(a[i])
		y.add(b[i])
	return 'YES' if x & y != set() else 'NO'
for i in range(int(input())):
	a = input()
	b = input()
	print(make(a, b))


def a(s, arr):
	for i in s:
		arr[ord(i) - ord('a')] += 1
	return arr
n = int(input())
for i in range(n):
	arr1 = [0] * 26
	arr2 = [0] * 26
	s1 = input()
	s2 = input()
	arr1 = a(s1, arr1)
	arr2 = a(s2, arr2)
	flag = False
	for j in range(26):
		if (arr1[j] > 0 and arr2[j]) > 0:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')


q = int(input())
answ = []
for i in range(q):
	s = input()
	t = input()
	a = False
	for l in s:
		if t.find(l) != -1:
			a = True
			break
	if a:
		answ.append('YES')
	else:
		answ.append('NO')
for a in answ:
	print(a)


def check_string(s, t):
	size = len(s)
	if s == t:
		return 'YES'
	if size == 1:
		return 'NO'
	for i in range(size):
		if t.find(s[i]) != -1:
			return 'YES'
	return 'NO'
q = int(input())
ss = [None] * q
tt = [None] * q
for i in range(q):
	ss[i] = input()
	tt[i] = input()
for i in range(q):
	print(check_string(ss[i], tt[i]))


n = int(input())
for i in range(n):
	k = 0
	s = str(input())
	s1 = str(input())
	for i1 in range(len(s)):
		if s[i1] in s1:
			continue
		else:
			k = k + 1
	if k < len(s):
		print('Yes')
	else:
		print('No')


test = int(input())
while test > 0:
	test -= 1
	s = set(list(input()))
	t = set(list(input()))
	ans = s.intersection(t)
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	a = list(input())
	b = input()
	k = 'NO'
	for i in a:
		if i in b:
			k = 'YES'
	print(k)


q = int(input())
for gg in range(q):
	s = input()
	t = input()
	f = 1
	for x in s:
		if x in t:
			print('YES')
			f = 0
			break
	if f:
		print('NO')


t = int(input())
for i in range(0, t, 1):
	a = str(input())
	b = str(input())
	if len(set(a) & set(b)) == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	result = 'NO'
	arr = [False] * 1000
	for j in range(len(a)):
		arr[ord(a[j])] = True
	for j in range(len(b)):
		if arr[ord(b[j])]:
			result = 'YES'
			break
	print(result)


q = int(input())
for k in range(q):
	s = input()
	t = input()
	s1 = set(s)
	s2 = set(t)
	if s1 & s2 != set():
		print('YES')
	else:
		print('NO')


def ii():
	return int(input())

def ss():
	return [x for x in input()]

def si():
	return [int(x) for x in input().split()]

def mi():
	return map(int, input().split())
for i in range(ii()):
	a = input()
	b = input()
	key = 'NO'
	for i in a:
		if i in b:
			key = 'YES'
			break
	print(key)


q = int(input())
for i in range(q):
	w = input()
	e = input()
	chek = True
	for j in w:
		if j in e:
			chek = False
	if chek:
		print('NO')
	else:
		print('YES')


n = int(input())
for i in range(n):
	a = list(input())
	b = list(input())
	a_l = [0] * 26
	b_l = [0] * 26
	for j in range(len(a)):
		a_l[ord(a[j]) - 97] = 1
		b_l[ord(b[j]) - 97] = 1
	answ = 'NO'
	for j in range(len(a_l)):
		if a_l[j] == 1 and b_l[j] == 1:
			answ = 'YES'
	print(answ)


q = int(input())
for _ in range(q):
	s1 = input()
	st1 = set(s1)
	s2 = input()
	st2 = set(s2)
	z = False
	for i in st1:
		if i in st2:
			z = True
	print('YES' if z else 'NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	a = set()
	for i in s:
		a.add(i)
	for i in t:
		if i in a:
			print('YES')
			break
	else:
		print('NO')


q = int(input())

def yes_or_no(s, t):
	for i in s:
		if i in t:
			return 'YES'
	return 'NO'
for _ in range(q):
	s = input()
	t = input()
	print(yes_or_no(s, t))


from __future__ import division, print_function
from collections import *
from math import *
from itertools import *
from time import time
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	s = list(input())
	t = list(input())
	if ''.join(s) == ''.join(t):
		print('YES')
		return
	ss = set(s)
	st = set(t)
	for i in ss:
		if i in st:
			print('YES')
			return
	print('NO')
	return
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
while t:
	main()
	t -= 1


q = int(input())
for i in range(q):
	s = input()
	t = input()
	chars = [False] * 26
	for c in s:
		p = ord(c) - ord('a')
		if not chars[p]:
			chars[p] = True
	haveSame = False
	for c in t:
		p = ord(c) - ord('a')
		if chars[p]:
			haveSame = True
			break
	print('YES' if haveSame else 'NO')


k = int(input())
for i in range(k):
	a = input()
	b = input()
	for i in range(len(a)):
		if a[i] in b:
			print('YES')
			break
	else:
		print('NO')


import math
import cmath
from decimal import *
from fractions import *
for t in range(int(input())):
	print('NO' if len(set(input()) & set(input())) == 0 else 'YES')


q = int(input())
ans = []
for i in range(q):
	a = list(input())
	b = list(input())
	k = 0
	for j in a:
		if j in b:
			k += 1
	if k:
		ans.append('YES')
	else:
		ans.append('NO')
print(*ans, sep='\n')


a = int(input())
for i in range(a):
	s = input()
	t = input()
	b = set(s)
	c = set(t)
	if c.intersection(b):
		print('yes')
	else:
		print('no')


for _ in range(int(input())):
	(s1, s2, flag) = (input(), input(), 0)
	for i in range(len(s1)):
		if s1[i] in s2:
			flag = 1
			break
	print(['YES', 'NO'][flag == 0])


n = int(input())
i = 0
ans = []
while i < n:
	asd = False
	s = input()
	t = input()
	for b in s:
		if b in t:
			asd = True
	ans.append(asd)
	i += 1
for i in ans:
	print('yes' if i else 'no')


q = int(input())
t1 = []
for i in range(q):
	dicti = {z: 0 for z in 'qazxswedcvfrtgbnhyujmkilop'}
	dicti2 = {z: 0 for z in 'qazxswedcvfrtgbnhyujmkilop'}
	s = input()
	t = input()
	n = len(s)
	for i in range(n):
		dicti[s[i]] = 1
		dicti2[t[i]] = 1
	k = 'NO'
	for i in dicti:
		if dicti[i] == 1 and dicti2[i] == 1:
			k = 'YES'
			break
	t1 += [k]
for i in t1:
	print(i)


n = int(input())
ans = []
for i in range(n):
	s = input()
	t = input()
	the_same = 0
	for i in range(len(s)):
		for j in range(len(s)):
			if s[j] == t[i]:
				the_same += 1
				break
		if the_same > 0:
			ans.append('YES')
			break
	if the_same == 0:
		ans.append('NO')
for i in range(n):
	print(ans[i])


q = int(input())
s1 = []
s2 = []
for i in range(q):
	x = str(input())
	y = str(input())
	s1.append(x)
	s2.append(y)
for i in range(q):
	a = s1[i]
	b = s2[i]
	if len(a) > len(b):
		big_string = len(a)
		short_string = len(b)
	elif len(a) < len(b):
		big_string = len(b)
		short_string = len(a)
	elif len(a) == len(b):
		big_string = short_string = len(a)
	i = 0
	is_common = False
	while i < short_string:
		if a[i] in b:
			is_common = True
			break
		i += 1
	if is_common:
		print('YES')
	else:
		print('NO')


num = int(input())
for q in range(num):
	inp1 = input()
	inp2 = input()
	for i in range(len(inp1)):
		if inp1[i] in inp2:
			print('YES')
			break
	else:
		print('NO')


def solve(s, t):
	(s, t) = (set(s), set(t))
	return len(s & t) >= 1
for _ in range(int(input())):
	(s, t) = (input(), input())
	[print('YES') if solve(s, t) or solve(t, s) else print('NO')]


q = int(input())
for _ in range(q):
	s = str(input())
	t = str(input())
	if s == t:
		print('YES')
	elif len(s) == 1:
		print('NO')
	else:
		flag = False
		for char in s:
			if char in t:
				flag = True
		if flag:
			print('YES')
		else:
			print('NO')


q = int(input())
M = []
for i in range(q):
	M.append('')
	s = input()
	t = input()
	for j in range(len(s)):
		for n in range(len(t)):
			if s[j] == t[n]:
				M[i] = 'YES'
				break
		if M[i] == 'YES':
			break
		else:
			M[i] = 'NO'
for i in range(q):
	print(M[i])


n = int(input())
a = []
b = []
for i in range(n):
	s = input()
	p = input()
	for j in range(len(s)):
		c = s[j]
		bl = False
		for u in range(len(s)):
			if c == p[u]:
				print('YES')
				bl = True
				break
		if bl:
			break
	if bl:
		continue
	print('NO')


q = int(input())
answer = []
for i in range(q):
	s = input()
	t = input()
	flag = False
	for ch in s:
		if t.find(ch) != -1:
			flag = True
	if flag:
		answer.append('YES')
	else:
		answer.append('NO')
for i in answer:
	print(i)


n = int(input())
k = 0
for i in range(n):
	a = input()
	b = input()
	for i in range(len(a)):
		if a[i] in b:
			print('YES')
			k += 1
			break
	if k == 0:
		print('NO')
	k = 0


for _ in range(int(input())):
	s = input()
	t = input()
	char = []
	for i in s:
		if i not in char:
			char.append(i)
	for i in t:
		if i in char:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = set(list(input()))
	t = set(list(input()))
	flg = 0
	for i in s:
		if i in t:
			flg = 1
			break
	if flg == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for _ in range(n):
	s = input()
	t = input()
	if len(s) != len(t):
		print('NO')
	letter_s = set()
	letter_t = set()
	for letter in s:
		letter_s.add(letter)
	for letter in t:
		letter_t.add(letter)
	if letter_s.intersection(letter_t):
		print('YES')
	else:
		print('NO')


def solve(s, t):
	return bool(set(s) & set(t))

def main():
	q = int(input())
	for _ in range(q):
		s = input()
		t = input()
		print('YES' if solve(s, t) else 'NO')
main()


y = int(input())
for i in range(y):
	if set(input()) & set(input()):
		print('yes')
	else:
		print('no')


q = int(input())
for i in range(q):
	s = str(input())
	t = str(input())
	f = 'NO'
	for i in range(len(s)):
		if t.find(s[i]) != -1:
			f = 'YES'
			break
	print(f)


for i in range(int(input())):
	(s, t) = (input(), input())
	f = 1
	for j in set(s):
		if j in set(t):
			f = 0
			break
	print(['YES', 'NO'][f])


def zapr(s, t):
	for it in s:
		for item in t:
			if it == item:
				return 'YES'
	return 'NO'
q = int(input())
for i in range(q):
	print(zapr(input(), input()))


c = int(input())
for i in range(c):
	booly = False
	a = input()
	b = input()
	for i in a:
		if i in b:
			booly = True
	if booly:
		print('Yes')
	else:
		print('No')


q = int(input())
arraystr = []
i = 0
while i < q * 2:
	st = input()
	arraystr.append(st)
	i += 1
i = 0
while i < q:
	ln = len(arraystr[i * 2])
	j = 0
	while j < ln:
		k = arraystr[i * 2 + 1].find(arraystr[i * 2][j], 0, ln)
		j += 1
		if k != -1:
			print('YES')
			j = ln
	if k == -1:
		print('NO')
	i += 1


for _ in range(int(input())):
	print(['NO', 'YES'][set(input()) & set(input()) != set()])


n = int(input())
for i in range(n):
	s1 = set(input().strip())
	s2 = set(input().strip())
	flag = 0
	for i in s1:
		if i in s2:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	p = input()
	h = input()
	(q, w) = (set(p), set(h))
	if len(q & w) != 0:
		print('YES')
	else:
		print('NO')


q = int(input())
answerlist = []
for i in range(q):
	str1 = input()
	str2 = input()
	answer = 0
	for char in str1:
		for char2 in str2:
			if char == char2:
				answer = 1
	answerlist.append(answer)
for i in range(q):
	if answerlist[i] == 1:
		print('yes')
	else:
		print('no')


n = int(input())
c = []
for i in range(n):
	a = input()
	b = input()
	f = True
	m = len(a)
	for h in range(m):
		if f == True:
			for g in range(m):
				if h + 1 == m and m == g + 1 and (a[h] != b[g]):
					c.append('NO')
					f = False
					break
				elif a[h] == b[g]:
					c.append('YES')
					f = False
					break
		else:
			break
for i in c:
	print(i)


for i in range(int(input())):
	(S, T) = (set(input()), set(input()))
	print('YES' if len(list(S.intersection(T))) > 0 else 'NO')


q = int(input())
for i in range(q):
	a1 = str(input())
	a2 = str(input())
	result = True
	for i in a1:
		for j in a2:
			if i == j:
				result = False
				break
	if result:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	print(['NO', 'YES'][len({*input()} & {*input()}) >= 1])


q = int(input())
out = []
for i in range(q):
	s = set(input())
	t = set(input())
	if len(s & t) > 0:
		out.append('YES')
	else:
		out.append('NO')
print('\n'.join(out))


q = int(input())
for i in range(q):
	test = set()
	s = list(input())
	t = list(input())
	for item in s:
		test.add(item)
	for item in t:
		if item in test:
			print('YES')
			break
	else:
		print('NO')


n = int(input())
for _ in range(n):
	str1 = set(input())
	str2 = set(input())
	str1 = str1 & str2
	if len(str1) > 0:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = input()
	b = input()
	a1 = set([i for i in a])
	b1 = set([i for i in b])
	if len(a) == len(b) and len(a1 & b1) > 0:
		print('YES')
	else:
		print('NO')


i = int(input())
lot = []
for _ in range(i):
	lot.append('NO')
	s1 = input()
	s2 = input()
	for z in range(len(s1)):
		if lot[_] == 'YES':
			break
		for z2 in range(len(s2)):
			if s1[z] == s2[z2]:
				lot[_] = 'YES'
				break
for a in range(i):
	print(lot[a])


q = int(input())
for i in range(q):
	s = str(input())
	t = str(input())
	if s == t:
		print('YES')
	elif len(s) == len(t):
		ans = 0
		for j in range(len(s)):
			a = s[j]
			if t.find(a) >= 0:
				ans = 1
		if ans == 1:
			print('YES')
			ans = 0
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	s = set(input().strip())
	t = set(input().strip())
	if s & t:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	for w in a:
		z = b.find(w)
		if z != -1:
			print('YES')
			break
	else:
		print('NO')


q = int(input())
for i in range(q):
	d = 0
	s = input()
	s1 = input()
	for i in range(len(s)):
		for j in range(len(s)):
			if s[i] == s1[j]:
				d = 1
	if d == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	a = list(input())
	b = list(input())
	ans = 'NO'
	for j in range(len(a)):
		if a[j] in b:
			ans = 'YES'
	print(ans)


q = int(input())
for i in range(q):
	k = 0
	s = input()
	t = input()
	for p in range(len(s)):
		for j in range(len(s)):
			if s[p] == t[j]:
				k += 1
	if k > 0:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	s1 = input()
	s2 = input()
	b = False
	for j in s1:
		for k in s2:
			if j == k:
				b = True
				break
	if b:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	(s, t) = (input(), input())
	(set_s, set_t) = (set(), set())
	for j in range(len(s)):
		set_s.add(s[j])
	for j in range(len(t)):
		set_t.add(t[j])
	if len(set_s & set_t) == 0:
		print('NO')
	else:
		print('YES')


t = int(input())
for case in range(t):
	x = set(list(input()))
	y = set(list(input()))
	if len(x.intersection(y)) == 0:
		ans = 'NO'
	else:
		ans = 'YES'
	print(ans)


for i in range(int(input())):
	s = input()
	t = input()
	ss = set(s)
	st = set(t)
	if s == t:
		print('YES')
		continue
	if ss.isdisjoint(st):
		print('NO')
	else:
		print('YES')


for i in range(int(input())):
	print('Yes' if len(set(input()) & set(input())) else 'No')


q = int(input())
i = 0
ABC = 'qwertyuipasdfghjklzxcvbnmo'
while i < q:
	(s, t) = [input() for j in [0, 0]]
	F = False
	abc = [False] * 26
	for j in s:
		abc[ABC.find(j)] = True
	for j in t:
		if abc[ABC.find(j)]:
			F = True
			break
	if F:
		print('yes')
	else:
		print('no')
	i += 1


from collections import Counter
for _ in range(int(input())):
	(s, t) = (Counter(input()), Counter(input()))
	ans = 'NO'
	for c in s.keys():
		if c in t.keys():
			ans = 'YES'
	print(ans)


q = int(input())
for z in range(q):
	s = input()
	t = input()
	for c in s:
		if c in t:
			print('YES')
			break
	else:
		print('NO')


tc = int(input())
for i in range(0, tc):
	s = input()
	t = input()
	res = ''
	found = False
	for i in s:
		if i in t and (not i in res):
			res += i
			print('YES')
			found = True
			break
	if found == False:
		print('NO')


q = int(input())
for i in range(q):
	c = True
	s = input()
	t = input()
	for j in s:
		if j in t:
			print('YES')
			c = False
			break
	if c:
		print('NO')


n = int(input())
for i in range(n):
	a1 = input()
	a2 = input()
	a11 = list(a1)
	a12 = list(a2)
	t = 1
	for c in a12:
		if c in a11:
			print('YES')
			t = 0
			break
	if t == 1:
		print('NO')


n = int(input())
xs = []
ys = []
for i in range(n):
	x = str(input())
	y = str(input())
	xs.append(x)
	ys.append(y)
for i in range(xs.__len__()):
	if xs.__len__() >= 2:
		yes = False
		for a in xs[i]:
			for b in ys[i]:
				if a == b:
					yes = True
					break
		if yes:
			print('YES')
		else:
			print('NO')
	elif xs[i][0] == ys[i][0]:
		print('YES')
	else:
		print('NO')


n = int(input())
ans = []
for i in range(n):
	s1 = input()
	s2 = input()
	flag = 1
	for i in s1:
		if i in s2:
			flag = 0
	if flag:
		ans.append('NO')
	else:
		ans.append('YES')
for i in ans:
	print(i)


n = int(input())
for i in range(n):
	s = input()
	t = input()
	flag = False
	for c in s:
		if c in t:
			print('YES')
			flag = True
			break
	if not flag:
		print('NO')


a = int(input())
for i in range(a):
	s = input()
	t = list(input())
	for q in range(len(t)):
		d = s.find(t[q])
		if d != -1:
			print('yes')
			break
		else:
			q = q + 1
		if q == len(t):
			print('no')


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	a = list(input())
	b = list(input())
	n = len(a)
	f = 1
	for i in a:
		if i in b:
			f = 0
			print('YES')
			break
	if f == 1:
		print('NO')


t = int(input())
answer = []
for a in range(t):
	count1 = [0 for i in range(26)]
	count2 = [0 for j in range(26)]
	line1 = set(list(input()))
	line2 = set(list(input()))
	ans = False
	for j in line1:
		if j in line2:
			ans = True
			break
	if ans:
		answer.append('YES')
	else:
		answer.append('NO')
for b in answer:
	print(b)


def f():
	s1 = input()
	s2 = input()
	if set(s1) & set(s2):
		return 'YES'
	return 'NO'
for i in range(int(input())):
	print(f())


n = int(input())
for i in range(n):
	s1 = input()
	s2 = input()
	p = True
	for i in s1:
		for j in s2:
			if i == j and p:
				print('YES')
				p = False
	if p:
		print('NO')


q = int(input())
for ii in range(q):
	s1 = input()
	s2 = input()
	m = set()
	for i in s1:
		m.add(i)
	p = True
	for i in m:
		if i in s2:
			print('YES')
			p = False
			break
	if p:
		print('NO')


q = int(input())
for _ in range(q):
	s = str(input())
	t = str(input())
	if set(s).intersection(set(t)):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	s = input()
	t = input()
	if len(s) != len(t):
		print('NO')
	else:
		a = set(s)
		b = set(t)
		if len(a.intersection(b)) > 0:
			print('YES')
		else:
			print('NO')


n = int(input())
for i in range(n):
	s1 = input()
	a = set(s1)
	s2 = input()
	b = set(s2)
	r = a.intersection(b)
	if r:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	first = input()
	second = input()
	if first == second:
		print('YES')
		continue
	yes_flag = False
	for letter in first:
		if letter in second:
			print('YES')
			yes_flag = True
			break
	if not yes_flag:
		print('NO')


z = int(input())
for i in range(z):
	q = [0] * (ord('z') + 1)
	a = input()
	s = input()
	for i in a:
		q[ord(i)] = 1
	w = True
	for i in s:
		if q[ord(i)] == 1:
			w = False
			print('YES')
			break
	if w:
		print('NO')


q = int(input())
n = ''
for i in range(q):
	n = n + ' ' + input()
	n = n + ',' + input()
c = n.split()
for j in c:
	(x, y) = j.split(',')
	if len(set(x) & set(y)) == 0:
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	a = input()
	b = input()
	if a == b:
		print('YES')
	else:
		a = set(a)
		b = set(b)
		c = a.isdisjoint(b)
		if c == 1:
			print('NO')
		else:
			print('YES')


n = int(input())
ans = []
for i in range(0, n, 1):
	a = input()
	b = input()
	check = 0
	for i in range(0, len(a), 1):
		if a[i] in b:
			check = 1
	if check == 1:
		ans.append('YES')
	else:
		ans.append('NO')
for i in range(0, len(ans), 1):
	print(ans[i])


a = int(input())
g = []
for i in range(0, a):
	s = str(input())
	t = str(input())
	set1 = set(list(s))
	set2 = set(list(t))
	if set1 & set2:
		g.append('YES')
	else:
		g.append('NO')
print('\n'.join(g))


a = int(input())
for i in range(a):
	b = input()
	c = input()
	if len(set(b + c)) == len(set(b)) + len(set(c)):
		print('NO')
	else:
		print('YES')


q = int(input())
for i in range(q):
	s = input()
	b = input()
	if len(set(s) & set(b)):
		print('YES')
	else:
		print('NO')


def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def li():
	return list(mi())
t1 = ii()
while t1:
	t1 -= 1
	s = si()
	t = si()
	s = set(s)
	s = list(s)
	f = 0
	for i in s:
		if i in t:
			print('Yes')
			f = 1
			break
	if f == 0:
		print('No')


n = int(input())
for i in range(0, n):
	first_string = input()
	second_string = input()
	map = {}
	for i in range(0, len(first_string)):
		if first_string[i] in map:
			map[first_string[i]] += 1
		else:
			map[first_string[i]] = 1
	same = False
	for i in range(0, len(second_string)):
		if second_string[i] in map:
			same = True
			break
	if same == True:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	a = [0] * 40
	s = input()
	t = input()
	ans = 'NO'
	for i in range(len(s)):
		a[ord(s[i]) - ord('a')] += 1
	for i in range(len(s)):
		if a[ord(t[i]) - ord('a')] > 0:
			ans = 'YES'
	print(ans)


n = int(input())
for _ in range(n):
	s1 = input()
	ss1 = set(s1)
	s2 = input()
	ss2 = set(s2)
	if ss1 & ss2:
		print('YES')
	else:
		print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		s = S()
		t = S()
		ss = set([c for c in s])
		ts = set([c for c in t])
		rr.append(YES(ss & ts))
	return JA(rr, '\n')
print(main())


m = int(input())
ans = []
for i in range(m):
	an = 'NO'
	s1 = input()
	s2 = input()
	for j in 'qwertyuiopasdfghjklzxcvbnm':
		if j in s1 and j in s2:
			an = 'YES'
			break
	ans.append(an)
for i in ans:
	print(i)


i = input
for _ in ' ' * int(i()):
	print('YNEOS'[not {*i()} & {*i()}::2])


a = int(input())
for i in range(a):
	b = input()
	c = input()
	y = 0
	for i in b:
		if i in c:
			y = 1
		else:
			pass
	if y == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(0, q):
	a = input()
	s = input()
	z = len(a)
	x = -1
	for i in range(0, z):
		x = a.find(s[i])
		if x != -1:
			break
	if x != -1:
		print('YES')
	else:
		print('NO')


q = int(input())
i = 0
ABC = 'qwertyuiopasdfghjklzxcvbnm'
while i < q:
	(s, t) = [input() for j in [0, 0]]
	f = False
	abc = [False] * 26
	for j in s:
		abc[ABC.find(j)] = True
	for j in t:
		if abc[ABC.find(j)]:
			f = True
			break
	if f:
		print('YES')
	else:
		print('NO')
	i += 1


n = int(input())
for i in range(n):
	ss = set(input())
	tt = set(input())
	if len(ss & tt) > 0:
		print('YES')
	else:
		print('NO')


num = int(input())
for i in range(num):
	st1 = input()
	st2 = input()
	flag = False
	for j in st1:
		if j in st2:
			flag = True
			break
	if flag:
		print('Yes')
	else:
		print('No')


def f(s, t):
	for ch in 'abcdefghijklmnopqrstuvwxyz':
		if ch in s and ch in t:
			return 'YES'
	return 'NO'
for i in range(int(input())):
	print(f(input(), input()))


for _ in range(int(input())):
	s = input()
	s1 = input()
	s = set(s)
	s1 = set(s1)
	if s1 & s:
		print('YES')
	else:
		print('NO')


q = int(input())
z = []
for i in range(q):
	s = input()
	t = input()
	if len(list(s)) != 1 and len(list(set(s) & set(t))) != 0:
		z.append('YES')
	elif s != t:
		z.append('NO')
	else:
		z.append('YES')
for a in z:
	print(a)


def eq(s, t):
	for i in s:
		if i in t:
			return True
q = int(input())
a = list()
for i in range(q):
	s = input()
	t = input()
	if s == t:
		a.append('YES')
	elif eq(s, t):
		a.append('YES')
	else:
		a.append('NO')
for i in a:
	print(i)


def task_1():
	n = int(input())
	for i in range(n):
		num = int(input())
		if num == 2:
			print(2)
			continue
		print(num % 2)

def do_it(word_1, word_2):
	for ch1 in word_1:
		for ch2 in word_2:
			if ch1 == ch2:
				print('YES')
				return
	print('NO')
	return

def task_2():
	n = int(input())
	for i in range(n):
		word_1 = str(input())
		word_2 = str(input())
		do_it(word_1, word_2)
task_2()


q = int(input())
for i in range(q):
	s = input()
	s = set(s)
	s = list(s)
	t = input()
	t = set(t)
	z = 0
	for i in range(len(s)):
		if s[i] in t:
			z = 1
			break
	if z == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
while n > 0:
	s = str(input())
	t = str(input())
	s = set(s)
	t = set(t)
	i = s.intersection(t)
	if len(i) > 0:
		print('YES')
	else:
		print('NO')
	n -= 1


t = int(input())
for i in range(t):
	s = input()
	s1 = input()
	f = 0
	for i in s1:
		if i in s:
			f = 1
			print('YES')
			break
	if f == 0:
		print('NO')


for t in range(int(input())):
	print('NO' if len(set(input().strip()).intersection(set(input().strip()))) == 0 else 'YES')


q = int(input())
for _ in range(q):
	a = list(input())
	b = list(input())
	sa = set()
	sb = set()
	for i in range(len(a)):
		sa.add(a[i])
		sb.add(b[i])
	ok = True
	for i in sa:
		if i in sb:
			ok = False
			break
	if ok:
		print('NO')
	else:
		print('YES')


a = int(input())
gg = []
ggg = []
for i in range(a):
	gg.append(input())
	ggg.append(input())
for i in range(a):
	for ii in gg[i]:
		if ii in ggg[i]:
			print('YES')
			break
	else:
		print('NO')


t = int(input())
i = 0
while i < t:
	a = str(input())
	b = str(input())
	s = 0
	for x in a:
		for y in b:
			if x == y:
				s += 1
	if s > 0:
		print('YES')
	else:
		print('NO')
	i += 1


n = int(input())
b = []
for i in range(n):
	a = str(input())
	x = str(input())
	aa = set(a)
	bb = set(x)
	s = aa.intersection(bb)
	if len(x) == len(a):
		if x == a:
			b.append('YES')
		elif len(s) != 0:
			b.append('YES')
		else:
			b.append('NO')
	else:
		b.append('NO')
for i in b:
	print(i)


for _ in range(int(input())):
	a = input()
	b = input()
	possible = any(map(lambda x: x in b, a))
	print('YES' if possible else 'NO')


for i in range(int(input())):
	x = set(input())
	y = set(input())
	print('YES' if len(x.intersection(y)) else 'NO')


n = int(input())
ans = []
for _ in range(n):
	a = set(input())
	b = set(input())
	if len(a & b) > 0:
		ans.append('YES')
	else:
		ans.append('NO')
for el in ans:
	print(el)


a = int(input())
sp = []
k = False
for i in range(a):
	b = input()
	c = input()
	for j in b:
		if j in c:
			k = True
			break
	if k:
		sp.append('YES')
	else:
		sp.append('NO')
	k = False
for i in sp:
	print(i)


q = int(input())
for i in range(q):
	a = input()
	s = input()
	a = set([i for i in a])
	s = set([i for i in s])
	u = a & s
	if len(u) >= 1:
		print('YES')
	else:
		print('NO')


n = int(input())
q = [0 for i in range(n)]
for i in range(n):
	q[i] = [input(), input()]
for i in q:
	flag = True
	for u in range(len(i[0])):
		if i[0][u] in i[1] or i[1][u] in i[0]:
			print('YES')
			flag = False
			break
	if flag:
		print('NO')


k = int(input())
f = ''
for i in range(k):
	a = set(input())
	b = set(input())
	if len(a & b) != 0:
		f += 'Yes\n'
	else:
		f += 'No\n'
print(f)


n = int(input())
for i in range(n):
	c = 0
	s1 = input()
	s2 = input()
	for j in s1:
		if j in s2:
			c = 1
			break
	if c == 1:
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(0, q):
	s = str(input())
	t = str(input())
	b = 0
	for j in range(0, len(s)):
		if s[j] in t:
			print('YES')
			b = 1
			break
	if b == 0:
		print('NO')


n = int(input())
for x in range(n):
	str1 = input()
	str2 = input()
	kt = 0
	for y in str1:
		for z in str2:
			if y == z:
				print('YES')
				kt = 1
				break
		if kt == 1:
			break
	if kt == 0:
		print('NO')


t = int(input())
for _ in range(t):
	s = input()
	t = input()
	ans = False
	for i in set(s):
		if i in t:
			ans = True
			break
	print('YES' if ans else 'NO')


q = int(input())
for i in range(q):
	s1 = input()
	s2 = input()
	f = 1
	for i in range(len(s1)):
		for j in range(len(s2)):
			if f and s1[i] == s2[j]:
				print('YES')
				f = 0
	if f:
		print('NO')


from collections import defaultdict as dt
for _ in range(int(input())):
	a = input()
	b = input()
	d = dt(lambda : 0)
	e = dt(lambda : 0)
	x = 0
	for i in a:
		d[i] = d[i] + 1
	for i in b:
		e[i] = e[i] + 1
	for i in d:
		if e[i] != 0:
			print('YES')
			x = 1
			break
	if x == 0:
		print('NO')


for tc in range(int(input())):
	s = input().strip()
	t = input().strip()
	good = False
	for i in range(len(s)):
		for j in range(len(t)):
			if s[i] == t[j]:
				good = True
				break
	print('YES' if good else 'NO')


for i in range(int(input())):
	print('No' if len(set(input()) & set(input())) == 0 else 'YES')


for _ in range(int(input())):
	s = input()
	t = input()
	ch = 0
	for i in range(len(s)):
		if s[i] in t:
			ch += 1
	if ch == 0:
		print('NO')
	else:
		print('YES')


for c in range(int(input())):
	s = set(list(input()))
	t = set(list(input()))
	if s.intersection(t):
		print('YES')
	else:
		print('NO')


q = int(input())
for i in range(q):
	g = 0
	s1 = str(input())
	s2 = str(input())
	for j in s1:
		if j in s2:
			g = 1
			print('YES')
			break
	if g == 0:
		print('NO')


q = int(input())
for i in range(q):
	flag = 0
	s = str(input())
	t = str(input())
	for k in s:
		if k in t:
			flag = 1
			print('yes')
			break
	if flag == 0:
		print('no')


q = int(input())
Z = []
for i in range(q):
	a = input()
	b = input()
	A = [0] * 26
	B = [0] * 26
	Tr = False
	for j in range(len(a)):
		A[ord(a[j]) - ord('a')] = 1
	for j in range(len(b)):
		B[ord(b[j]) - ord('a')] = 1
	for j in range(26):
		if A[j] == B[j] == 1:
			Tr = True
	Z.append(Tr)
for z in Z:
	if z:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = (input(), input())
	print('Yes' if set(a) & set(b) else 'No')


n = int(input())
answer = 'NO'
for i in range(0, n):
	a = input()
	b = input()
	a1 = set(a)
	b1 = set(b)
	if set.intersection(a1, b1) != set():
		answer = 'YES'
	else:
		answer = 'NO'
	print(answer)


q = int(input())
for i in range(q):
	s = input()
	t = input()
	for c in s:
		if c in t:
			print('yes')
			break
	else:
		print('no')


q = int(input())
for i in range(q):
	s = str(input())
	t = str(input())
	if s == t:
		print('YES')
		continue
	if len(s) == len(t) == 1 and s != t:
		print('NO')
		continue
	bl = False
	for i in range(len(s)):
		if s[i] in t:
			bl = True
	if bl:
		print('YES')
	else:
		print('NO')