Gennady owns a small hotel in the countryside where he lives a peaceful life. He loves to take long walks, watch sunsets and play cards with tourists staying in his hotel. His favorite game is called "Mau-Mau".

To play Mau-Mau, you need a pack of $52$ cards. Each card has a suit (Diamonds — D, Clubs — C, Spades — S, or Hearts — H), and a rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, or A).

At the start of the game, there is one card on the table and you have five cards in your hand. You can play a card from your hand if and only if it has the same rank or the same suit as the card on the table.

In order to check if you'd be a good playing partner, Gennady has prepared a task for you. Given the card on the table and five cards in your hand, check if you can play at least one card.


-----Input-----

The first line of the input contains one string which describes the card on the table. The second line contains five strings which describe the cards in your hand.

Each string is two characters long. The first character denotes the rank and belongs to the set $\{{\tt 2}, {\tt 3}, {\tt 4}, {\tt 5}, {\tt 6}, {\tt 7}, {\tt 8}, {\tt 9}, {\tt T}, {\tt J}, {\tt Q}, {\tt K}, {\tt A}\}$. The second character denotes the suit and belongs to the set $\{{\tt D}, {\tt C}, {\tt S}, {\tt H}\}$.

All the cards in the input are different.


-----Output-----

If it is possible to play a card from your hand, print one word "YES". Otherwise, print "NO".

You can print each letter in any case (upper or lower).


-----Examples-----
Input
AS
2H 4C TH JH AD

Output
YES

Input
2H
3D 4C AC KD AS

Output
NO

Input
4D
AS AC AD AH 5H

Output
YES



-----Note-----

In the first example, there is an Ace of Spades (AS) on the table. You can play an Ace of Diamonds (AD) because both of them are Aces.

In the second example, you cannot play any card.

In the third example, you can play an Ace of Diamonds (AD) because it has the same suit as a Four of Diamonds (4D), which lies on the table.

Difficulty: EASY

Solutions:
x = input()
y = input().split()
flag = 0
for z in y:
	if z[0] == x[0] or z[1] == x[1]:
		flag = 1
	elif z[0] == x[1] or z[1] == x[0]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


table = input()
cards = [x for x in input().strip().split()]
matches = set()
for card in cards:
	for x in card:
		matches.add(x)
if table[0] in matches or table[1] in matches:
	print('YES')
else:
	print('NO')


mycard = str(input())
tablecard = list(input().split())
for i in tablecard:
	if i[1] == mycard[1]:
		print('YES')
		exit()
	elif i[0] == mycard[0]:
		print('YES')
		exit()
	else:
		continue
print('NO')


card = input()
answer = False
Cards = input().split()
for i in range(len(Cards)):
	if Cards[i][0] == card[0] or Cards[i][1] == card[1]:
		answer = True
		print('YES')
		break
if answer is False:
	print('NO')


a = input()
b = [str(i) for i in input().split()]
flag = 0
for i in range(0, 5):
	l = list(b[i])
	if l[0] == a[0]:
		flag = 1
		break
for i in range(0, 5):
	l = list(b[i])
	if l[1] == a[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


import getpass
import sys

def ria():
	return [int(i) for i in input().split()]
if getpass.getuser() != 'frohenk':
	filename = 'half'
else:
	sys.stdin = open('input.txt')
crd = input()
cs = input().split()
for i in cs:
	if i[0] == crd[0] or i[1] == crd[1]:
		print('YES')
		exit(0)
print('NO')


n = input()
a = input().split()
m = []
for i in a:
	if n[0] == i[0] or n[1] == i[1]:
		m = i
if m != []:
	print('YES')
else:
	print('NO')


s = input()
ar = [str(i) for i in input().strip().split()]
b = 0
for i in ar:
	if s[0] == i[0] or s[1] == i[1]:
		b = 1
		break
if b:
	print('YES')
else:
	print('NO')


s = input()
a = list(map(str, input().split()))
f = 0
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


n = input()
a = input()
for i in n:
	if i in a:
		print('YES')
		exit()
else:
	print('NO')


import sys
t = list(sys.stdin.readline().rstrip('\n'))
h = list(sys.stdin.readline().rstrip('\n'))
if t[0] in h:
	print('YES')
elif t[1] in h:
	print('YES')
else:
	print('NO')


drawn = input()
f = 0
first = drawn[0]
second = drawn[1]
have = input().split(' ')
for i in range(5):
	if first == have[i][0] or second == have[i][1]:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


tb = input()
hand = input()
hand_card = hand.split()
flag = 0
for i in hand_card:
	if i[0] in tb[0] or i[1] in tb[1]:
		flag = 1
		exit
if flag == 0:
	print('NO')
else:
	print('YES')


s = input().strip()[:2]
a = list(input().split())
for k in a:
	if k[0] == s[0] or k[1] == s[1]:
		print('YES')
		exit()
print('NO')


cardT = input()
(rank, suit) = (cardT[0], cardT[1])
cards = [a for a in input().split()]
for card in cards:
	if card[0] == rank or card[1] == suit:
		print('YES')
		break
else:
	print('NO')


def main():
	table = list(map(str, input()))
	deck = list(map(str, input()))
	if table[0] in deck or table[1] in deck:
		print('YES')
	else:
		print('NO')
main()


a = input()
b = input().split()
t = False
for card in b:
	if card[0] == a[0] or card[1] == a[1]:
		t = True
		break
if t:
	print('YES')
else:
	print('NO')


test = input()
inp = [i for i in input().split()]
for i in inp:
	if test[0] == i[0] or test[1] == i[1]:
		print('YES')
		break
else:
	print('NO')


carte = input()
liste = input().split()
resultat = 'NO'
for i in range(len(liste)):
	if liste[i][0] == carte[0]:
		resultat = 'YES'
		break
	elif liste[i][1] == carte[1]:
		resultat = 'YES'
		break
print(resultat)


table = input()
hand = input().split()
hasil = False
for i in table:
	if hasil == True:
		break
	for j in hand:
		if i in j:
			hasil = True
			break
		else:
			hasil = False
if hasil == True:
	print('YES')
else:
	print('NO')


inp = input()
cards = input().split(' ')
cards = ''.join(cards)
flag = 0
for i in inp:
	if i in cards:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


a = input()
x = 0
lst = list(input().strip().split())[:5]
for i in lst:
	for j in range(len(i)):
		if i[j] == a[0]:
			x += 1
			break
		elif i[j] == a[1]:
			x += 1
			break
if x != 0:
	print('YES')
else:
	print('NO')


a = input('')
l = []
for i in a:
	l.append(i)
lst = []
b = input().split(' ')
for i in b:
	for j in i:
		lst.append(j)
ans = 'NO'
for i in l:
	if i in lst:
		ans = 'YES'
print(ans)


t = list(input())
h = list(''.join(list(input().split())))
flag = 'NO'
for i in range(0, 5):
	if t[0] == h[i * 2] or t[1] == h[i * 2 + 1]:
		flag = 'YES'
print(flag)


card = input()
hand = list(input())
if card[0] in hand or card[1] in hand:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
for i in b:
	if i[0] == a[0] or i[1] == a[1]:
		print('YES')
		break
else:
	print('NO')


card = input()
r = card[0]
c = card[1]
hand = list(input().rstrip().split())
for i in hand:
	if i[0] == r or i[1] == c:
		print('YES')
		exit()
print('NO')


l1 = []
s = str(input())
l = [str(i) for i in input().split()]
for i in l:
	if s[1] == i[1] or s[0] == i[0]:
		l1.append('YES')
	else:
		l1.append('NO')
if 'YES' in l1:
	print('YES')
else:
	print('NO')


card = input()
cardRank = card[0]
cardSuit = card[1]
suits = set()
ranks = set()
cards = input().split(' ')
for i in range(len(cards)):
	ranks.add(cards[i][0])
	suits.add(cards[i][1])
if cardRank in ranks or cardSuit in suits:
	print('YES')
else:
	print('NO')


tc = input()
words = input().split()
for word in words:
	if word[0] == tc[0] or word[1] == tc[1]:
		print('YES')
		exit()
print('NO')


s1 = input()
s2 = input().split(' ')
if any(list(map(lambda x: x[0] == s1[0], s2))) or any(list(map(lambda x: x[1] == s1[1], s2))):
	print('YES')
else:
	print('NO')


s = input()
x = input().split()
for i in range(5):
	if s[0] == x[i][0] or s[1] == x[i][1]:
		print('YES')
		exit(0)
print('NO')


from sys import stdin, stdout

def main():
	inp = [str(x).rstrip() for x in stdin.readlines()]
	(table, hand) = (inp[0], [str(x) for x in inp[1].split()])
	for i in hand:
		for j in table:
			if j in i:
				return stdout.write(str('YES') + '\n')
	return stdout.write(str('NO') + '\n')
main()


import sys
a = input()
b = input().split()
for i in range(5):
	if b[i][0] == a[0] or b[i][1] == a[1]:
		print('YES')
		sys.exit()
print('NO')


bir = input()
(q, w, e, r, t) = map(str, input().split())
y = q + w + e + r + t
if bir[0] in y or bir[1] in y:
	print('YES')
else:
	print('NO')


import re
tablecard = input()
handcards = input()
y = tablecard[0] + '|' + tablecard[1]
x = re.findall(y, handcards)
if len(x) > 0:
	print('YES')
else:
	print('NO')


s = input()
l = list(input().split())
f = 0
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


card = input()
match = 1
rank = card[0]
suit = card[1]
cards = input().split()
for i in range(5):
	if cards[i][0] == rank:
		match *= 0
	if cards[i][1] == suit:
		match *= 0
if match == 0:
	print('YES')
else:
	print('NO')


n = list(input())
b = input().split()
flag = 0
for i in range(5):
	if b[i][0] in n:
		print('YES')
		flag = 1
		break
	elif b[i][1] in n:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


a = input()
b = input()
if a[0] in b or a[1] in b:
	print('YES')
else:
	print('NO')


table = str(input())
table_n = table[0:1]
table_m = table[1:2]
res = False
ary = input().split(' ')
for i in ary:
	tmp_n = i[0:1]
	tmp_m = i[1:2]
	if table_n == tmp_n or table_m == tmp_m:
		res = True
if res == True:
	print('YES')
else:
	print('NO')


s = input()
r = input().split()
if any((s[0] == x[0] or s[1] == x[1] for x in r)):
	print('YES')
else:
	print('NO')


(ts, tr) = list(input())
res = False
for e in input().split():
	(hs, hr) = list(e)
	if hs == ts or hr == tr:
		res = True
if res:
	print('YES')
else:
	print('NO')


card1 = input()
(cardnumber, cardSuit) = [c for c in card1]
hands = input().split()
find = 'NO'
for card in hands:
	(number, suit) = [c for c in card]
	if cardnumber == number or cardSuit == suit:
		find = 'YES'
		break
print(find)


import sys
pin = sys.stdin.readline
pout = sys.stdout.write
ran = range
string = pin()
total = map(str, pin().split())
total = ''.join(map(str, total))
if string[0] in total or string[1] in total:
	pout('YES\n')
else:
	pout('NO\n')


s = input()
a = input().split()
for i in range(5):
	b = str(a[i])
	if b[0] in s:
		print('YES')
		exit()
	elif b[1] in s:
		print('YES')
		exit()
print('NO')


s = input()
answ = 0
m = 0
a = input().split()
for k in range(1, 6):
	if s[0] == a[m][0] or s[1] == a[m][1]:
		answ = 1
	m += 1
if answ == 0:
	print('NO')
else:
	print('YES')


a = str(input())
b = str(input())
k = 0
for i in range(0, len(b) - 1, 3):
	if a[0] == b[i] or a[1] == b[i + 1]:
		print('YES')
		k = 1
		break
if k == 0:
	print('NO')


a = input()
if any((i[0] == a[0] or i[1] == a[1] for i in input().split())):
	print('YES')
else:
	print('NO')


card = str(input())
l = list(map(str, input().split()))
r = card[0]
s = card[1]
c1 = l[0]
c2 = l[1]
c3 = l[2]
c4 = l[3]
c5 = l[4]
f = False
if c1[0] == r or c1[1] == s:
	print('YES')
elif c2[0] == r or c2[1] == s:
	print('YES')
elif c3[0] == r or c3[1] == s:
	print('YES')
elif c4[0] == r or c4[1] == s:
	print('YES')
elif c5[0] == r or c5[1] == s:
	print('YES')
else:
	print('NO')


s = str(input())
b = list(map(str, input().split()))
a = []
for _ in range(5):
	a.append(b[_][0])
	a.append(b[_][1])
if s[0] in a or s[1] in a:
	print('YES')
else:
	print('NO')


karta = input()
a = [i for i in input().split()]
s = ''
for i in a:
	s += i
if karta[0] in s or karta[1] in s:
	print('YES')
else:
	print('NO')


s = input()
a = input().split(' ')
fl = 0
for i in range(5):
	if a[i][0] == s[0] or a[i][1] == s[1]:
		fl = 1
		break
if fl == 1:
	print('YES')
else:
	print('NO')


card = input()
hand = input().split()
answer = 0

def check(card, card_h):
	return 1 if card[0] == card_h[0] or card[1] == card_h[1] else 0
for card_h in hand:
	if check(card, card_h) == 1:
		answer = 1
print('YES') if answer else print('NO')


N = list(input())
x = list(input().split())
l1 = []
l2 = []
for i in range(0, len(x)):
	l1.append(x[i][0])
	l2.append(x[i][1])
if N[0] in l1 or N[1] in l2:
	print('YES')
else:
	print('NO')


table_card = input()
plr_cards = input()
c = 0
for i in plr_cards:
	if i == table_card[0] or i == table_card[1]:
		c = c + 1
	else:
		pass
if c == 0:
	print('NO')
else:
	print('YES')


a = input()
b = input()
common = set([c for c in a if c in b])
if common == set():
	print('NO')
else:
	print('YES')


fs = input()
ss = list(input())
if fs[0] in ss or fs[1] in ss:
	print('YES')
else:
	print('NO')


from bisect import bisect_right as br
from bisect import bisect_left as bl
from collections import defaultdict
from itertools import combinations
import functools
import sys
import math
MAX = sys.maxsize
MAXN = 10 ** 6 + 10
MOD = 10 ** 9 + 7

def isprime(n):
	n = abs(int(n))
	if n < 2:
		return False
	if n == 2:
		return True
	if not n & 1:
		return False
	for x in range(3, int(n ** 0.5) + 1, 2):
		if n % x == 0:
			return False
	return True

def mhd(a, b, x, y):
	return abs(a - x) + abs(b - y)

def numIN():
	return map(int, sys.stdin.readline().strip().split())

def charIN():
	return sys.stdin.readline().strip().split()
t = [0] * 1000010

def create(a, n):
	global t
	for i in range(n, 2 * n):
		t[i] = a[i - n]
	for i in range(n - 1, 0, -1):
		t[i] = t[2 * i] + t[2 * i + 1]

def ncr(n, k):
	res = 1
	c = [0] * (k + 1)
	c[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, k), 0, -1):
			c[j] = (c[j] + c[j - 1]) % MOD
	return c[k]
s = input()
r = s[0]
d = s[1]
l = input().split()
for i in l:
	if i[0] == r or i[1] == d:
		print('YES')
		exit(0)
print('NO')


s = input()
t = input().split()
flag = 0
for x in t:
	if x[0] == s[0] or x[1] == s[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


floor = input()
hand = input()
x = False
lst = hand.split()
for card in lst:
	for rait in card:
		if rait == floor[0] or rait == floor[1]:
			x = True
			break
if x is False:
	print('NO')
elif x is True:
	print('YES')


table_card = input()
hand_cards = input().split()
match = 0
for card in hand_cards:
	if card[0] == table_card[0] or card[1] == table_card[1]:
		match += 1
		break
if match:
	print('YES')
else:
	print('NO')


s = input()
v = input().split()
a = [i[0] for i in v]
b = [i[1] for i in v]
if s[0] in a or s[1] in b:
	print('YES')
else:
	print('NO')


a = input()
b = input()
b = b.split(' ')
flag = False
for i in range(len(b)):
	if b[i][0] == a[0]:
		flag = True
		break
	if b[i][1] == a[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(a, b) = z()
c = list(z().split())
ans = 'NO'
for i in c:
	if a in i or b in i:
		ans = 'YES'
print(ans)


mesa = input()
cartas = input().split(' ')
mesaChar = list(mesa)
rta = 'NO'
for carta in cartas:
	cartaChar = list(carta)
	if cartaChar[0] == mesaChar[0] or cartaChar[1] == mesaChar[1]:
		rta = 'YES'
		break
print(rta)


s = input()
a = input().split()
done = True
for i in range(5):
	if a[i][0] == s[0] or a[i][1] == s[1]:
		print('YES')
		done = False
		break
if done:
	print('NO')


n = input()
a = n[0]
b = n[1]
arr = [input() for i in n.split()]
for i in arr:
	if a in i or b in i:
		print('YES')
	else:
		print('NO')


table = input()
hand = input().split()
(rank, suit) = (table[0], table[1])
can_play = any((card[0] == rank or card[1] == suit for card in hand))
print('YES' if can_play else 'NO')


a = input()
(c1, c2, c3, c4, c5) = input().split()
for i in range(2):
	if c1[i] in a or c2[i] in a or c3[i] in a or (c4[i] in a) or (c5[i] in a):
		print('YES')
		exit()
print('NO')


card_in = input()
hand_in = input().split()
card = (card_in[0], card_in[1])
HAND_SIZE = 5
hand = ()
for i in range(HAND_SIZE):
	hand += ((hand_in[i][0], hand_in[i][1]),)
playable = False
for i in range(HAND_SIZE):
	if card[0] == hand[i][0] or card[1] == hand[i][1]:
		playable = True
		break
if playable:
	print('YES')
else:
	print('NO')


s = input()
r = input()
chk = 0
for i in range(2):
	for j in range(i, len(r), 3):
		if s[i] == r[j]:
			print('YES')
			exit(0)
print('NO')


desk = input()
play = input().split()
for i in play:
	if i[0] == desk[0] or i[1] == desk[1]:
		print('YES')
		break
else:
	print('NO')


t = input()
h = input().split()
c = 0
for i in h:
	if i[0] == t[0] or i[1] == t[1]:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


v = 0
a = input()
b = input().split()
al = [a[0], a[1]]
bl = [0] * 2
for i in range(5):
	c = b[i]
	bl[0] = c[0]
	bl[1] = c[1]
	if al[0] == bl[0]:
		v = 1
	elif al[1] == bl[1]:
		v = 1
if v == 1:
	print('YES')
else:
	print('NO')


s = input()
(a, b, c, d, e) = input().split()
cc = 0
if a[0] == s[0] or b[0] == s[0] or c[0] == s[0] or (d[0] == s[0]) or (e[0] == s[0]):
	cc += 1
elif a[1] == s[1] or b[1] == s[1] or c[1] == s[1] or (d[1] == s[1]) or (e[1] == s[1]):
	cc += 1
else:
	cc = 0
if cc > 0:
	print('YES')
else:
	print('NO')


def foo(f, s):
	for each in f:
		if each in s:
			print('YES')
			return
	print('NO')
first = input()
second = input().replace(' ', '')
foo(first, second)


A = input()
n = input().split()
print('YES' if any((A.find(k[0]) != -1 or A.find(k[1]) != -1 for k in n)) else 'NO')


table = list(map(str, input()))
hand = input().split()
for i in hand:
	if i[0] in table or i[1] in table:
		print('YES')
		break
else:
	print('NO')


import sys
table = input()
hand = input().split(' ')
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		print('YES')
		sys.exit()
print('NO')
sys.exit()


k = input()
for s in input().split():
	if s[0] == k[0] or s[1] == k[1]:
		print('YES')
		exit()
print('NO')


t = input()
p = input()
if t[0] in p or t[1] in p:
	print('YES')
else:
	print('NO')


q = input()
ans = input().split()
flag = 0
flag1 = 0
for k in range(len(ans)):
	i = 0
	while i < 2:
		if ans[k][i] == q[i]:
			flag = 1
			break
		i += 1
	if flag == 1:
		print('YES')
		flag1 = 1
		break
if flag1 == 0:
	print('NO')


s = list(input())
h = input()
h = h.replace(' ', '')
h = list(h)
lf = []
for i in s:
	if i in h:
		lf.append('YES')
	else:
		lf.append('NO')
if 'YES' in lf:
	print('YES')
else:
	print('NO')


x = input()
arr = list(map(str, input().split()))
i = 0
f = 0
while i < 5:
	if arr[i][0] == x[0] or arr[i][1] == x[1]:
		f = 1
		break
	i += 1
if f == 0:
	print('NO')
else:
	print('YES')


n = str(input())
(a1, a2, a3, a4, a5) = map(str, input().split())
f = 0
if a1[0] == n[0]:
	f = 1
if a1[1] == n[1]:
	f = 1
if a2[0] == n[0]:
	f = 1
if a2[1] == n[1]:
	f = 1
if a3[0] == n[0]:
	f = 1
if a3[1] == n[1]:
	f = 1
if a4[0] == n[0]:
	f = 1
if a4[1] == n[1]:
	f = 1
if a5[0] == n[0]:
	f = 1
if a5[1] == n[1]:
	f = 1
if f == 1:
	print('YES')
else:
	print('NO')


onTable = input()
myCards = list(map(str, input().split()))
checkCon = False
for i in range(5):
	if onTable[0] == myCards[i][0] or onTable[1] == myCards[i][1]:
		print('YES')
		checkCon = True
		break
if not checkCon:
	print('NO')


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	(r, s) = input()
	for (x, y) in input().split():
		if r == x or s == y:
			YES()
			return
	NO()

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def dbg(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import os
import sys
from io import BytesIO, IOBase
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 read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

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

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


a = input()
b = input().split()
i = 1
flag = 'NO'
for i in range(5):
	if a[0] == b[i][0] or a[1] == b[i][1]:
		flag = 'YES'
print(flag)


s = input()
x = input().split()
p = ''.join(x)
cek = False
for i in range(0, 10, 2):
	if s[0] == p[i] or s[1] == p[i + 1]:
		cek = True
if cek:
	print('YES')
else:
	print('NO')


s = input()
l = input().split()
f = set()
last = set()
for i in l:
	f.add(i[0])
	last.add(i[1])
if s[0] in f or s[1] in last:
	print('YES')
else:
	print('NO')


table = input('')
table1 = list(table)[0]
table2 = list(table)[1]
deck = input('')
if table1 in deck or table2 in deck:
	print('YES')
else:
	print('NO')


my = input()
your = list(input().split())
flag = 'NO'
for i in your:
	if i[0] == my[0] or i[1] == my[1]:
		flag = 'YES'
		break
print(flag)


def playable(t, h):
	for i in range(5):
		if h[i][0] == t[0] or h[i][1] == t[1]:
			return 'YES'
	return 'NO'
table = input()
hand = input().split()
print(playable(table, hand))


import sys
input = sys.stdin.readline
n = input()
l = list(input().split())
d = 0
for i in l:
	if n[0] == i[0] or n[1] == i[1]:
		print('YES')
		d = 1
		break
if d == 0:
	print('NO')


s1 = input()
s = input()
if s1[0] in s or s1[1] in s:
	print('YES')
else:
	print('NO')


table = input()
for e in input().split():
	if e[0] == table[0] or e[1] == table[1]:
		print('YES')
		exit()
print('NO')


k = input()
c = [j for j in input().split(' ')]
(a, b) = (k[0], k[1])
for i in c:
	if i[0] == a or i[1] == b:
		print('YES')
		exit(0)
print('NO')


card_on_the_table = input()
suit_on_the_table = card_on_the_table[0]
rank_on_the_table = card_on_the_table[1]
list_of_cards_in_hand = input().split(' ')
list_of_suits_in_hand = []
list_of_ranks_in_hand = []
for card in list_of_cards_in_hand:
	list_of_suits_in_hand.append(card[0])
	list_of_ranks_in_hand.append(card[1])
can_a_card_be_played = 0
for suit in list_of_suits_in_hand:
	if suit == suit_on_the_table:
		can_a_card_be_played = 1
		break
for rank in list_of_ranks_in_hand:
	if rank == rank_on_the_table:
		can_a_card_be_played = 1
		break
if can_a_card_be_played == 1:
	print('YES')
else:
	print('NO')


c0 = input().strip()
cards = [s.strip() for s in input().split()]

def check():
	for c in cards:
		for i in (0, 1):
			if c[i] == c0[i]:
				return True
	return False
ans = 'YES' if check() else 'NO'
print(ans)


table = input()
cards = input().split()
for card in cards:
	if table[0] in card or table[1] in card:
		print('YES')
		break
else:
	print('NO')


s = input()
l = list(map(str, input().split()))
a = []
c = []
s1 = ''
an = []
for i in range(len(s)):
	a.append(str(s[i]))
for i in range(len(l)):
	for j in range(len(l[i])):
		c.append(l[i][j])
for i in range(0, len(c), 2):
	if a[0] in c[i:i + 2]:
		an.append(1)
	if a[1] in c[i:i + 2]:
		an.append(1)
	else:
		an.append(0)
if 1 in an:
	print('YES')
else:
	print('NO')


i1 = list(input())
for j in input().split():
	if i1[0] in j or i1[1] in j:
		print('YES')
		exit(0)
print('NO')


card = input()
cards = input().split()
ans = 0
for i in range(len(cards)):
	if ans:
		break
	else:
		for j in range(2):
			if card[j] == cards[i][j]:
				ans = 1
				break
if ans:
	print('YES')
else:
	print('NO')


x = input()
n = list(map(str, input().split()))
count = 0
for i in x:
	for j in n:
		if j[0] == i or j[1] == i:
			count = 1
			break
		else:
			count = 0
	if count == 1:
		break
if count == 1:
	print('YES')
else:
	print('NO')


given = tuple(input())
answer = False
strings = input().split(' ')
for i in range(0, 5):
	hand = tuple(strings[i])
	if hand[0] == given[0] or hand[1] == given[1]:
		answer = True
print('YES' if answer else 'NO')


q = list(input())
w = list(input().split())
e = []
for i in range(len(w)):
	for j in w[i]:
		e.append(j)
if q[0] in e or q[1] in e:
	print('YES')
else:
	print('NO')


import sys
n = list(sys.stdin.readline())
a = sys.stdin.readline().strip().split()
for i in a:
	if n[0] == i[0] or n[1] == i[1]:
		print('YES')
		exit(0)
print('NO')


s1 = list(str(input()))
s2 = ''
for i in list(map(str, input().split())):
	s2 += i
if s1[0] in s2 or s1[1] in s2:
	print('YES')
else:
	print('NO')


cur = input()
hand = input()
arrhand = hand.split()
yes = 0
for j in range(0, 5):
	if arrhand[j][0] == cur[0] or arrhand[j][1] == cur[1]:
		yes = 1
	else:
		pass
if yes == 1:
	print('YES')
else:
	print('NO')


s1 = input()
ss2 = input().split()
ok = False
for s2 in ss2:
	for i in range(2):
		if s1[i] == s2[i]:
			ok = True
if ok:
	print('YES')
else:
	print('NO')


hand = input()
(one, two, three, four, fife) = input().split()
rank = [one[0], two[0], three[0], four[0], fife[0]]
suit = [one[1], two[1], three[1], four[1], fife[1]]
answer = 'NO'
for i in rank:
	if i == hand[0]:
		answer = 'YES'
for i in suit:
	if i == hand[1]:
		answer = 'YES'
print(answer)


s = input()
(d, m) = (s[0], s[1])
s = input().split(' ')
for el in s:
	if el[0] == d or el[1] == m:
		print('YES')
		break
else:
	print('NO')


a = input()
d = list(a)
c = []
s = 0
b = list(input().split())
for i in range(len(b)):
	c.append(list(b[i]))
for i in c:
	for j in i:
		if j in d:
			s = s + 1
if s != 0:
	print('YES')
else:
	print('NO')


table = list(input())
mine = list(input())
if table[0] in mine or table[1] in mine:
	print('YES')
else:
	print('NO')


myCard = input()
table = input()
rank = myCard[0]
suit = myCard[1]
if rank in table:
	print('YES')
elif suit in table:
	print('YES')
else:
	print('NO')


card_on_table = input()
cards_in_hand = input().split(' ')
is_in = 'NO'
for n in range(5):
	if card_on_table[0] in cards_in_hand[n] or card_on_table[1] in cards_in_hand[n]:
		is_in = 'YES'
print(is_in)


inp = input().strip().split()
arr = input().strip().split()
flag = 0
for i in range(len(arr)):
	if inp[0][0] == arr[i][0] or inp[0][1] == arr[i][1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


s = input()
x = [*input().strip().split()]
for w in x:
	if s[0] == w[0] or s[1] == w[1]:
		print('YES')
		exit()
print('NO')


n = input('')
c = input('').split()
dic = dict()
x = 0
for i in c:
	for w in i:
		dic[w] = dic.get(w, 0) + 1
for i in n:
	for w in i:
		if w not in dic:
			continue
		else:
			x = 1
			break
if x == 1:
	print('YES')
else:
	print('NO')


a = str(input())
arr = list(map(str, input().split()))
c = 0
for i in range(len(arr)):
	if a[0] == arr[i][0] or a[1] == arr[i][1]:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


s = input()
ar = input().split(' ')
ans = 0
for i in range(5):
	if s[0] == ar[i][0]:
		ans = 1
		break
	if s[1] == ar[i][1]:
		ans = 1
		break
if ans == 1:
	print('YES')
else:
	print('NO')


a = list(input())
b = list(input())
if a[0] == b[0] or a[1] == b[1] or a[0] == b[3] or (a[1] == b[4]) or (a[0] == b[6]) or (a[1] == b[7]) or (a[0] == b[9]) or (a[1] == b[10]) or (a[0] == b[12]) or (a[1] == b[13]):
	print('YES')
else:
	print('NO')


s = input()
(a, b, c, d, e) = [x for x in input().split()]
if s[0] in a or s[1] in a or s[0] in b or (s[1] in b) or (s[0] in c) or (s[1] in c) or (s[0] in d) or (s[1] in d) or (s[0] in e) or (s[1] in e):
	print('YES')
else:
	print('NO')


a = input()
arr = list(input().split())
for el in arr:
	if el[0] == a[0] or el[1] == a[1]:
		print('YES')
		exit()
print('NO')


tablecard = input()
handcard = input().split()
T = True
for h in handcard:
	if h[0] == tablecard[0] or h[1] == tablecard[1]:
		print('YES')
		T = False
		break
if T:
	print('NO')


import sys
t = input()
vc = [x for x in input().split()]
for s in vc:
	if s[0] == t[0] or s[1] == t[1]:
		print('YES')
		sys.exit(0)
print('NO')


s = input()
cards = input()
if s[0] in cards or s[1] in cards:
	print('YES')
else:
	print('NO')


card = input()
choices = input().split()
for choice in choices:
	if choice[0] == card[0] or choice[1] == card[1]:
		print('YES')
		exit(0)
print('NO')


s = input()
c = 0
l = list(map(str, input().rstrip().split()))
for i in range(5):
	a = l[i]
	if a[1] == s[1] or a[0] == s[0]:
		c = c + 1
if c >= 1:
	print('YES')
else:
	print('NO')


n = list(input())
s = list(input())
l = []
for i in range(len(s)):
	if n[0] == s[i] or n[1] == s[i]:
		l.append(1)
	else:
		l.append(0)
print('NO' if l.count(1) == 0 else 'YES')


(r, s) = list(input().strip())
l = input().strip().split()
a = []
b = []
for i in range(len(l)):
	a.append(l[i][0])
	b.append(l[i][1])
if r in a or s in b:
	print('YES')
else:
	print('NO')


D = input()
a = 0
memo = [*map(str, [*input()])]
for i in range(len(memo)):
	if memo[i] in D:
		a += 1
if a == 0:
	print('NO')
else:
	print('YES')


ct = list(input())
ch = list(input())
if ct[0] in ch or ct[1] in ch:
	print('YES')
else:
	print('NO')


t = input()
y = list(map(str, input()))
if t[0] in y or t[1] in y:
	print('YES')
else:
	print('NO')


start = str(input())
hand = str(input())
count = 0
a = hand.split()
for i in range(0, len(a), 1):
	if a[i][0] == start[0]:
		print('YES')
		count = 1
		break
	elif a[i][1] == start[1]:
		print('YES')
		count = 1
		break
if count != 1:
	print('NO')


table_card = input()
hand_cards = input().split()

def main():
	for card in hand_cards:
		if card[0] == table_card[0] or card[1] == table_card[1]:
			print('YES')
			return
	print('NO')
main()


n = input()
l = list(n)
k = list(map(str, input().split()))
y = ''.join(map(str, k))
if l[0] in y or l[1] in y:
	print('YES')
else:
	print('NO')


(r, s) = input()
l = input().split()
ans = 'NO'
for e in l:
	if e[0] == r or e[1] == s:
		ans = 'YES'
		break
print(ans)


a = list(input())
b = list(map(str, input().split()))
c = []
h = []
for i in range(5):
	c.append(b[i][0])
	h.append(b[i][1])
if a[0] in c or a[1] in h:
	print('YES')
else:
	print('NO')


def check(on_table, hand):
	on_table_rank = on_table[0]
	on_table_suit = on_table[1]
	for card in hand:
		card_rank = card[0]
		card_suit = card[1]
		if card_rank == on_table_rank or card_suit == on_table_suit:
			print('YES')
			return
	print('NO')
	return
on_table = input()
hand = input().split(' ')
check(on_table, hand)


list1 = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A']
list2 = ['D', 'C', 'S', 'H']
word = input()
line = input().split()
list1 = []
list2 = []
for i in line:
	list1.append(i[0])
	list2.append(i[1])
if word[0] in list1 or word[1] in list2:
	print('YES')
else:
	print('NO')


(mast, digit) = input().strip()
cards_in_the_hands = [x for x in input().split()]

def check():
	for card in cards_in_the_hands:
		if mast in card or digit in card:
			print('YES')
			return
	print('NO')
check()


a = input()
b = [a for a in input().split()]
e = []
for i in b:
	for g in i:
		e.append(g)
f = a[0]
h = a[1]
if f in e or h in e:
	print('YES')
else:
	print('NO')


class Card:

	def __init__(self, s):
		self.rank = s[0]
		self.suit = s[1]

	def __eq__(self, another):
		if self.rank == another.rank or self.suit == another.suit:
			return True
		else:
			return False

	def can_play(self, others):
		for card in others:
			if self == card:
				return True
		return False
first_card = Card(input())
cards = [Card(i) for i in input().split()]
if first_card.can_play(cards):
	print('YES')
else:
	print('NO')


card = input()
a = input().split()
if card[0] in [c[0] for c in a] or card[1] in [c[1] for c in a]:
	print('YES')
else:
	print('NO')


keyCard = list(str(input()))
others = list(str(input()))
if keyCard[0] in others or keyCard[1] in others:
	print('YES')
else:
	print('NO')


h = str(input())
hs = str(input()).split(' ')
for i in range(0, len(hs)):
	if hs[i][0] in h or hs[i][1] in h:
		b = 'YES'
		break
	else:
		b = 'NO'
print(b)


s = input()
s1 = list(zip(*map(lambda x: list(x), input().split())))
print('YES' if s[0] in s1[0] or s[1] in s1[1] else 'NO')


table = list(input())
cards = list(input().strip())
if table[0] in cards or table[1] in cards:
	print('YES')
else:
	print('NO')


need = list(input())
s = [x for x in input().split()]
tr = False
for i in s:
	if need[0] == i[0] or need[1] == i[1]:
		tr = True
		break
if tr == True:
	print('YES')
else:
	print('NO')


s = input()
h = list(map(str, input().split()))
ok = False
for i in range(len(h)):
	if h[i][0] == s[0] or h[i][1] == s[1]:
		ok = True
		break
if ok == True:
	print('YES')
else:
	print('NO')


card_g = input()
cards_user = input().split()
output = 'NO'
for i in cards_user:
	if i[0] == card_g[0] or i[1] == card_g[1]:
		output = 'YES'
print(output)


value = input()
values = input()
if values.find(value[0]) != -1 or values.find(value[1]) != -1:
	print('YES')
else:
	print('NO')


cardOnTable = input()
myCards = input().split()
for card in myCards:
	if card[1] == cardOnTable[1] or card[0] == cardOnTable[0]:
		print('YES')
		break
else:
	print('NO')


t = input()
a = input().split()
c1 = t[0]
c2 = t[1]
ans = 'NO'
for i in range(len(a)):
	if a[i][0] == c1 or a[i][1] == c2:
		ans = 'YES'
print(ans)


a = list(input())
b = list(input())
i = 0
while i < len(b):
	if b[i] == a[0] or b[i] == a[1]:
		print('YES')
		break
	i += 1
else:
	print('NO')


card = input()[:2]
i = input().strip().split()[:5]
for x in range(5):
	if i[x][0] == card[0] or i[x][1] == card[1]:
		print('YES')
		break
else:
	print('NO')


a = input()
b = input()
b = b.split()
i = 0
count = 0
while i < 2:
	for x in b:
		j = 0
		while j < 2:
			if x[j] == a[i] and count == 0:
				print('YES')
				count = count + 1
			j = j + 1
	i = i + 1
if count == 0:
	print('NO')


m = input()
n = input().split()
s = 0
for i in range(5):
	if m[0] == n[i][0] or m[1] == n[i][1]:
		s = 1
		break
if s:
	print('YES')
else:
	print('NO')


s = input()
l = list(map(str, input().split()))
c = 0
for i in range(len(l)):
	if s[0] == l[i][0] or s[1] == l[i][1]:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


t = input()
H = input().split()
for c in H:
	if c[0] == t[0] or c[1] == t[1]:
		print('YES')
		quit()
print('NO')


str = input()
karti = input()
if str[0] in karti:
	print('YES')
elif str[1] in karti:
	print('YES')
else:
	print('NO')


from sys import stdin
inp = stdin.readline
table = inp().strip()
hand = inp().strip().split()
canPlay = False
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		canPlay = True
		break
print('YES' if canPlay else 'NO')


table = input()
inp = input()
hand = inp.split(' ')
x = 0
for i in range(5):
	if table[0] in hand[i]:
		x = 1
		break
	if table[1] in hand[i]:
		x = 1
		break
if x == 0:
	print('NO')
else:
	print('YES')


import sys
input = sys.stdin.readline
card = list(input().split())
hand = list(input().split())
yes = False
for i in card[0]:
	for j in hand:
		if i == j[0] or i == j[1]:
			yes = True
print('YES' if yes else 'NO')


a = input()
s = set(input())
print('NYOE S'[a[0] in s or a[1] in s::2])


def check_if_move_exists(table, arr):
	for i in arr:
		if table[0] == i[0]:
			return 'YES'
		elif table[1] == i[1]:
			return 'YES'
	return 'NO'
table = input()
arr = [x for x in input().split(' ')]
print(check_if_move_exists(table, arr))


st1 = input()
cnt = 0
l = [s for s in input().split()]
for i in range(len(l)):
	if st1[0] == l[i][0] or st1[1] == l[i][1]:
		print('YES')
		break
	else:
		cnt += 1
if cnt == 5:
	print('NO')


x = input()
y = input()
if x[0] in y or x[1] in y:
	print('YES')
else:
	print('NO')


card_tb = input('')
card_hd = input('').split(' ')
tg_rank = card_tb[0]
tg_suit = card_tb[1]
for item in card_hd:
	cur_rank = item[0]
	cur_suit = item[1]
	if cur_rank == tg_rank or cur_suit == tg_suit:
		print('YES')
		exit()
print('NO')


s = input()
p = list(map(str, input().split()))
k = 0
c = []
for i in p:
	for j in i:
		c.append(j)
for i in s:
	if i in c:
		print('YES')
		break
	else:
		k = k + 1
if k == 2:
	print('NO')


tableCard = input()
cards = input().split()
flag = 0
for card in cards:
	rank = card[0]
	suit = card[1]
	tabelRank = tableCard[0]
	tableSuit = tableCard[1]
	if rank == tabelRank or suit == tableSuit:
		flag = 1
		break
if flag == 0:
	print('NO')
else:
	print('YES')


table_card = input()
five_cards = input().split(' ')
for i in five_cards:
	if i[0] == table_card[0] or i[1] == table_card[1]:
		print('YES')
		exit()
print('NO')


n = input()
a = [x for x in input().split()]
count = 0
for elem in a:
	if n[0] in elem or n[1] in elem:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


n = list(input())
flag = False
for i in input().split():
	if i[0] == n[0] or i[1] == n[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


str = input()
cards = input().split()
flg = 0
for x in cards:
	if x[0] == str[0] or x[1] == str[1]:
		print('YES')
		flg = 1
		break
if flg == 0:
	print('NO')


s = str(input())
arr = map(str, input().split())
a = s[0]
b = s[1]
cond = False
for ele in arr:
	if a in ele or b in ele:
		cond = True
	else:
		pass
if cond == True:
	print('YES')
else:
	print('NO')


s = input()
l = list(input().split())
for i in range(len(l)):
	if s[0] == l[i][0]:
		print('YES')
		break
	elif s[1] == l[i][1]:
		print('YES')
		break
else:
	print('NO')


import re
onTable = str(input())
inHand = str(input())
mastid = []
numbrid = []
i = int(0)
x = int(0)
inHand = re.sub(' ', '', inHand)
while i < len(inHand):
	if i % 2 == 0:
		numbrid.append(inHand[i])
	elif i % 2 != 0:
		mastid.append(inHand[i])
	else:
		break
	i += 1
if onTable[0] in numbrid or onTable[1] in mastid:
	print('YES')
else:
	print('NO')


def main():
	card_on_the_table = input()
	cards_in_your_hand = list(input().split())
	can_play = False
	for card_in_your_hand in cards_in_your_hand:
		if card_in_your_hand[0] == card_on_the_table[0] or card_in_your_hand[1] == card_on_the_table[1]:
			can_play = True
			break
	print('YES' if can_play else 'NO')
main()


[a, b] = [x for x in input()]
L = [x for x in input()]
print('YES' if a in L or b in L else 'NO')


table_card = input()
hand_cards = input().split()
f = 0
for i in range(5):
	if table_card[0] == hand_cards[i][0] or table_card[1] == hand_cards[i][1]:
		f += 1
if f > 0:
	print('YES')
else:
	print('NO')


a = input()
b = []
c = 0
b = [x for x in input().split()]
for i in range(5):
	if a[0] == b[i][0] or a[1] == b[i][1]:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


table = input()
hand = [list(i) for i in input().split()]
play = False
for (rank, suit) in hand:
	if rank == table[0] or suit == table[1]:
		print('YES')
		play = True
		break
if play == False:
	print('NO')


d1 = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
d2 = ['D', 'C', 'S', 'H']
x = str(input())
f = x[0]
g = x[1]
s = str(input())
o = s.split()
f0 = [l[0] for l in o]
g0 = [l[1] for l in o]
if f in f0 or g in g0:
	print('YES')
else:
	print('NO')


def split(word):
	return [char for char in word]
card = input()
card = split(card)
deck = input()
deck = split(deck)
result = 'NO'
for i in card:
	for j in deck:
		if i == j:
			result = 'YES'
			break
print(result)


s = str(input())
t = list(map(str, input().split()))
for j in t:
	for i in range(len(s)):
		if s[i] in j:
			print('YES')
			exit()
print('NO')


a = input()
b = input()
count = 0
for i in b:
	if i in a:
		print('YES')
		break
	else:
		count += 1
if count == 14:
	print('NO')


curr = input()
n = input().split()
myString = ''
for x in n:
	myString += x
if curr[0] in myString or curr[1] in myString:
	print('YES')
else:
	print('NO')


ans = 'NO'
a = input()
for i in input().split():
	if i[0] == a[0] or i[1] == a[1]:
		ans = 'YES'
print(ans)


t = input()
A = input().split()
b = False
for x in A:
	if t[0] in x or t[1] in x:
		b = True
		break
print('YES' if b else 'NO')


SUIT = 'D,C,S,H'.split(',')
RANK = '2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A'.split(', ')
desk = input()
hand = input().split()

def c(desk, hand):
	for card in hand:
		if card[0] == desk[0]:
			return 'YES'
		if card[1] == desk[1]:
			return 'YES'
	return 'NO'
print(c(desk, hand))


q = input()
r = 0
t = 0
u = 0
y = 0
a = input().split()
for i in range(10):
	e = a[r]
	if q[t] == e[u]:
		print('YES')
		y = 1
		break
	r = r + 1
	if r > 4:
		r = r - 5
	u = u + 1
	if u > 1:
		u = u - 2
	t = t + 1
	if t > 1:
		t = t - 2
if y == 0:
	print('NO')


flag = 0
a = []
s = input()
ss = list(map(str, input().split()))
for i in ss:
	for j in i:
		a.append(j)
for i in s:
	if i in a:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


s = input()
string = input()
b = 0
for i in range(0, len(s)):
	if s[i] in string:
		print('YES')
		b = 1
		break
if b == 0:
	print('NO')


table = input()
hand = input().split()
play = False
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		play = True
		break
print('YES') if play else print('NO')


import time

def main():
	n = list(input())
	k = input()
	flag = False
	for i in k:
		if i == n[0] or i == n[1]:
			return print('YES')
			flag = True
	if flag == False:
		return print('NO')
main()


table = input()
hand = input().split()
a = False
for i in hand:
	if i[0] == table[0] or i[1] == table[1]:
		a = True
if a:
	print('YES')
else:
	print('NO')


r = input('')
s = input().split()
w = 0
for k in s:
	if r[0] == k[0] or r[1] == k[1]:
		w += 1
if w > 0:
	print('YES')
else:
	print('NO')


table = input()
table = list(table)
hand = input()
hand = list(hand)
k = False
for i in range(0, 14):
	if table[0] == hand[i] or table[1] == hand[i]:
		k = True
if k:
	print('YES')
else:
	print('NO')


s = input()
ss = input().split()
for i in ss:
	if s[0] == i[0] or s[1] == i[1]:
		print('YES')
		exit()
print('NO')


carta_board = input()
carta_hand = input().replace(' ', '')
if carta_hand.find(carta_board[0]) >= 0 or carta_hand.find(carta_board[1]) >= 0:
	print('YES')
else:
	print('NO')


c = input()
lis = list(map(str, input().split()))
flag = 0
for card in lis:
	if c[0] == card[0]:
		flag = 1
	elif c[1] == card[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


def is_playable(on_table, in_hands):
	for t in on_table:
		if t in in_hands:
			return 'YES'
	return 'NO'
on_table = input()
in_hands = input()
print(is_playable(on_table, in_hands))


deck = set(input())
hand = input()
verify = 0
for x in deck:
	if x in hand:
		verify += 1
print('YES' if verify > 0 else 'NO')


s = input()
(rank, suit) = (s[0], s[1])
cards_in_hand = input().split()
card_1_rank = cards_in_hand[0][0]
card_1_suit = cards_in_hand[0][1]
card_2_rank = cards_in_hand[1][0]
card_2_suit = cards_in_hand[1][1]
card_3_rank = cards_in_hand[2][0]
card_3_suit = cards_in_hand[2][1]
card_4_rank = cards_in_hand[3][0]
card_4_suit = cards_in_hand[3][1]
card_5_rank = cards_in_hand[4][0]
card_5_suit = cards_in_hand[4][1]
rank_in_hand = [card_1_rank, card_2_rank, card_3_rank, card_4_rank, card_5_rank]
suits_in_hand = [card_1_suit, card_2_suit, card_3_suit, card_4_suit, card_5_suit]
if rank in rank_in_hand or suit in suits_in_hand:
	print('YES')
else:
	print('NO')


card = input()
cards = input().split(' ')
canPlay = False
for c in cards:
	if c[0] == card[0] or c[1] == card[1]:
		canPlay = True
		break
if canPlay:
	print('YES')
else:
	print('NO')


in_hand = input()
on_table = input().split()
for i in range(5):
	if in_hand[0] in on_table[i][0]:
		print('YES')
		break
	elif in_hand[1] in on_table[i][1]:
		print('YES')
		break
else:
	print('NO')


table = input()
cards = input()
if (table[0] in cards) | (table[1] in cards):
	print('YES')
else:
	print('NO')


s = input()
hand = input()
list = []
for j in hand:
	list.append(j)
count = 0
for i in s:
	if list.count(i) > 0:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


n = input().strip()
hand = input().strip().split()
isIt = False
for i in hand:
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		isIt = True
		break
if not isIt:
	print('NO')


a = input()
b = list(map(str, input().split()))
b = ''.join(b)
if a[0] in b or a[1] in b:
	print('YES')
else:
	print('NO')


s = input()
(q1, q2, q3, q4, q5) = map(str, input().split())
i = s[0]
j = s[1]
ans = 'NO'
if q1.count(j) != 0 or q1.count(i) != 0:
	ans = 'YES'
if q2.count(j) != 0 or q2.count(i) != 0:
	ans = 'YES'
if q3.count(j) != 0 or q3.count(i) != 0:
	ans = 'YES'
if q4.count(j) != 0 or q4.count(i) != 0:
	ans = 'YES'
if q5.count(j) != 0 or q5.count(i) != 0:
	ans = 'YES'
print(ans)


card_table = input()
a = card_table[0]
b = card_table[1]
cards = input()
if a in cards:
	print('YES')
elif b in cards:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split(' ')
result = 'NO'
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		result = 'YES'
		break
print(result)


import math
import os
import random
import re
import sys
s = input()
a = input()
if s[0] in a:
	print('YES')
elif s[1] in a:
	print('YES')
else:
	print('NO')


s = input()
l = list(map(str, input().split()))
flag = 0
for item in l:
	if item[0] == s[0] or item[1] == s[1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


(x, y) = input()
c = input()
if x in c or y in c:
	print('YES')
else:
	print('NO')


table = input()
onHand = [list(x) for x in input().split(' ')]
card = []
for i in onHand:
	for j in i:
		card.append(j)
table = list(table)
for i in card:
	if i in table:
		flag = True
		break
	else:
		flag = False
if flag == True:
	print('YES')
else:
	print('NO')


a = input()
b = input()
c = 0
v = 0
m = 'D C S H'
z = '2 3 4 5 6 7 8 9 T J Q K A'
for i in range(len(z)):
	if z[i] in a and z[i] in b:
		v += 1
	else:
		c += 1
for i in range(len(m)):
	if m[i] in a and m[i] in b:
		v += 1
	else:
		c += 1
if v >= 1:
	print('YES')
elif c >= 2:
	print('NO')


(a, lista) = (input(), input().split())
can = False
for i in lista:
	if i[0] == a[0] or i[1] == a[1]:
		can = True
		break
if can:
	print('YES')
else:
	print('NO')


table = input()
q = False
s = list(input().split())
for i in range(5):
	if table[0] == s[i][0] or table[1] == s[i][1]:
		q = True
if q:
	print('yes'.upper())
else:
	print('no'.upper())


s = input()
l = list(map(str, input().split()))
Flag = False
for i in l:
	if s[0] == i[0]:
		Flag = True
		print('YES')
		break
if Flag == False:
	for i in l:
		if s[1] == i[1]:
			Flag = True
			print('YES')
			break
if Flag == False:
	print('NO')


q = input()
p = input()
p = p.replace(' ', '')
p = p.replace('', ' ')
p = p.split()
q = q.replace('', ' ')
q = q.split()
c = 0
for i in range(2):
	if q[i] in p:
		c += 1
if c == 0:
	print('NO')
else:
	print('YES')


a = input()
count = 0
x = []
x = [str(x) for x in input().split()]
c = x[0]
d = x[1]
e = x[2]
f = x[3]
g = x[4]
if a[0] == c[0] or a[1] == c[1]:
	print('YES')
elif a[0] == d[0] or a[1] == d[1]:
	print('YES')
elif a[0] == e[0] or a[1] == e[1]:
	print('YES')
elif a[0] == f[0] or a[1] == f[1]:
	print('YES')
elif a[0] == g[0] or a[1] == g[1]:
	print('YES')
else:
	print('NO')


a = input()
l = input().split()
w = 'NO'
for x in l:
	if x[1] == a[1] or x[0] == a[0]:
		w = 'YES'
print(w)


(a, b) = input()
c = set(input())
if a in c or b in c:
	print('YES')
else:
	print('NO')


s = input().strip()
d = input().strip()
l = d.split(' ')
k = 1
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		k = 0
		print('YES')
		break
if k:
	print('NO')


karta = input()
l = list(map(str, input().split()))
mozes = False
b = 0
for i in karta:
	if b == 0:
		broj = i
		b += 1
	else:
		boja = i
for i in l:
	if boja in i or broj in i:
		mozes = True
if mozes:
	print('YES')
else:
	print('NO')


card = input()
my_cards = input().split()
for x in my_cards:
	if x[0] == card[0] or x[1] == card[1]:
		print('YES')
		break
else:
	print('NO')


s = input()
ss = input().split()
for e in ss:
	if e[0] == s[0] or e[1] == s[1]:
		print('YES')
		break
else:
	print('NO')


suit = ['D', 'C', 'S', 'H']
rank = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
table_card = input()
hand_cards = input().split()
ans = ''
for i in range(len(hand_cards)):
	if hand_cards[i][0] == table_card[0]:
		ans = 'YES'
		break
	elif hand_cards[i][1] == table_card[1]:
		ans = 'YES'
		break
	else:
		ans = 'NO'
print(ans)


import sys
on_table = sys.stdin.readline().strip()
on_hands = sys.stdin.readline().strip().split()
dignity = set()
suit = set()
for now_card in on_hands:
	dignity.add(now_card[0])
	suit.add(now_card[1])
if on_table[0] in dignity or on_table[1] in suit:
	print('YES')
else:
	print('NO')


x = input()
arr = list(map(str, input().split()))
for el in arr:
	if el[0] == x[0] or el[1] == x[1]:
		print('YES')
		exit()
print('NO')


str = input()
str1 = input()
k = 0
l = 1
flag = False
while k < len(str1):
	if str[0] == str1[k] or str[1] == str1[l]:
		print('YES')
		flag = True
		break
	else:
		k += 3
		l += 3
if flag == False:
	print('NO')


t = input()
a = list(input().split())
for i in a:
	if t[0] == i[0] or t[1] == i[1]:
		print('YES')
		exit()
print('NO')


import collections
import math
import itertools
try:
	n = input()
	x = list(map(str, input().split()))
	p = 0
	for i in range(0, len(x)):
		if n[0] == x[i][0] or n[1] == x[i][1]:
			p = 1
			break
	if p == 1:
		print('YES')
	else:
		print('NO')
except:
	pass


(a, b) = input()
h = input()
print(('NO', 'YES')[a in h or b in h])


def gennadyPartnerTask(ontable, cards):
	for (c, s) in cards:
		if ontable[0] == c or ontable[1] == s:
			return 'YES'
	return 'NO'
ontable = input()
cards = [i for i in input().split()]
op = gennadyPartnerTask(ontable, cards)
print(op)


card = input()
cards = input().split()
for i in range(5):
	if cards[i][0] == card[0] or cards[i][1] == card[1]:
		print('YES')
		exit()
print('NO')


s = input()
s2 = list(map(str, input().split()))
s1 = ''
lst = s1.join(s2)
count = 0
for i in s:
	if i in lst:
		count += 1
	else:
		pass
if count > 0:
	print('YES')
else:
	print('NO')


on_table = input()
in_hand = input().split(' ')
fin = 0
for x in in_hand:
	if on_table[0] == x[0]:
		fin = 1
	if on_table[1] == x[1]:
		fin = 1
if fin == 1:
	print('YES')
else:
	print('NO')


s = input()
L = list(input().split())
co = False
for i in range(len(L)):
	if L[i][0] == s[0] or L[i][1] == s[1]:
		print('YES')
		co = True
		break
if not co:
	print('NO')


a = input()
b = input()
print('YES' if b.find(a[0]) != -1 or b.find(a[1]) != -1 else 'NO')


n = input()
s = input()
l = s.split()
c = 0
for i in range(len(l)):
	if l[i][0] == n[0] or l[i][1] == n[1]:
		c += 1
		break
if c > 0:
	print('YES')
else:
	print('NO')


a = list(input())
b = list(''.join(input().split()))
d = set(a) & set(b)
if d == set():
	print('NO')
else:
	print('YES')


a = input()
b = [i for i in input().split()]
for i in b:
	if a[0] in i or a[1] in i:
		print('YES')
		exit()
print('NO')


S = input()
A = list(map(str, input().split()))
B = [i[0] for i in A]
C = [i[1] for i in A]
if S[0] in B or S[0] in C or S[1] in B or (S[1] in C):
	print('YES')
else:
	print('NO')


table_card = list(input())
my_cards = input()

def solve():
	for card in my_cards:
		if card in table_card:
			print('YES')
			return
	print('NO')
	return
solve()


s = input()
T = input().split()
for t in T:
	if s[0] == t[0] or s[1] == t[1]:
		print('YES')
		exit()
print('NO')


c = input()
x = 1
string = input()
for i in c:
	if i in string:
		print('YES')
		x = 0
		break
if x:
	print('NO')


tab = input()
inp = list(map(str, input().split()))
flag = False
for i in range(5):
	if inp[i][0] == tab[0]:
		flag = True
		break
	if inp[i][1] == tab[1]:
		flag = True
		break
if flag == True:
	print('YES')
else:
	print('NO')


print('NYOE S'[bool(set(input()) & set(input()))::2])


tb = input()
l = input().split(' ')
for item in l:
	if item[0] == tb[0] or item[1] == tb[1]:
		print('YES')
		exit(0)
print('NO')


s = input()
first = input().split()
c = 0
for card in first:
	if s[:1] in card:
		print('YES')
		break
	if s[-1] in card:
		print('YES')
		break
	c = c + 1
if c == 5:
	print('NO')


ranks = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
suits = ['D', 'C', 'S', 'H']
hand = input()
on_desk = list(map(str, input().split()))
rank_list = [i[0] for i in on_desk]
suit_list = [i[1] for i in on_desk]
if hand[0] in rank_list or hand[1] in suit_list:
	print('YES')
else:
	print('NO')


fc = input()
cards = input()
if fc[0] in cards or fc[1] in cards:
	print('YES')
else:
	print('NO')


cd = list(input())
s = cd[0]
t = cd[1]
ls = input().split(' ')
f = False
for i in ls:
	i = list(i)
	u = i[0]
	v = i[1]
	if s == u or t == v:
		f = True
print(['NO', 'YES'][f])


k = str(input())
x = [str(y) for y in input().split()]
f = 1
for i in x:
	if i[-1] == k[-1] or i[0] == k[0]:
		f = 0
		break
print('NO' if f == 1 else 'YES')


s = input()
hand = input().split()
rank = [x[0] for x in hand]
suit = [x[1] for x in hand]
if s[0] in rank or s[1] in suit:
	print('YES')
else:
	print('NO')


hand = input()
desk = input().split()

def tusk(hand, desk):
	for d in desk:
		if d[0] == hand[0] or d[1] == hand[1]:
			return 'YES'
	return 'NO'
print(tusk(hand, desk))


a = input()
s = input()
if a[0] in s or a[1] in s:
	print('YES')
else:
	print('NO')


t = input()
a = [x for x in input().split()]
for i in a:
	if i[0] == t[0] or i[1] == t[1]:
		print('YES')
		break
else:
	print('NO')


s = str(input())
l = input().split()
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		break
else:
	print('NO')


def A1097(card_table, card_hand):
	for card in card_hand:
		if card_table[0] == card[0] or card_table[1] == card[1]:
			return True
	return False
card_table = input().upper()
card_hand = input().split(' ')
result = A1097(card_table, card_hand)
if result:
	print('YES')
else:
	print('NO')


def solve(x, y, lis):
	return 'YES' if x in lis or y in lis else 'NO'

def main():
	(a, b) = input()
	arr = input()
	print(solve(a, b, arr))
main()


import sys
a = sys.stdin.readline().split()
b = a[0][1]
a = a[0][0]
c = sys.stdin.readline().split()
t = 'NO'
for i in range(0, 5):
	if a == c[i][0] or b == c[i][1]:
		t = 'YES'
		i = 5
	else:
		i += 1
print(t)


table = input()
hand = input().split()
if table[0] in set((c[0] for c in hand)) or table[1] in set((c[1] for c in hand)):
	print('YES')
else:
	print('NO')


s = str(input())
sp = list(input().split(' '))
for i in sp:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		s = 'P'
		break
if s is not 'P':
	print('NO')


table = input()
hands = input().split(' ')
yes = False
tRank = table[0]
tSuit = table[1]
for card in hands:
	hRank = card[0]
	hSuit = card[1]
	if hRank == tRank or hSuit == tSuit:
		yes = True
if yes == True:
	print('YES')
else:
	print('NO')


card = input()
hand = [f for f in input().split()]
flag = 1
for i in hand:
	if card[0] == i[0] or card[1] == i[1]:
		print('YES')
		flag = 0
		break
if flag:
	print('NO')


k = list(input())
A = list(input().split())
c = 1
for i in A:
	if i[0] == k[0] or i[1] == k[1]:
		print('YES')
		c = 0
		break
if c:
	print('NO')


main = input()
cards = [x for x in input().split()]
flag = True
for card in cards:
	if main[0] == card[0] or main[1] == card[1]:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


play = input()
l = list(map(str, input().split()))
flag = 0
for i in l:
	if play[0] in i or play[1] in i:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


import math
import sys
from sys import *
from bisect import insort
import heapq
import collections
from collections import deque, defaultdict
from itertools import permutations, combinations, combinations_with_replacement
import random
import os
mod = 10 ** 9 + 7
MAX = sys.maxsize
MIN = -sys.maxsize - 1

def isPrime(n):
	if n > 1:
		for i in range(2, n):
			if n % i == 0:
				return False
		else:
			return True
	else:
		return False

def isPanagram(s):
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for char in alphabet:
		if char not in s.lower():
			return False
	return True

def isEqual(list1):
	if len(list1) < 0:
		res = True
	res = all((ele == list1[0] for ele in list1))
	if res:
		return True
	else:
		return False

def remove_duplicate(list1):
	final_list = []
	for i in list1:
		if i not in final_list:
			final_list.append(i)
	return final_list % mod

def solve():
	n = input()
	arr = list(map(str, input().split()))
	for i in arr:
		if i[0] == n[0] or i[1] == n[1]:
			return 'YES'
	return 'NO'
result = solve()
stdout.write(str(result) + '\n')


a = input().strip()
b = list(map(str, input().strip().split()))
num = 0
for key in b:
	if a[0] == key[0] or a[1] == key[1]:
		num += 1
if num > 0:
	print('YES')
else:
	print('NO')


(i, j, f) = (input(), input().split(' '), 0)
for k in j:
	if i[0] == k[0] or i[1] == k[1]:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


table = input()
arr = list(input().split())
rank = table[0]
suit = table[1]
rct = 0
sct = 0
for i in range(len(arr)):
	if rank == arr[i][0]:
		rct = rct + 1
for i in range(len(arr)):
	if suit == arr[i][1]:
		sct = sct + 1
if rct == 0 and sct == 0:
	print('NO')
else:
	print('YES')


n = input()
l = list(input().split())[0:5]
for i in l:
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		break
else:
	print('NO')


def ask(rank, suit, hand):
	for (r, s) in hand:
		if r == rank or s == suit:
			print('YES')
			return
	print('NO')
(rank, suit) = list(input())
hand = list(map(list, input().split()))
ask(rank, suit, hand)


a = str(input())
b = str(input())
c = list(a)
d = c[0]
e = c[1]
f = b.count(d)
g = b.count(e)
if f >= 1 or g >= 1:
	print('YES')
else:
	print('NO')


t = input()
h = input().split()
flag = False
for j in h:
	if j[0] == t[0] or j[1] == t[1]:
		print('YES')
		flag = True
		break
if flag == False:
	print('NO')


X = input()
B = list(input().split())
for x in B:
	if x[0] == X[0] or x[1] == X[1]:
		print('YES')
		return
print('NO')


def fun():
	for i in range(len(l)):
		if l[i][1] == c[1] or l[i][0] == c[0]:
			print('YES')
			return
	print('NO')
c = input()
l = input().split()
fun()


x = input()
y = input()
l = 0
ans = 0
for i in y:
	if x[0] == y[l] or x[1] == y[l]:
		ans = 'YES'
		if ans == 'YES':
			print(ans)
			break
	l += 1
if ans == 0:
	print('NO')


n = input()
s = input().split()
a = [s[0] + s[1] + s[2] + s[3] + s[4]]
for i in a:
	q = str(i)
	if n[0] in q or n[1] in q:
		print('YES')
	else:
		print('NO')


def main():
	n = input()
	vals = input().split()
	for v in vals:
		if v[0] == n[0]:
			print('YES')
			return
		if v[1] == n[1]:
			print('YES')
			return
	print('NO')
main()


a = input()
l = list(map(str, input().split()))
k = 0
for i in l:
	if a[0] == i[0] or a[1] == i[1]:
		k = 1
		break
if k == 1:
	print('YES')
elif k == 0:
	print('NO')


st = input()
st1 = input()
ls = st1.split()
a = ls[0]
b = ls[1]
c = ls[2]
d = ls[3]
e = ls[4]
if st[0] == a[0] or st[1] == a[1] or st[0] == b[0] or (st[1] == b[1]) or (st[0] == c[0]) or (st[1] == c[1]) or (st[0] == d[0]) or (st[1] == d[1]) or (st[0] == e[0]) or (st[1] == e[1]):
	print('YES')
else:
	print('NO')


c = input()
g = input().split()
a = 1
for i in g:
	if i[0] == c[0] or i[0] == c[1] or i[1] == c[0] or (i[1] == c[1]):
		print('YES')
		a = 0
		break
if a:
	print('NO')


s = input()
sa = input()
print('YES' if s[0] in sa or s[1] in sa else 'NO')


def solve():
	sc = input()
	c = input().split()
	for i in c:
		if i[0] == sc[0] or i[1] == sc[1]:
			print('YES')
			return
	print('NO')
solve()


on_the_table = input().lower()
to_checks = input().lower()
ok = 0
for c in on_the_table:
	if c in to_checks:
		ok = 1
		break
print('YES' if ok else 'NO')


table = input()
list_cards = input().split()
test = 'NO'
indice = 0
while test == 'NO' and indice < len(list_cards):
	if list_cards[indice][0] == table[0] or list_cards[indice][1] == table[1]:
		test = 'YES'
	indice += 1
print(test)


t = input()
t = list(t)
a = list(map(str, input().split()))
w = 0
for i in range(5):
	for j in range(2):
		if a[i][j] in t:
			print('YES')
			w = 1
			break
	if w == 1:
		break
if w == 0:
	print('NO')


a = input()
flag = 0
b = input()
b = b.replace(' ', '')
j = 0
for i in range(5):
	if b[j] == a[0] or b[j + 1] == a[1]:
		print('YES')
		flag = 1
		break
	j += 2
if flag == 0:
	print('NO')


ta = input()
hand = list(input().split())
c = 0
for i in range(5):
	if ta[0] in hand[i] or ta[1] in hand[i]:
		c += 1
if c > 0:
	print('YES')
else:
	print('NO')


tab = input()
hand = input()
if tab[0] in hand or tab[1] in hand:
	print('YES')
else:
	print('NO')


card = input()
hand = [x for x in input().split()]
result = 'NO'
for i in range(5):
	for j in range(2):
		if card[j] == hand[i][j]:
			result = 'YES'
			break
print(result)


kart = input()
karts = list(map(str, input().split()))
z = 0
for i in range(len(karts)):
	if kart[0] in karts[i] or kart[1] in karts[i]:
		z = 1
		break
if z == 1:
	print('YES')
else:
	print('NO')


table = input()
rank = table[0]
suit = table[1]
hand = [str(x) for x in input().strip().split()]
hand_rank = [h[0] for h in hand]
hand_suit = [h[1] for h in hand]
l = len(hand)
count = 0
if rank in hand_rank:
	count = 1
elif suit in hand_suit:
	count = 1
if count == 0:
	print('NO')
else:
	print('YES')


ranks = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A']
ranks = list(map(str, ranks))
suits = ['D', 'C', 'S', 'H']
(t_rank, t_suit) = list(input())
cards_hand = input().split(' ')
flag = 'NO'
for card in cards_hand:
	(h_rank, h_suit) = list(card)
	if h_rank == t_rank or h_suit == t_suit:
		flag = 'YES'
		break
print(flag)


first_card = input()
cards = [i for i in input().split()]
for card in cards:
	if card[0] == first_card[0] or card[1] == first_card[1]:
		print('YES')
		break
else:
	print('NO')


hand = input()
table = input().split(' ')
res = 'NO'
for i in table:
	if i[0].lower() == hand[0].lower() or i[1].lower() == hand[1].lower():
		res = 'YES'
		break
print(res)


cot = input()
cih = list(input().split())
for cards in cih:
	if cot[0] == cards[0] or cot[1] == cards[1]:
		print('YES')
		break
else:
	print('NO')


table = input()
hand = list(map(str, input().split()))
flag = 0
for i in range(0, len(hand)):
	if hand[i][0] == table[0]:
		flag = 1
		break
	if hand[i][1] == table[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(a, b) = list(input())
l = list(input().split())
ans = 'NO'
for i in range(5):
	if l[i][0] == a or l[i][1] == b:
		ans = 'YES'
print(ans)


n = input()
m = list(n)
l1 = []
l2 = []
o = 0
a = input()
l1.append(a[0])
l1.append(a[3])
l1.append(a[6])
l1.append(a[9])
l1.append(a[12])
l2.append(a[1])
l2.append(a[4])
l2.append(a[7])
l2.append(a[10])
l2.append(a[13])
for i in m:
	if o == 1:
		break
	for j in range(5):
		if i == l1[j] or i == l2[j]:
			print('YES')
			o = 1
			break
if o == 0:
	print('NO')


a = list(input())
b = list(input())
res = list(set(a) & set(b))
if res != []:
	print('YES')
else:
	print('NO')


table = input()
mycards = input().split(' ')
cards = [x for x in mycards]
ok = False
for card in cards:
	if card[0] == table[0] or card[1] == table[1]:
		ok = True
		break
if ok:
	print('YES')
else:
	print('NO')


a = input()
k = 0
arr_cards = input().split()
for i in arr_cards:
	if i[0] == a[0] or i[1] == a[1]:
		print('YES')
		break
	else:
		k += 1
if k == len(arr_cards):
	print('NO')


x = input()
y = list(input().split())
FLAG = 0
for i in range(len(y)):
	if y[i][0] == x[0] or y[i][1] == x[1]:
		FLAG = 1
		break
if FLAG == 0:
	print('NO')
else:
	print('YES')


card_table = input()
card_hand = input()
if card_table[0] in card_hand or card_table[1] in card_hand:
	print('YES')
else:
	print('NO')


card_table = input().rstrip().replace(' ', '')
card_hand = input().rstrip().replace(' ', '')
check_table = {}
for c in card_hand:
	check_table[c] = 1 if c != ' ' else 0
print('YES') if card_table[0] in check_table or card_table[1] in check_table else print('NO')


c = input()
card = c[0]
set_no = c[1]
cardlist = list(input().split(' '))
res = False
for c in cardlist:
	if c[0] == card or c[1] == set_no:
		res = True
		break
if res == True:
	print('YES')
else:
	print('NO')


n = input()
lis = [str(x) for x in input().split()]
s = ''.join(lis)
if s.count(n[0]) > 0 or s.count(n[1]) > 0:
	print('YES')
else:
	print('NO')


input_1 = input()
input_2 = input()
input_2 = input_2.split(' ')
table_card_rank = input_1[0]
table_card_suit = input_1[1]
control = False
for index in range(5):
	card_rank = input_2[index][0]
	card_suit = input_2[index][1]
	if card_rank == table_card_rank or card_suit == table_card_suit:
		control = True
		break
	else:
		control = False
if control == True:
	print('YES')
else:
	print('NO')


n = input()
l = list(input().split())
c = 0
for i in range(len(n)):
	for j in l:
		if n[i] in j:
			print('YES')
			c = 1
			break
	if c == 1:
		break
if c == 0:
	print('NO')


def solve():
	t = list(input())
	a = input().split()
	for x in range(5):
		if t[0] in a[x] or t[1] in a[x]:
			print('YES')
			return
	print('NO')
solve()


(first, five) = (input(), input())
print(['NO', 'YES'][first[0] in five[::3] or first[1] in five[1::3]])


n = input()
t = input().split()
for i in t:
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		break
else:
	print('NO')


table_card = input()
hand_cards = input().split()
for hand_card in hand_cards:
	if hand_card[0] == table_card[0] or hand_card[1] == table_card[1]:
		print('YES')
		break
else:
	print('NO')


c = input()
l = input().split()
P = 'NO'
for i in l:
	if i[0] == c[0] or i[1] == c[1]:
		P = 'YES'
		break
print(P)


n = input()
strk = input().split()
strk = str(strk)
if n[0] in strk or n[1] in strk:
	print('YES')
else:
	print('NO')


def main():
	card = input()
	rank = card[0]
	suit = card[1]
	cards = list(map(str, input().split()))
	ranks = []
	suits = []
	for i in cards:
		ranks.append(i[0])
		suits.append(i[1])
	if rank in ranks or suit in suits:
		print('YES')
	else:
		print('NO')
main()


input1 = input()
input2 = input().split()
if input1[0] in [i[0] for i in input2] or input1[1] in [i[1] for i in input2]:
	print('YES')
else:
	print('NO')


x = input().strip()
y = input().strip().split()
if x[0] in [z[0] for z in y]:
	print('YES')
elif x[1] in [z[1] for z in y]:
	print('YES')
else:
	print('NO')


value = input()
lst = input()
if value[0] in lst or value[1] in lst:
	print('YES')
else:
	print('NO')


a = ''
a = input()
b = []
b = list(input().split())
c = False
for i in b:
	if a[0] == i[0]:
		c = True
		break
	elif a[1] == i[1]:
		c = True
		break
if c:
	print('YES')
else:
	print('NO')


a = input()
v = 0
b = [i for i in input().split()]
x = a[0]
y = a[1]
for i in b:
	if i[0] == x or i[1] == y:
		v = 1
		print('YES')
		break
if v == 0:
	print('NO')


n = input()
cards = input()
output = 0
cards = cards.split(' ')
for card in cards:
	if n[0] in card or n[1] in card:
		output = 1
if output == 1:
	print('YES')
else:
	print('NO')


n1 = list(input())
n2 = list(input().replace(' ', ''))
for i in n1:
	if i in n2:
		print('YES')
		break
else:
	print('NO')


import sys
s = input()
list = list(map(str, input().split()))
for i in range(0, 5):
	if list[i][0] == s[0] or list[i][1] == s[1]:
		print('YES')
		sys.exit()
print('NO')


a = input()
table = [i for i in a]
hand = input().split()
cards = []
for i in hand:
	x = [j for j in i]
	cards = cards + x
ans = 'NO'
for i in table:
	if i in cards:
		ans = 'YES'
	else:
		continue
print(ans)


s = input()
a = s[0]
b = s[1]
q = input().split()
ans = 'NO'
for el in q:
	if el[0] == a or el[1] == b:
		ans = 'YES'
print(ans)


a = input()
(b1, b2, b3, b4, b5) = map(str, input().split())
if a[-1] == b1[-1] or a[-1] == b2[-1] or a[-1] == b3[-1] or (a[-1] == b4[-1]) or (a[-1] == b5[-1]) or (a[0] == b1[0]) or (a[0] == b2[0]) or (a[0] == b3[0]) or (a[0] == b4[0]) or (a[0] == b5[0]):
	print('YES')
else:
	print('NO')


inputcard = input()
ranklist = []
suitlist = []
for i in input().split():
	ranklist.append(i[0])
	suitlist.append(i[1])
if inputcard[0] in ranklist or inputcard[1] in suitlist:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
playable = 'NO'
table_rank = table[0]
table_suit = table[1]
hand_ranks = [card[0] for card in hand]
hand_suits = [card[1] for card in hand]
for suit in hand_suits:
	if suit == table_suit:
		playable = 'YES'
		break
if playable == 'NO':
	for rank in hand_ranks:
		if rank == table_rank:
			playable = 'YES'
			break
print(playable)


k1 = input()
k = input().split()
r = False
for j in k:
	if k1[0] == j[0] or k1[1] == j[1]:
		r = True
if r:
	print('YES')
else:
	print('NO')


def cards(hand, c):
	count = 0
	for i in c:
		if i not in hand:
			count += 1
	if count == 2:
		return 'NO'
	return 'YES'
x = input()
hand = input().strip()
print(cards(hand, x))


import sys
input = sys.stdin.readline

def main():
	card = insr()
	cards = insr()
	no = True
	for x in cards:
		if (x == card[0] or x == card[1]) and no:
			print('YES')
			no = False
	if no:
		print('NO')

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def instr():
	return ''.join(insr())

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
main()


no = input()
nos = input()
nos = nos.split()

def find(no1, nos1):
	for i in nos1:
		for j in no1:
			if j in i:
				return 'YES'
	return 'NO'
print(find(no, nos))


id_table = str(input())
name = [str(i) for i in input().split()]
first = ''
sec = ''
for i in name:
	first = first + i[0]
	sec = sec + i[1]
if id_table[0] in first or id_table[1] in sec:
	print('YES')
else:
	print('NO')


card_on_table = input().strip()
my_cards = input().split()
(table_rank, table_suit) = card_on_table
can_play = False
for i in range(len(my_cards)):
	(curr_rank, curr_suit) = my_cards[i]
	if curr_rank == table_rank or curr_suit == table_suit:
		can_play = True
		break
print('YES' if can_play else 'NO')


c = input()
l = list(map(str, input().split(' ')))
a = []
for i in l:
	for j in i:
		a.append(j)
for i in c:
	if i in a:
		print('YES')
		break
else:
	print('NO')


played = list(input())
hand = [list(i) for i in input().split()]
possible = False
for card in hand:
	if card[0] == played[0] or card[1] == played[1]:
		possible = True
		break
if possible:
	print('YES')
else:
	print('NO')


n = input()
l = list(input().split())
for i in l:
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		exit()
print('NO')


res = 'NO'
card = input()
hand = input().split(' ')
for i in hand:
	if card[0] == i[0] or card[1] == i[1]:
		res = 'YES'
		break
print(res)


s = input()
c = 0
l = list(map(str, input().split()))
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		c = 1
if c > 0:
	print('YES')
else:
	print('NO')


def card_game(inhand, A):
	for i in A:
		if inhand[0] == i[0] or inhand[1] == i[1]:
			return 'YES'
	return 'NO'
inhand = input()
A = list(input().split())
print(card_game(inhand, A))


card = input()
hand = input().split()
res = False
for hcard in hand:
	for (a, b) in zip(card, hcard):
		if a == b:
			res = True
			break
if res:
	print('YES')
else:
	print('NO')


n = input()
var = input().split()
b = False
for i in range(len(var)):
	if n[0] == var[i][0] or n[1] == var[i][1]:
		b = True
		break
print('YES' if b else 'NO')


(rank, suit) = input()
hand = input().split()
f = True
for card in hand:
	if rank in card or suit in card:
		print('YES')
		f = False
		break
if f:
	print('NO')


ct = input()
ch = input().split()

def f(param):
	if ct[1] in param[1] or ct[0] in param[0]:
		return True
	else:
		return False
try:
	list(filter(f, ch))[0][0] and print('YES')
except:
	print('NO')


a = str(input())
l = list(map(str, input().split()))
for i in a:
	f = 0
	if i == l[0][0] or i == l[0][1] or i == l[1][0] or (i == l[1][1]) or (i == l[2][0]) or (i == l[2][1]) or (i == l[3][0]) or (i == l[3][1]) or (i == l[4][0]) or (i == l[4][1]):
		f = 1
		break
	else:
		f = 0
if f == 1:
	print('YES')
else:
	print('NO')


l1 = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']
l2 = ['D', 'C', 'S', 'H']
c = input()
li = list(input().split(' '))
for i in li:
	if i[0] == c[0]:
		print('YES')
		exit()
	elif i[1] == c[1]:
		print('YES')
		exit()
	else:
		continue
print('NO')


c = input()
l = list(map(str, input().split()))
l1 = []
l2 = []
for i in l:
	l1.append(i[0])
	l2.append(i[1])
if c[0] in l1 or c[1] in l2:
	print('YES')
else:
	print('NO')


v = 'NO'
i = 0
z = input()
s = input()
while i < 5:
	if s[0 + i * 3] == z[0]:
		v = 'YES'
	i = i + 1
i = 0
while i < 5:
	if s[1 + i * 3] == z[1]:
		v = 'YES'
	i = i + 1
print(v)


a = input()
A = list(map(str, input().split()))
k = False
i = 0
while k != True and i != 5:
	if A[i][0] == a[0] or A[i][1] == a[1]:
		k = True
	else:
		i += 1
if k == True:
	print('YES')
else:
	print('NO')


a = input().strip()
A = [x.strip() for x in input().split()]
done = 0
for x in A:
	if a[0] == x[0] or a[1] == x[1]:
		print('YES')
		done = 1
		break
if not done:
	print('NO')


tabl = str(input())
hand = list(map(str, input().split(' ')))
res = 0
for i in (0, 1, 2, 3, 4):
	if tabl[0] == hand[i][0] or tabl[1] == hand[i][1]:
		res = 1
if res == 1:
	print('YES')
else:
	print('NO')


n = input()
s = input()
test = False
for c in n:
	if c in s:
		test = True
if test:
	print('YES')
else:
	print('NO')


C = input()
f = lambda x: x[0] == C[0] or x[1] == C[1]
print('YES' if len(list(filter(f, input().split()))) > 0 else 'NO')


from sys import stdin, stdout
inp = lambda : (int(o) for o in stdin.readline().split())
sinp = lambda : (o for o in stdin.readline().split())
out = lambda : stdout.write(str())
I = lambda : map(str, input().split())
Y = lambda : int(input())
d = input()
a = list(I())
for i in a:
	if d[0] == i[0]:
		exit(print('YES'))
	if d[1] == i[1]:
		exit(print('YES'))
print('NO')


card_on_table = input()
hand = input().split()
can_play = False
for card in hand:
	if card_on_table[0] == card[0] or card_on_table[1] == card[1]:
		can_play = True
		break
if can_play:
	print('YES')
else:
	print('NO')


x = input()
y = input().split(' ')
j = 0
for i in y:
	if x[0] in i:
		j += 1
	elif x[1] in i:
		j += 1
	else:
		pass
if j > 0:
	print('YES')
else:
	print('NO')


card = input()
deck = input()
if card[0] in deck:
	print('YES')
elif card[1] in deck:
	print('YES')
else:
	print('NO')


a = input()
flag = False
b = input()
brr = b.split()
for ele in brr:
	if ele[0] == a[0] or ele[1] == a[1]:
		flag = True
print('YES' if flag == True else 'NO')


model = set(input())
print('YES' if any(map(lambda s: set(s) & model, input().split())) else 'NO')


s1 = input()
list1 = input()
if s1[0] in list1 or s1[1] in list1:
	print('YES')
else:
	print('NO')


a = input()
b_list = input().split()
a_0 = a[0]
a_1 = a[1]
for i in b_list:
	if a_0 == i[0] or a_1 == i[1]:
		print('YES')
		exit()
print('NO')


import sys
from math import *
reads = lambda : map(lambda x: x, input().strip('\n').split())
x = input()
cards = list(reads())
for c in cards:
	if c[0] == x[0] or c[1] == x[1]:
		print('YES')
		sys.exit(0)
print('NO')


s = input()
S = list(input().split())
flag = 0
for i in s:
	for j in S:
		if i in j:
			flag = 1
			print('YES')
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


from operator import itemgetter as ig
q = input()
w = input().split()
if any((q[i] in set(map(ig(i), w)) for i in [0, 1])):
	print('YES')
else:
	print('NO')


table = input()
hand = list(input().split())
s = 0
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		s = 1
		break
if s:
	print('YES')
else:
	print('NO')


s = input()
a = input()
x = a.find(s[0])
y = a.find(s[1])
if x != -1:
	print('YES')
elif y != -1:
	print('YES')
else:
	print('NO')


s = input()
str = input()
if s[0] in str or s[1] in str:
	print('YES')
else:
	print('NO')


def solve():
	table_card = input()
	hand = input().split()
	ans = 'NO'
	for card in hand:
		if card[0] == table_card[0] or card[1] == table_card[1]:
			ans = 'YES'
			break
	print(ans)
solve()


s = input()
(a, b) = [i for i in s]
card = input().split()
flag = False
for string in card:
	if a in string or b in string:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


my_card = input()
table_cards = input().split()
flag = False
for card in table_cards:
	if card[0] == my_card[0] or card[1] == my_card[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


def card_play(s, t):
	if s[0] in t or s[1] in t:
		return 'YES'
	return 'NO'
x = input()
y = [i for i in input()]
z = ''.join(y)
print(card_play(x, z))


tableCard = input()
myCard = input().split(' ')
flat = 0
for i in myCard:
	if tableCard[0] == i[0] or tableCard[1] == i[1]:
		print('YES')
		flat = 1
		break
if flat == 0:
	print('NO')


s = input()
t = input().strip().split(' ')
flag = 0
for i in t:
	if i[0] in s or i[1] in s:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


a = input()
b = input().split(' ')
t = 0
flag = 0
while len(b) > t and flag == 0:
	if a[0] == b[t - 1][0] or a[1] == b[t - 1][1]:
		flag = 1
		print('YES')
	t += 1
if flag == 0:
	print('NO')


(card, hand) = (input(), input().split())
print(('NO', 'YES')[any((c == h for hc in hand for (c, h) in zip(card, hc)))])


table = input('')
hand = input('')
present = False
for i in table:
	for j in hand:
		if i == j:
			present = True
if present == True:
	print('YES')
else:
	print('NO')


def cardGame(inHand, onTable):
	for i in range(5):
		eachCard = onTable[i]
		if inHand[0] == eachCard[0] or inHand[1] == eachCard[1]:
			return 'YES'
	return 'NO'
inHand = list(input())
onTable = input().split()
result = cardGame(inHand, onTable)
print(result)


import sys

def OK(a, b):
	return a[0] == b[0] or a[1] == b[1]
ss = input().strip()
for i in input().strip().split():
	if OK(ss, i):
		print('YES')
		sys.exit(0)
print('NO')


ta = input()
ha = [x for x in input().split()]
yes = False
for i in ha:
	if i[0] == ta[0] or i[1] == ta[1]:
		yes = True
		break
if yes:
	print('YES')
else:
	print('NO')


a = str(input())
arr = list(input().split())
k = False
for i in arr:
	if a[0] == i[0] or a[1] == i[1]:
		k = True
		print('YES')
		break
if not k:
	print('NO')


s = input()
li = [i for i in input().split()]
count = 0
for i in range(len(li)):
	if s[0:1] == li[i][0:1] or s[:0:-1] == li[i][:0:-1]:
		count += 1
	else:
		count = count
if count >= 1:
	print('YES')
else:
	print('NO')


s = input()
a = [0, 0, 0, 0, 0]
(a[0], a[1], a[2], a[3], a[4]) = map(str, input().split(' '))
for i in range(5):
	if s[0] == a[i][0] or s[1] == a[i][1]:
		print('YES')
		break
	elif i == 4:
		print('NO')


Karte = list(input())
Hand = input().replace(' ', '')
Hand = list(Hand)
if Karte[0] in Hand or Karte[1] in Hand:
	print('YES')
else:
	print('NO')


k = input()
a = list(map(str, input().strip().split()))
c = 0
for i in a:
	if i[0] == k[0] or i[1] == k[1]:
		c += 1
if c >= 1:
	print('YES')
if c == 0:
	print('NO')


c = input()
s = input()
if c[0] in s or c[1] in s:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
for el in a:
	if el[0] == s[0] or el[1] == s[1]:
		print('YES')
		exit(0)
print('NO')


import sys
n = sys.stdin.readline()
letra = n[0]
tipo = n[1]
q = False
c = sys.stdin.readline()
i = 0
for i in c:
	if i == letra or i == tipo:
		q = True
		break
if q == True:
	print('YES')
else:
	print('NO')


string = input()
for i in input().split():
	if string[0] == i[0] or string[1] == i[1]:
		print('YES')
		exit()
print('NO')


s = input()
a = input().split(' ')
flag = -1
for i in a:
	for j in i:
		if j == s[0] or j == s[1]:
			flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


tableCard = str(input(''))
handCard = str(input(''))
handCardSplit = str.split(handCard)
play = False
for i in handCardSplit:
	if tableCard[0] == i[0] or tableCard[1] == i[1]:
		play = True
if play:
	print('YES')
else:
	print('NO')


checker = input()
options = list(input().split(' '))
for o in options:
	if o[0] == checker[0] or o[1] == checker[1]:
		print('YES')
		break
else:
	print('NO')


s = input()
a = input()
l = a.split()
l0 = l[0]
l1 = l[1]
l2 = l[2]
l3 = l[3]
l4 = l[4]
c = 0
if l0[0] == s[0] or l0[1] == s[1]:
	c += 1
if l1[0] == s[0] or l1[1] == s[1]:
	c += 1
if l2[0] == s[0] or l2[1] == s[1]:
	c += 1
if l3[0] == s[0] or l3[1] == s[1]:
	c += 1
if l4[0] == s[0] or l4[1] == s[1]:
	c += 1
if c >= 1:
	print('YES')
else:
	print('NO')


s = input()
t = input()
if t[0] == s[0] or t[3] == s[0] or t[6] == s[0] or (t[9] == s[0]) or (t[12] == s[0]) or (t[1] == s[1]) or (t[4] == s[1]) or (t[7] == s[1]) or (t[10] == s[1]) or (t[13] == s[1]):
	print('YES')
else:
	print('NO')


def can_play(H, T):
	return H[0] == T[0] or H[1] == T[1]
T = input()
HS = input().split()
print('YES' if any((can_play(H, T) for H in HS)) else 'NO')


a = input()
b = input().split()
check = 'NO'
for i in range(5):
	if a[0] == b[i][0]:
		check = 'YES'
		break
	if a[1] == b[i][1]:
		check = 'YES'
		break
print(check)


(s1, s2) = list(input())
(n, m) = ([], [])
for i in input().split():
	n.append(i[0])
	m.append(i[1])
if s1 in n or s2 in m:
	print('YES')
else:
	print('NO')


card = input()
hand = input()
if hand.count(card[0]) != 0 or hand.count(card[1]) != 0:
	print('YES')
else:
	print('NO')


def isIn(card1, card2):
	for i in range(2):
		if card1[i] == card2[i]:
			return True
	return False
cardDesk = input()
cardHand = input().split()
isPossible = 'NO'
for i in range(len(cardHand)):
	if isIn(cardDesk, cardHand[i]):
		isPossible = 'YES'
		break
print(isPossible)


a = input()
b = [x for x in input().split()]
str = 'NO'
for x in b:
	if a[0] == x[0] or a[1] == x[1]:
		str = 'YES'
		break
print(str)


p = input()
a = p[0]
b = p[1]
l = set(input())
if a in l or b in l:
	print('YES')
else:
	print('NO')


table_card = input()
is_valid = False
hand_cards = input().strip().split(' ')
for card in hand_cards:
	if card[0] == table_card[0] or table_card[1] == card[1]:
		is_valid = True
		break
if is_valid:
	print('YES')
else:
	print('NO')


flag = 0
ct = input()
arr = list(input().split())
for i in range(5):
	for j in range(2):
		if arr[i][j] == ct[0] or arr[i][j] == ct[1]:
			flag = 1
if flag == 0:
	print('NO')
else:
	print('YES')


a = input()
cards = input().split()

def casino():
	for card in cards:
		if card[0] == a[0] or card[1] == a[1]:
			return 'YES'
	return 'NO'
print(casino())


x = str(input())
(a, b, c, d, e) = map(str, input().split())
if a[0] == x[0] or a[1] == x[1] or b[0] == x[0] or (b[1] == x[1]) or (c[0] == x[0]) or (c[1] == x[1]) or (d[0] == x[0]) or (d[1] == x[1]) or (e[0] == x[0]) or (e[1] == x[1]):
	print('YES')
else:
	print('NO')


n = input()
l = input()
if n[0] in l or n[1] in l:
	print('YES')
else:
	print('NO')


n = input()
(a, b, c, d, e) = input().split()
i = 0
if a[0] == n[0] or a[1] == n[1]:
	print('YES')
elif b[0] == n[0] or b[1] == n[1]:
	print('YES')
elif c[0] == n[0] or c[1] == n[1]:
	print('YES')
elif d[0] == n[0] or d[1] == n[1]:
	print('YES')
elif e[0] == n[0] or e[1] == n[1]:
	print('YES')
else:
	print('NO')


class CodeforcesTask1097ASolution:

	def __init__(self):
		self.result = ''
		self.table = ''
		self.deck = []

	def read_input(self):
		self.table = input()
		self.deck = input().split(' ')

	def process_task(self):
		self.result = 'NO'
		for x in range(5):
			if self.table[0] == self.deck[x][0] or self.table[1] == self.deck[x][1]:
				self.result = 'YES'
				break

	def get_result(self):
		return self.result
Solution = CodeforcesTask1097ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
s = input()
l = input().split()
if s[0] in [i[0] for i in l] or s[1] in [i[1] for i in l]:
	print('YES')
else:
	print('NO')


on_Table = input()
good = 'NO'
for card in input().split():
	if card[0] == on_Table[0] or card[1] == on_Table[1]:
		good = 'YES'
print(good)


card_table = input()
your_cards = list(map(str, input().split()))
cards = ''.join(your_cards)
if card_table[0] in cards or card_table[1] in cards:
	print('YES')
else:
	print('NO')


x = input()
str = list(input().split())
for i in str:
	if x[0] == i[0] or x[1] == i[1]:
		print('YES')
		exit()
print('NO')


x = input()
a = list(input().split())
ok = False
for i in a:
	if i[0] == x[0] or i[1] == x[1]:
		ok = True
		break
if ok:
	print('YES')
else:
	print('NO')


a = str(input())
b = list(map(str, input().split()))
g = []
for i in range(2):
	for n in range(5):
		if a[i] in b[n]:
			g.append(1)
if len(g) > 0:
	print('YES')
else:
	print('NO')


s = input()
a = list(input().split())
flag = 0
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


card = input()
hand = input().split()
found = False
for c in hand:
	if c[0] == card[0] or c[1] == card[1]:
		print('YES')
		found = True
		break
if found == False:
	print('NO')


table = input()
hand = input()
if table[0] in hand or table[1] in hand:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input().split()
f = False
for i in s2:
	if i[0] == s1[0] or i[1] == s1[1]:
		f = True
		print('YES')
		break
if not f:
	print('NO')


y = input()
x = input()
for i in range(2):
	for j in range(len(x)):
		if y[i] == x[j]:
			print('YES')
			exit()
print('NO')


s = input()
s1 = list(s)
a = list(map(str, input().split()))
flag = 0
for i in a:
	l = list(i)
	for j in s1:
		if j in l:
			flag = 1
			print('YES')
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


import time

def compareCards(tablePair, handPairs):
	for x in handPairs:
		if tablePair[0] == x[0] or tablePair[1] == x[1]:
			return 'YES'
	return 'NO'

def solve():
	tablePair = input()
	handPairs = [x for x in input().split()]
	print(compareCards(tablePair, handPairs))
solve()


t = input().split()
a = t[0][0]
b = t[0][1]
s = input()
if a in s:
	print('YES')
elif b in s:
	print('YES')
else:
	print('NO')


hand = list(input())
l = list(input().split())
for i in range(0, 5):
	list(l[i])
flag1 = 0
flag2 = 0
for i in range(0, 5):
	if hand[0] == l[i][0]:
		flag1 = 1
if flag1 == 0:
	for i in range(0, 5):
		if hand[1] == l[i][1]:
			flag2 = 1
if flag1 or flag2:
	print('YES')
else:
	print('NO')


(s, z) = list(input())
l = list(input().split())
j = 'NO'
for i in range(5):
	if l[i][0] == s or l[i][1] == z:
		j = 'YES'
print(j)


tc = input()
hc = []
hc = input().split()
hc = hc[:5]
flag = False
for card in hc:
	if tc[0] in card or tc[1] in card:
		flag = True
if flag == True:
	print('YES')
else:
	print('NO')


card = input()
hand = input()
rank = card[0]
suit = card[1]
cards_hand = hand.split(' ')
found = 0
for c in cards_hand:
	if rank == c[0]:
		print('YES')
		found = 1
		break
	if suit == c[1]:
		print('YES')
		found = 1
		break
if found == 0:
	print('NO')


t = input()
h = input().split()
x = t[0]
y = t[1]
ans = 0
for i in range(5):
	if h[i][0] == x or h[i][1] == y:
		ans += 1
if ans >= 1:
	print('YES')
else:
	print('NO')


s = input()
s1 = input().split()
for i in range(5):
	if s1[i][0] == s[0] or s1[i][1] == s[1]:
		print('YES')
		quit()
print('NO')


n = input()
l = list(input().split())
l1 = []
l2 = []
for i in range(len(l)):
	l1.append(l[i][0])
	l2.append(l[i][1])
if n[0] in l1 or n[1] in l2:
	print('YES')
else:
	print('NO')


tbl = input()
cards = input().split()
flag = False
for card in cards:
	if card[0] == tbl[0] or card[1] == tbl[1]:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


table = input()
hand = list(map(str, input().split()))
move = False
for i in range(5):
	if hand[i][0] == table[0]:
		move = True
	if hand[i][1] == table[1]:
		move = True
if move:
	print('YES')
else:
	print('NO')


tableCard = input()
handCards = input().split(' ')
flag = False
for handCard in handCards:
	if handCard[0] == tableCard[0] or handCard[1] == tableCard[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


import re
i1 = input()
b = 'f'
i2 = input()
tmp = re.split(' ', i2)
for i in tmp:
	if i1[0] == i[0] or i1[1] == i[1]:
		b = 't'
		break
if b == 't':
	print('YES')
else:
	print('NO')


import sys
import math

def main():
	s = input()
	cards = input().split()
	(a, b) = (s[0], s[1])
	f = [x[0] for x in cards]
	s = [x[1] for x in cards]
	print('YES' if a in f or b in s else 'NO')
main()


sDesire = input()
A = input().split()
for i in A:
	if set(list(i)).intersection(set(list(sDesire))):
		print('YES')
		break
else:
	print('NO')


s = input().rstrip()
a = list(input().split())
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		exit()
print('NO')


incard = input().strip()
hand = [i for i in input().strip().split(' ')]
if incard[0] in (c[0] for c in hand) or incard[1] in (c[1] for c in hand):
	print('YES')
else:
	print('NO')


a = input()
cnt = 0
x = [str(x) for x in input().split()]
for i in x:
	if a[0] in i[0] or a[1] in i[1]:
		cnt = 1
		break
if cnt == 1:
	print('YES')
else:
	print('NO')


import sys

def main():
	s = sys.stdin.readline().strip('\n')
	five = sys.stdin.readline().strip('\n').split()
	for x in five:
		if x[0] == s[0] or x[1] == s[1]:
			print('YES')
			return 0
	print('NO')
	return 0
main()


s = input()
a = [str(i) for i in input().split()]
b = []
c = []
for i in a:
	b += [i[0]]
	c += [i[1]]
if s[0] in b or s[1] in c:
	print('YES')
else:
	print('NO')


T = input()
(h1, h2, h3, h4, h5) = input().split(' ')
H = [h1, h2, h3, h4, h5]
count = 0
for i in range(5):
	if H[i][0] == T[0] or H[i][1] == T[1]:
		count = count + 1
		break
if count > 0:
	print('YES')
else:
	print('NO')


a = input()
b = list(input().split())

def GCG(a):
	for i in range(2):
		for j in range(5):
			if a[i] == b[j][i]:
				return 'YES'
	return 'NO'
print(GCG(a))


card = input()
l = list(input().split())
ans = 0
for i in l:
	if i[0] == card[0] or i[1] == card[1]:
		ans += 1
if ans != 0:
	print('YES')
else:
	print('NO')


def main():
	TB = input()
	hands = input().split()
	for card in hands:
		if TB[1] == card[1]:
			print('YES')
			return
		if TB[0] == card[0]:
			print('YES')
			return
	print('NO')
main()


n = list(input())
ok = True
for i in map(str, input().split()):
	m = list(i)
	if m[0] == n[0] or m[1] == n[1]:
		print('YES')
		ok = False
		break
if ok:
	print('NO')


n = input()
m = list(map(str, input().split()))
flag = 0
for i in range(5):
	if m[i][0] == n[0]:
		flag = 1
		break
	elif m[i][1] == n[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


a = input()
b = input()
for i in range(len(b)):
	if b.count(a[0]) >= 1 or b.count(a[1]) >= 1:
		print('YES')
		exit()
	elif b.count(a[1]) != 1:
		print('NO')
		exit()


card = input()
f_cards = input().split(' ')
val = 'NO'
for i in f_cards:
	if i[0] == card[0]:
		val = 'YES'
	elif i[1] == card[1]:
		val = 'YES'
print(val)


from sys import stdin
top_card = stdin.readline()
hand = list(stdin.readline().split())
suite = top_card[0]
rank = top_card[1]
answer = 'NO'
for i in range(len(hand)):
	if suite in hand[i] or rank in hand[i]:
		answer = 'YES'
print(answer)


table = input()
hand = input().split()
bool = any([card[c] == table[c] for card in hand for c in range(len(card))])
print('YES' if bool else 'NO')


s = input()
l = list(map(str, input().split()))
x = False
for i in range(len(s)):
	for j in l:
		if j[i] == s[i]:
			print('YES')
			x = True
			break
	if x:
		break
if not x:
	print('NO')


s1 = input()
a = s1[0]
b = s1[1]
s = input().split()
al = []
bl = []
for x in s:
	al.append(x[0])
	bl.append(x[1])
if a in al or b in bl:
	print('YES')
else:
	print('NO')


s = input()
y = 1
t = list(input().split())
for i in range(5):
	if y:
		for j in range(2):
			if t[i][j] == s[j]:
				print('YES')
				y = 0
				break
	else:
		break
if y:
	print('NO')


A = input()
Ans = False
suit = {'D': 0, 'C': 0, 'S': 0, 'H': 0}
rank = {}
for i in 'A23456789TJQK':
	rank[i] = 0
rank[A[0]] = 1
suit[A[1]] = 1
B = input().split()
for i in B:
	try:
		if rank[i[0]] == 1:
			print('YES')
			Ans = True
			break
	except:
		pass
	try:
		if suit[i[1]] == 1:
			print('YES')
			Ans = True
			break
	except:
		pass
if Ans == False:
	print('NO')


n = input()
m = input().split()
for i in m:
	if n[0] == i[0] or n[1] == i[1]:
		print('YES')
		exit()
print('NO')


x = input()
(r, s) = (x[0], x[1])
cards = input().split()
flag = False
for card in cards:
	if card[0] == r or card[1] == s:
		flag = True
		print('YES')
		break
if not flag:
	print('NO')


c = input()
mc = list(input().split())
b = 0
for i in range(5):
	if c[0] == mc[i][0] or c[1] == mc[i][1]:
		b = 1
		print('YES')
		break
if not b:
	print('NO')


a = input()
b = input().split(' ')
m = 0
for i in b:
	if a[0] in i or a[1] in i:
		print('YES')
		break
	m = m + 1
if m == len(b):
	print('NO')


a = input()
l = list(input().split())
g = 0
for i in range(5):
	if l[i][0] == a[0] or l[i][1] == a[1]:
		print('YES')
		g = 1
		break
if g == 0:
	print('NO')


s = input()
a = input().split()
b = []
for i in range(5):
	b.append(a[i])
ans = 0
for i in range(5):
	if s[0] == b[i][0] or s[1] == b[i][1]:
		ans = 1
		break
if ans == 1:
	print('YES')
else:
	print('NO')


krt = list(input())
k1 = krt[0]
k2 = krt[1]
km = [str(i) for i in input().split()]
k = 0
for i in range(5):
	if k1 in km[i] or k2 in km[i]:
		k = 1
		break
if k == 1:
	print('YES')
else:
	print('NO')


s = str(input())
n = list(map(str, input().split()))
import sys
import re
for i in n:
	if s[0] == i[0]:
		print('YES')
		sys.exit()
for j in n:
	if s[1] == j[1]:
		print('YES')
		sys.exit()
print('NO')


given = input()
a = [str(x) for x in input().split()]
c = 0
for i in range(len(a)):
	if given[0] == a[i][0] or given[1] == a[i][1]:
		print('YES')
		break
	else:
		c += 1
if c == 5:
	print('NO')


n = input()
s = input().split()
count = 0
for i in s:
	if n[0] in i or n[1] in i:
		print('YES')
		count += 1
		break
if count == 0:
	print('NO')


PlayCard = input()
YourCards = [i for i in input().split()]
flag = False
for i in range(2):
	for card in YourCards:
		if card[i] == PlayCard[i]:
			flag = True
			break
	if flag:
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
ss = input()
if s[0] in ss or s[1] in ss:
	print('YES')
else:
	print('NO')


card = input()
a = card[0]
b = card[1]
cards = [(x[0], x[1]) for x in input().split()]
res = False
for (c, e) in cards:
	if c == a or e == b:
		res = True
print('YES' if res else 'NO')


card = input()
tefuda = input().split(' ')
flag = False
for char in list(card):
	for tefuda_card in tefuda:
		if char in tefuda_card:
			flag = True
			break
	if flag:
		break
out = 'YES' if flag else 'NO'
print(out)


table = input()
deck = [c for c in input().split(' ')]
play = 'NO'
for i in deck:
	if table[0] == i[0] or table[1] == i[1]:
		play = 'YES'
		break
print(play)


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
for _ in range(t):
	s = input()
	l = input()
	print('YES' if s[1] in l or s[0] in l else 'NO')


class Solution(object):

	def solve(self):
		table = input().strip()
		hand = input().strip().split(' ')
		hand = [x.strip() for x in hand]
		tableRank = table[0]
		tableSuite = table[1]
		for x in hand:
			if x[0] == tableRank or x[1] == tableSuite:
				return 'YES'
		return 'NO'
sol = Solution()
print(sol.solve())


desk = list(input())
arr = input()
if desk[0] in arr or desk[1] in arr:
	print('YES')
else:
	print('NO')


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
ARR = lambda : list(map(int, input().split()))

def printARR(arr):
	for e in arr:
		print(e, end=' ')
	print()

def main():
	table = input()
	table_rank = table[0]
	table_suit = table[1]
	card = list(map(str, input().split()))
	for c in card:
		if c[0] == table_rank or c[1] == table_suit:
			print('YES')
			return
	print('NO')
tc = 1
for _ in range(tc):
	main()


a = input()
l = list(input().split(' '))
flag = -1
for i in l:
	if a[0] == i[0] or a[1] == i[1]:
		print('YES')
		flag = 0
		break
if flag == -1:
	print('NO')


(a, b) = input()
x = set()
y = set()
for (i, j) in input().split():
	x.add(i)
	y.add(j)
if a in x or b in y:
	print('YES')
else:
	print('NO')


c = input()
h = input()
if c[0] in h or c[1] in h:
	print('YES')
else:
	print('NO')


a = input()
lst = list(input().split())
f = 0
for i in lst:
	if i[0] == a[0] or i[1] == a[1]:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


s = input()
n = list(map(str, input().split()))
for c in n:
	if c[0] == s[0] or c[1] == s[1]:
		flag = True
		break
	else:
		flag = False
if flag:
	print('YES')
else:
	print('NO')


t_c = input()
cards = input().split()
for c in cards:
	if t_c[0] == c[0] or t_c[1] == c[1]:
		print('YES')
		exit()
print('NO')


(rank, suit) = input()
for (r, s) in input().split():
	if r == rank or s == suit:
		print('YES')
		break
else:
	print('NO')


cardOnTable = input('')
cardsInHand = [i for i in input('').split()]
out = 'NO'
for i in cardsInHand:
	if i[0] == cardOnTable[0] or i[1] == cardOnTable[1]:
		out = 'YES'
		break
	else:
		continue
print(out)


import sys
input = sys.stdin.readline
T = input().strip()
H = input().split()
for t in T:
	for h in H:
		if t in h:
			print('YES')
			sys.exit()
print('NO')


s = input()
v = 999
d = input().split()
for i in range(5):
	x = d[i]
	if s[0] == x[0] or s[1] == x[1]:
		v = v - 1
		print('YES')
		break
if v == 999:
	print('NO')


mesa = [i for i in input()]
rank = mesa[0]
suit = mesa[1]
cartas = input()
sirve = False
for i in cartas:
	if rank in i or suit in i:
		sirve = True
		break
print('YES' if sirve else 'NO')


a = input('')
(b, c, d, e, f) = input('').split()
if a[0] == b[0] or a[0] == c[0] or a[0] == d[0] or (a[0] == e[0]) or (a[0] == f[0]):
	print('YES')
elif a[1] == b[1] or a[1] == c[1] or a[1] == d[1] or (a[1] == e[1]) or (a[1] == f[1]):
	print('YES')
else:
	print('NO')


p = input()
lst = input()
s = list(lst)
if p[0] in s:
	print('YES')
elif p[1] in s:
	print('YES')
else:
	print('NO')


import sys
table_card = sys.stdin.readline()
hand_cards = sys.stdin.readline().strip()
hand_cards = hand_cards.split()
for card in hand_cards:
	if table_card[0] == card[0] or table_card[1] == card[1]:
		print('YES')
		break
else:
	print('NO')


(t, e) = list(input())
u = input().split()
for i in range(5):
	if u[i][0] == t or u[i][1] == e:
		print('YES')
		exit()
print('NO')


def main():
	targetCard = input()
	cardsWithUs = input().split(' ')
	flag = False
	for card in cardsWithUs:
		if targetCard[0] in card or targetCard[1] in card:
			flag = True
	if flag:
		print('YES')
	else:
		print('NO')
main()


s = input()
l = list(filter(lambda x: x[0] == s[0] or x[1] == s[1], input().split()))
print('YES' if len(l) > 0 else 'NO')


s = input()
S = input()
print('YES' if s[0] in S or s[1] in S else 'NO')


(rang, suit) = input()
hand = input().split()
if rang in map(lambda it: it[0], hand) or suit in map(lambda it: it[1], hand):
	print('YES')
else:
	print('NO')


def cardgame(c, cards):
	for i in cards:
		if i[0] == c[0] or i[1] == c[1]:
			return 'YES'
	return 'NO'
cc = input()
card = list(map(str, input().split()))
print(cardgame(cc, card))


hand = input()
table = input()
for i in range(len(table)):
	if hand[0] == table[i] or hand[1] == table[i]:
		print('YES')
		break
else:
	print('NO')


try:
	ans = False
	a = input()
	b = input().split()
	for i in range(5):
		if b[i][0] == a[0] or b[i][1] == a[1]:
			ans = True
	if ans:
		print('YES')
	else:
		print('NO')
except EOFError:
	pass


f_card = list(input().strip())
s_card = list(input().strip())
for m in s_card:
	for n in f_card:
		if n == m:
			print('YES')
			exit(0)
print('NO')


table = input()
in_hand = input()
if table[0] in in_hand or table[-1] in in_hand:
	print('YES')
else:
	print('NO')


tableCard = input()
(first, second, third, fourth, fifth) = input().split()
if tableCard[-1] in first:
	print('YES')
elif tableCard[:-1] in first:
	print('YES')
elif tableCard[-1] in second:
	print('YES')
elif tableCard[:-1] in second:
	print('YES')
elif tableCard[-1] in third:
	print('YES')
elif tableCard[:-1] in third:
	print('YES')
elif tableCard[-1] in fourth:
	print('YES')
elif tableCard[:-1] in fourth:
	print('YES')
elif tableCard[-1] in fifth:
	print('YES')
elif tableCard[:-1] in fifth:
	print('YES')
else:
	print('NO')


t = input()
a = input().split(' ')
f = 1
for _ in range(5):
	if a[_][0] == t[0] or a[_][1] == t[1]:
		print('YES')
		f = 0
		break
if f == 1:
	print('NO')


t = input()
s = input()
p = 0
for i in s:
	if t[0] == i or t[1] == i:
		print('YES')
		p = 1
		break
if p == 0:
	print('NO')


s = input()
arr = list(map(str, input().split()))
flag = 0
for i in arr:
	if s[0] == i[0] or s[1] == i[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


ts = input()
tn = ts[:1]
tt = ts[-1]
hs = list(input().split())
f = 0
for i in range(len(hs)):
	num = hs[i][:1]
	t = hs[i][-1]
	if num == tn or t == tt:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


def fun(str1, arr):
	l = len(arr)
	for i in range(0, l):
		if str1[0] == arr[i][0] or str1[1] == arr[i][1]:
			return 'YES'
	return 'NO'
str1 = input()
arr = list(input().split())
print(fun(str1, arr))


s1 = input()
a = list(input().split())
ans = False
for i in a:
	if i[0] == s1[0] or i[1] == s1[1]:
		ans = True
if ans:
	print('YES')
else:
	print('NO')


import math
import bisect
import itertools
import sys
I = lambda : sys.stdin.readline()
mod = 10 ** 9 + 7

def mindiff(a):
	b = a[:]
	b.sort()
	m = 10000000000
	for i in range(len(b) - 1):
		if b[i + 1] - b[i] < m:
			m = b[i + 1] - b[i]
	return m

def lcm(a, b):
	return a * b // math.gcd(a, b)

def merge(a, b):
	i = 0
	j = 0
	c = 0
	ans = []
	while i < len(a) and j < len(b):
		if a[i] < b[j]:
			ans.append(a[i])
			i += 1
		else:
			ans.append(b[j])
			c += len(a) - i
			j += 1
	ans += a[i:]
	ans += b[j:]
	return (ans, c)

def mergesort(a):
	if len(a) == 1:
		return (a, 0)
	mid = len(a) // 2
	(left, left_inversion) = mergesort(a[:mid])
	(right, right_inversion) = mergesort(a[mid:])
	(m, c) = merge(left, right)
	c += left_inversion + right_inversion
	return (m, c)

def is_prime(num):
	if num == 1:
		return False
	if num == 2:
		return True
	if num == 3:
		return True
	if num % 2 == 0:
		return False
	if num % 3 == 0:
		return False
	t = 5
	a = 2
	while t <= int(math.sqrt(num)):
		if num % t == 0:
			return False
		t += a
		a = 6 - a
	return True

def ceil(a, b):
	if a % b == 0:
		return a // b
	else:
		return a // b + 1

def binsearch(arr, b, low, high):
	if low == high:
		return low
	if arr[math.ceil((low + high) / 2)] < b:
		return binsearch(arr, b, low, math.ceil((low + high) / 2) - 1)
	else:
		return binsearch(arr, b, math.ceil((low + high) / 2), high)

def ncr1(n, r):
	s = 1
	for i in range(min(n - r, r)):
		s *= n - i
		s %= mod
		s *= pow(i + 1, mod - 2, mod)
		s %= mod
	return s

def calc(n, m, r):
	s = 0
	for i in range(0, r + 1, 2):
		s += ncr1(n, i) * ncr1(m, i)
		s %= mod
	return s
s = input()
a = list(map(str, input().split()))
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		exit(print('YES'))
exit(print('NO'))


(r, s) = input()
h = input()
if r in h or s in h:
	print('YES')
else:
	print('NO')


def get_first_card():
	return input()

def get_hand():
	return input().split(' ')

def solve():
	card_on_table = get_first_card()
	hand = get_hand()
	for card in hand:
		if card[0] == card_on_table[0] or card[1] == card_on_table[1]:
			return True
	return False
if solve():
	print('YES')
else:
	print('NO')


pl = input()
i = input().split(' ')
a = 0
while a < 5:
	if i[a][0] == pl[0]:
		print('YES')
		break
	elif i[a][1] == pl[1]:
		print('YES')
		break
	a = a + 1
if a == 5:
	print('NO')


card = input()
cards = list(map(str, input().split()))
result = 0
for i in range(0, 5):
	if card[0] == cards[i][0] or card[1] == cards[i][1]:
		result += 1
if result > 0:
	print('YES')
else:
	print('NO')


cot = input()
arr = list(map(str, input().split()))
str1 = ''
str2 = str1.join(arr)
mm = True
for i in range(len(str2)):
	if cot[0] == str2[i]:
		print('YES')
		mm = False
		break
if mm:
	for i in range(len(str2)):
		if cot[1] == str2[i]:
			print('YES')
			mm = False
			break
if mm:
	print('NO')


le = input()
chalbe = input().split()
lele = 'NO'
for i in range(5):
	if le[0] == chalbe[i][0] or le[1] == chalbe[i][1]:
		lele = 'YES'
print(lele)


x1 = input()
m = input().split()
(l1, l2) = ([i[0] for i in m], [i[1] for i in m])
if x1[0] in l1 or x1[1] in l2:
	print('YES')
else:
	print('NO')


x = input()
n = x[0]
r = x[1]
l = list(map(str, input().split()))
i = 0
f = True
while i < 5:
	y = l[i]
	if n == y[0] or r == y[1]:
		print('YES')
		f = False
		break
	else:
		i += 1
if f == True:
	print('NO')


s = input()
(a, b, c, d, e) = map(str, input().split())
ar = []
ar.append(a[1])
ar.append(a[0])
ar.append(b[1])
ar.append(b[0])
ar.append(c[1])
ar.append(c[0])
ar.append(d[1])
ar.append(d[0])
ar.append(e[1])
ar.append(e[0])
for i in ar:
	if i in s:
		t = 1
		break
	else:
		t = 0
if t == 1:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
rankl = []
suitl = []
for i in range(5):
	rankl.append(a[i][0])
	suitl.append(a[i][1])
if s[0] in rankl or s[1] in suitl:
	print('YES')
else:
	print('NO')


(rank, suite) = [a for a in input()]
cards = [a for card in input().split(' ') for a in card]
if rank in cards or suite in cards:
	print('YES')
else:
	print('NO')


s = input()
li = input().split()
for i in li:
	if s[0] == i[0]:
		print('YES')
		break
	elif s[1] == i[1]:
		print('YES')
		break
else:
	print('NO')


s = input()
A = list(map(str, input().split()))
flag = False
for a in A:
	if a[0] == s[0] or a[1] == s[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


x = input()
l = list(map(str, input().split()))
p = 0
for i in x:
	for j in l:
		if j[0] == i or j[1] == i:
			p = 1
			break
		else:
			p = 0
	if p == 1:
		break
if p == 1:
	print('YES')
else:
	print('NO')


l = list(input())
d = list(input().split())
for i in range(5):
	if list(d[i])[0] == l[0] or list(d[i])[1] == l[1]:
		print('YES')
		exit()
print('NO')
exit()


def find():
	a = input()
	c = [i for i in a]
	b = input()
	d = [i for i in b]
	for i in c:
		if i in d:
			print('YES')
			return 1
	print('NO')
find()


can = False
t = input()
dat = input().split()
for i in range(5):
	if t[0] == dat[i][0]:
		can = True
	if t[1] == dat[i][1]:
		can = True
print('YES' if can else 'NO')


s = input()
s = list(s)
t = list(map(str, input().split()))
l = ''.join(t)
c = list(l)
x = s[0] in c or s[1] in c
if x:
	print('YES')
else:
	print('NO')


s = input()
l = input().split()
k = [i[0] for i in l]
m = [i[1] for i in l]
p = k + m
if s[0] in p or s[1] in p:
	print('YES')
else:
	print('NO')


import sys
on_table = input()
on_hand = list(input().split())
for x in range(5):
	if on_table[0] == on_hand[x][0] or on_table[1] == on_hand[x][1]:
		print('YES')
		sys.exit(0)
print('NO')


tk = input()
lhk = [x for x in input().split()]
for x in lhk:
	if x[0] == tk[0] or x[1] == tk[1]:
		print('YES')
		exit(0)
print('NO')


table = input()
hands = input().split(' ')
res = 'NO'
for h in hands:
	if h[0] == table[0] or h[1] == table[1]:
		res = 'YES'
print(res)


a = input()
b = [x for x in input().split()]
a1 = a[0]
a2 = a[1]
str = 'NO'
for x in b:
	x1 = x[0]
	x2 = x[1]
	if a1 == x1 or a2 == x2:
		str = 'YES'
		break
print(str)


a = list(str(input()))
b = list(map(str, input().split()))
for z in range(-1, 4):
	for i in range(-1, 2):
		s = list(str(b[z]))
		if s[i] == a[i]:
			print('YES')
			exit()
print('NO')


__author__ = 'Sudip'
a = input()
b = input()
c = d = -1
c = b.find(a[0])
d = b.find(a[1])
if c > -1 or d > -1:
	print('YES')
else:
	print('NO')


import sys, functools
cardOnTable = sys.stdin.readline().rstrip()
cardOnHards = sys.stdin.readline().split()
isFound = False
for card in cardOnHards:
	if card[0] == cardOnTable[0]:
		isFound = True
		break
	if card[1] == cardOnTable[1]:
		isFound = True
		break
print('YES' if isFound else 'NO')


def czy(a, b):
	if a[0] == b[0] or a[1] == b[1]:
		return True
	else:
		return False

def Makao(a, lista):
	for i in lista:
		if czy(a, i):
			return 'YES'
	return 'NO'
a = input()
lista = input().split()
print(Makao(a, lista))


flag = False
card = input()
spisok = list(input().split())
for i in spisok:
	if card[0] in i or card[1] in i:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


n = input()
x = [i for i in input()]
n = [i for i in n]
n.sort(reverse=True)
if x.count(n[0]) >= 1 or x.count(n[1]) >= 1:
	print('YES')
else:
	print('NO')


table = input()
hand = input()
hand = hand.split()
flag = 0
for i in hand:
	if table[0] == i[0] or table[1] == i[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


table_card = input()
my_hand = [card for card in input().split()]

def solve(table_card, hand):
	table_card = set(table_card)
	completed = False
	for card in hand:
		if card[1] in table_card or card[0] in table_card:
			print('YES')
			completed = True
			break
	if not completed:
		print('NO')
solve(table_card, my_hand)


s = input()
(a, b, c, d, e) = map(str, input().split())
lt = [a[0], a[1], b[0], b[1], c[0], c[1], d[0], d[1], e[0], e[1]]
if s[0] in lt or s[1] in lt:
	print('YES')
else:
	print('NO')


(rank, suit) = list(input())
all_cards = input()
if rank in all_cards or suit in all_cards:
	print('YES')
else:
	print('NO')


table = input()
hands = input().split()
can = 'NO'
for card in hands:
	if table[0] == card[0] or table[1] == card[1]:
		can = 'YES'
		break
print(can)


a = input()
s = input().split()
t = 'NO'
for i in s:
	if i[0] == a[0] or i[1] == a[1]:
		t = 'YES'
		break
print(t)


s = str(input())
card_on_tab = list(map(str, input().split()))
suit = {'D', 'C', 'S', 'H'}
cards = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'}
x = ''.join(card_on_tab)
for i in s:
	if s[0] in x or s[-1] in x:
		print('YES')
		break
	else:
		print('NO')
		break


X = input()
Y = input().split()
x = False
for l in Y:
	if X[0] == l[0] or X[1] == l[1]:
		x = True
		break
print('YES' if x else 'NO')


card = input()
dost = card[:1]
chifra = card[1:]
array = list(input().strip().split())

def check():
	for i in range(len(array)):
		if array[i].__contains__(dost) or array[i].__contains__(chifra):
			print('YES')
			return
	print('NO')
	return
check()


table = input()
hand = input().split(' ')
flag = False
for i in range(5):
	if table[0] == hand[i][0] or table[1] == hand[i][1]:
		flag = True
print('YES' if flag else 'NO')


n = input()
s = input()
s = s.split()
count = 0
st = ''
for i in range(len(s)):
	st = s[i]
	if n[0] == st[0] or n[1] == st[1]:
		print('YES')
		count += 1
		break
if count == 0:
	print('NO')


s = str(input())
l = input().split()
flag = False
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		flag = True
if flag:
	print('YES')
else:
	print('NO')


(rank_t, suit_t) = list(input())
hand = set(list(input().replace(' ', '')))
if rank_t in hand or suit_t in hand:
	print('YES')
else:
	print('NO')


a = list(input())
b = list(input())
t = 0
for i in a:
	if i in b:
		print('YES')
		t += 1
		break
if t == 0:
	print('NO')


def main():
	table_card = input()
	hand_cards = input().split()
	answer = 'NO'
	for card in hand_cards:
		if card[0] == table_card[0]:
			answer = 'YES'
		if card[1] == table_card[1]:
			answer = 'YES'
	print(answer)
main()


card = list(input())
stri = ''.join(map(str, input().split(' ')))
if card[0] in stri or card[1] in stri:
	print('YES')
else:
	print('NO')


s = input()
l = [x for x in input().split()]
d = [l[0][0], l[1][0], l[2][0], l[3][0], l[4][0]]
e = [l[0][1], l[1][1], l[2][1], l[3][1], l[4][1]]
if s[0] in d or s[1] in e:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
c = False
for x in b:
	if x[0] in a or x[1] in a:
		c = True
if c:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
n = len(b)
res = 'NO'
for i in range(n):
	if a[0] == b[i][0] or a[1] == b[i][1]:
		res = 'YES'
print(res)


q = input()
a = q[0]
b = q[1]
x = [i for i in input().split()]
c1 = set()
c2 = set()
for i in x:
	c1.add(i[0])
	c2.add(i[1])
if a in c1 or b in c2:
	print('YES')
else:
	print('NO')


me = input()
hand = []
hand = list(me)
cards = input()
table = []
table = list(cards)
table = [i for i in table if i != ' ']
match = 'NO'
for h in hand:
	if h in table:
		match = 'YES'
		break
print(match)


n = input()
s = input()
x = s.split()
k = 0
for i in range(5):
	if x[i][0] == n[0] or x[i][1] == n[1]:
		print('YES')
		k = 1
		break
if k == 0:
	print('NO')


card_on_table = input()
card_on_table = [j for i in card_on_table for j in i]
card_in_hand = list(input().split())
card_in_hand = set([j for i in card_in_hand for j in i])
answer = [item in card_in_hand for item in card_on_table]
if any(answer):
	print('YES')
else:
	print('NO')


n = input().lower()
p = input().lower().split()
for i in range(len(p)):
	a = p[i]
	if a[0] == n[0] or a[1] == n[1]:
		print('YES')
		break
	elif i == len(p) - 1:
		print('NO')


tableCard = input()
myCards = [a for a in input().strip().split()]
canPlay = False
for card in myCards:
	if card[0] == tableCard[0] or card[1] == tableCard[1]:
		canPlay = True
		break
if canPlay:
	print('YES')
else:
	print('NO')


s = input()
s1 = input().split()
a = []
b = []
for i in s1:
	a.append(i[0])
	b.append(i[1])
if s[0] in a or s[1] in b:
	print('YES')
else:
	print('NO')


a = input()
b = input()
if b.count(a[0]) > 0 or b.count(a[1]) > 0:
	print('YES')
else:
	print('NO')


(x, y) = input()
z = input()
print(('NO', 'YES')[x in z or y in z])


import sys
card = sys.stdin.readline()
hand = sys.stdin.readline().split()
s = card[0]
r = card[1]
for h in hand:
	hs = h[0]
	hr = h[1]
	if hs == s or hr == r:
		print('YES')
		sys.exit()
print('NO')


a = input()
(x, y) = (a[0], a[1])
(X, Y) = ([], [])
A = input().split()
for a in A:
	X.append(a[0])
	Y.append(a[1])
print('YES' if x in X or y in Y else 'NO')


n = input()
p = input().split()
flag = 0
for i in p:
	if n[0] == i[0] or n[1] == i[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


def main():
	firstCard = input()
	tableCards = input().split()
	for each in tableCards:
		if firstCard[0] == each[0] or firstCard[1] == each[1]:
			print('YES')
			return
	print('NO')
	return
main()


a = input()
b = input().split()
c1 = {}
c2 = {}
for i in b:
	if i[0] not in c1:
		c1[i[0]] = True
	if i[1] not in c2:
		c2[i[1]] = True
if a[0] in c1 or a[1] in c2:
	print('YES')
else:
	print('NO')


n = input()
x = list(map(str, input().split()))
k = 0
for i in range(5):
	if x[i][0] == n[0] or x[i][1] == n[1]:
		k = 1
		break
if k == 1:
	print('YES')
else:
	print('NO')


n = input()
m = list(map(str, input().split(' ')))
k = False
for i in range(5):
	if m[i][0] == n[0] or m[i][1] == n[1]:
		k = True
if k:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
flag = 'yay'
for i in range(len(b)):
	if a[0] == b[i][0] or a[1] == b[i][1]:
		print('YES')
		flag = 'nan'
		break
if flag == 'yay':
	print('NO')


table = input()
hand = list(map(str, input().split()))
result = 'NO'
for i in range(0, len(hand)):
	if hand[i][0] == table[0] or hand[i][1] == table[1]:
		result = 'YES'
		break
print(result)


from sys import stdin, stdout
from math import sin, tan, cos, pi, atan2, sqrt, acos, atan, factorial
from random import randint

def get_card(s):
	return (s[0], s[1])
t = stdin.readline().strip()
m = stdin.readline().strip().split()
label = 0
for f in m:
	if get_card(t)[0] == get_card(f)[0] or get_card(t)[1] == get_card(f)[1]:
		label = 1
if label:
	stdout.write('YES\n')
else:
	stdout.write('NO\n')


card = list(input())
hand = input().split(' ')
yes = False
for i in range(5):
	n = list(hand[i])
	if card[0] == n[0] or card[1] == n[1]:
		yes = True
		break
	else:
		yes = False
if yes == True:
	print('YES')
else:
	print('NO')


a = list(input().strip())
b = input()
k = 0
c = 0
for i in range(0, len(b)):
	if a[k] == b[i] or a[k + 1] == b[i]:
		c = 1
if c == 1:
	print('YES')
else:
	print('NO')


st = input()
a = list(input().split())
for i in range(len(a)):
	if a[i][0] == st[0] or a[i][1] == st[1]:
		print('YES')
		break
else:
	print('NO')


(rank, suit) = list(input())
elements = list(map(list, input().strip().split()))
flag = False
for i in elements:
	if rank == i[0] or suit == i[1]:
		flag = True
		break
if flag == True:
	print('YES')
else:
	print('NO')


t = input()
a = list(input().split())
can = False
for x in a:
	if x[1] == t[1]:
		can = True
	if x[0] == t[0]:
		can = True
if can:
	print('YES')
else:
	print('NO')


x = input()
cards = input().split()
res = 'NO'
for c in cards:
	if x[0] == c[0] or x[1] == c[1]:
		res = 'YES'
		break
print(res)


card = input()
cards = input()
if card[0] in cards or card[1] in cards:
	print('YES')
else:
	print('NO')


card_tbl = input()
ur_cards = input().split(' ')
can_play = False
for card in ur_cards:
	if card[0] == card_tbl[0]:
		can_play = True
		break
	if card[1] == card_tbl[1]:
		can_play = True
		break
if can_play:
	print('YES')
else:
	print('NO')


N = input()
hand = input()
hand = hand.split()
out = 0
for i in range(0, 5):
	if hand[i][0] == N[0] or hand[i][1] == N[1]:
		out = 1
		break
	else:
		out = 0
if out == 1:
	print('YES')
else:
	print('NO')


card_on_table = input()
hand = input().split()
a = 0
for i in hand:
	if i[0] == card_on_table[0] or i[1] == card_on_table[1]:
		print('YES')
		a = a + 1
		break
	else:
		pass
if a == 0:
	print('NO')


table_card = input()
hand_cards = input()
result = 'NO'
for x in hand_cards.split():
	if x[0] == table_card[0] or x[1] == table_card[1]:
		result = 'YES'
		break
	else:
		pass
print(result)


a = input()
b = input().split()
k = 0
for i in range(5):
	if a[0] == b[i][0] or a[1] == b[i][1]:
		k += 1
if k > 0:
	print('YES')
else:
	print('NO')


c = input()
rank = c[0]
suit = c[1]
cards = input().split()
found = False
for card in cards:
	if card[0] == rank or card[1] == suit:
		found = True
		break
print('YES' if found else 'NO')


n = input()
a = [i for i in input().split()]
f = False
for i in a:
	if i[0] == n[0] or i[1] == n[1]:
		f = True
if f == True:
	print('YES')
else:
	print('NO')


in_table = input()
in_hand = list(input().split())
flag = 0
for ele in in_hand:
	if in_table[0] == ele[0] or in_table[1] == ele[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


tmp = input()
d = False
a1 = tmp[0]
a2 = tmp[1]
tmp = [x for x in input().split()]
for i in range(5):
	if tmp[i][1] == a2 or tmp[i][0] == a1:
		d = True
		break
if d:
	print('YES')
else:
	print('NO')


n = input()
a = input()
if n[0] in a or n[1] in a:
	print('YES')
else:
	print('NO')


m = input()
c = input()
c = c.split()
ss = []
pp = []
for i in range(len(c)):
	st = c[i]
	ss.append(st[0])
	pp.append(st[1])
if m[0] in ss or m[1] in pp:
	print('YES')
else:
	print('NO')


table = input()
number = table[0:1]
suit = table[1:2]
hand = [str(x) for x in input().split()]
for card in hand:
	if number in card[0:1] or suit in card[1:2]:
		print('YES')
		break
else:
	print('NO')


s = input()
l = list(input().split())
s1 = ''.join(l)
if s[0] in s1 or s[1] in s1:
	print('YES')
else:
	print('NO')


s = input()
l = [i for i in input().split()]
l1 = [i[0] for i in l]
l2 = [i[1] for i in l]
if s[0] in ''.join(l1) or s[1] in ''.join(l2):
	print('YES')
else:
	print('NO')


table = input()
d = table[0]
m = table[1]
k = input().split()
for i in k:
	if i[0] == d or i[1] == m:
		print('YES')
		exit()
print('NO')


card_table = input()
cards = input().split()
answer = 'NO'
for card in cards:
	(sets, suits) = (card[0], card[1])
	if sets in card_table or suits in card_table:
		answer = 'YES'
		break
print(answer)


a = input()
z = list(map(str, input().split()))
n = 5
for i in range(n):
	if a[0] == z[i][0] or a[1] == z[i][1]:
		print('YES')
		return
print('NO')


x = input()
str = input()
print('YES' if x[0] in str or x[1] in str else 'NO')


x = input()
y = input().split()
c = 0
for i in range(len(y)):
	if y[i][0] == x[0]:
		print('YES')
		c = 1
		break
	elif y[i][1] == x[1]:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


(a, b) = list(input())
e = ''
d = list(input())
for i in range(len(d)):
	if a == d[i] or b == d[i]:
		e = 'True'
if e != 'True':
	print('NO')
else:
	print('YES')


ab = input()
a = ab[0]
b = ab[1]
s = 0
car = list(map(str, input().split()))
for i in car:
	if i[0] == a or i[1] == b:
		print('YES')
		break
	else:
		s += 1
if s == len(car):
	print('NO')


table_card = input()
(a, b, c, d, e) = list(input().split(' '))
lista = [a, b, c, d, e]
play = 0
for i in lista:
	if i[0] == table_card[0] or i[1] == table_card[1]:
		play += 1
if play > 0:
	print('YES')
else:
	print('NO')


card = input()
cards = input().split()
for i in cards:
	if i[0] == card[0] or i[1] == card[1]:
		print('YES')
		quit()
print('NO')


card = list(input())
hand = list(input())
for _ in card:
	if _ in hand:
		print('YES')
		break
else:
	print('NO')


h = input()
t = input()
if h[0] in t or h[1] in t:
	print('YES')
else:
	print('NO')


i = input()
l = input().split()
flag = 'NO'
for c in i:
	for x in l:
		for y in x:
			if c == y:
				flag = 'YES'
print(flag)


a = input()
cnt = input()
count = 0
for i in a:
	if cnt.find(i) != -1:
		count = count + 1
if count > 0:
	print('YES')
else:
	print('NO')


getInput = input()
getInput2 = input()
getInput2 = getInput2.split()
dec = 'NO'
for item in getInput2:
	if getInput[0] in item or getInput[1] in item:
		dec = 'YES'
		break
print(dec)


hand = input()
(a, b, c, d, e) = input().split()
if hand[0] in (a[0], b[0], c[0], d[0], e[0]):
	print('YES')
elif hand[1] in (a[1], b[1], c[1], d[1], e[1]):
	print('YES')
else:
	print('NO')


s = input()
a = input()
for i in range(len(a)):
	if i % 3 != 2 and a[i] == s[i % 3]:
		print('YES')
		exit(0)
print('NO')


mycard = input()
table = input().split()
check = False
for i in range(5):
	if table[i][0] == mycard[0] or table[i][1] == mycard[1]:
		check = True
if check:
	print('YES')
else:
	print('NO')


table = input()
my_hand = list(map(str, input().split()))
rank = table[0:1]
suit = table[1:]
my_rank = []
my_suit = []
for i in my_hand:
	my_rank.append(i[0:1])
for i in my_hand:
	my_suit.append(i[1:])
if rank in my_rank or suit in my_suit:
	print('YES')
else:
	print('NO')


Table = input('')
Mycard = list(input('').split())
Bool = False
for i in Mycard:
	if i[0] == Table[0] or i[1] == Table[1]:
		print('YES')
		Bool = True
		break
if Bool is False:
	print('NO')


card_open = input()
cards_hand = input().split()
found = 'NO'
for card in cards_hand:
	if card[0] == card_open[0] or card[1] == card_open[1]:
		found = 'YES'
print(found)


table_card = input()
player_cards = input().split()
check_rank = any([table_card[0] in s[0] for s in player_cards])
check_suit = any([table_card[1] in s[1] for s in player_cards])
print('YES' if check_rank or check_suit else 'NO')


def main():
	x = set(input())
	y = set(input())
	print('YNEOS'[not bool(x & y)::2])
main()


def main():
	table = list(input())
	cards = list(map(list, input().split()))
	for i in range(5):
		if cards[i][0] in table or cards[i][1] in table:
			print('YES')
			return 0
	print('NO')
	return 0
main()


x = input()
s = 0
y = list(map(str, input().split()))
for i in y:
	if i[0] == x[0] or i[1] == x[1]:
		print('YES')
		break
	else:
		s += 1
if s == 5:
	print('NO')


desk = input().strip()
pairs = input().strip().split()
is_ok = False
for pair in pairs:
	if pair[0] == desk[0] or pair[1] == desk[1]:
		is_ok = True
if is_ok:
	print('YES')
else:
	print('NO')


s = input().rstrip()
x = list(s)
r = input().rstrip().split(' ')
l = []
q = []
for i in range(0, len(r)):
	c = list(r[i])
	l.append(c[0])
	q.append(c[1])
if x[0] in l or x[0] in q or x[1] in l or (x[1] in q):
	print('YES')
else:
	print('NO')


s = input()
a = input()
b = a.split()
ind = 0
for i in b:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		ind = 1
		break
if ind == 0:
	print('NO')


x = input()
y = list(input().rstrip().split())
for i in y:
	if i[0] == x[0] or i[1] == x[1]:
		print('YES')
		exit(0)
print('NO')


import sys
table = input()
hand = input().split()
for i in range(5):
	if hand[i][0] == table[0] or hand[i][1] == table[1]:
		print('YES')
		sys.exit(0)
print('NO')


__author__ = 'Sudip'
a = input()
b = input()
flag1 = flag2 = -1
flag1 = b.find(a[0])
flag2 = b.find(a[1])
if flag1 != -1 or flag2 != -1:
	print('YES')
else:
	print('NO')


t = list(input())
a = list(map(str, input().split()))
x = ''
for i in a:
	x += i
if t[0] in x or t[1] in x:
	print('YES')
else:
	print('NO')


s = input()
c = input().split()
a = []
b = []
for i in range(5):
	b.append(c[i][1])
	a.append(c[i][0])
f1 = 0
f2 = 0
for j in b:
	if s[1] in b:
		f1 = 1
	if s[0] in a:
		f2 = 1
if f1 == 1 or f2 == 1:
	print('YES')
else:
	print('NO')


d = input()
flag = 0
h = list(input().split(' '))
for i in range(5):
	if d[0] == h[i][0] or d[1] == h[i][1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


import sys
table_card = sys.stdin.readline().strip()
your_cards = sys.stdin.readline().strip().split()
for current_card in your_cards:
	if current_card[0] == table_card[0] or current_card[1] == table_card[1]:
		sys.stdout.write('YES\n')
		break
else:
	sys.stdout.write('NO\n')


a = input()
c = [str(x) for x in input().split()]
c2 = []
g = 1
for i in c:
	c2.append(i[0])
	c2.append(i[1])
for i in a:
	if i in c2:
		g = 0
if g == 0:
	print('YES')
else:
	print('NO')


import sys
data = sys.stdin.read().splitlines()
s1 = data[0]
s2 = data[1]
print('YES' if any((ch in s2 for ch in s1)) else 'NO')


s = input()
lst = list(input().split())
new_lst = []
for i in lst:
	new_lst.append(i[0])
	new_lst.append(i[1])
if s[0] in new_lst:
	print('YES')
elif s[1] in new_lst:
	print('YES')
else:
	print('NO')


table = input()
hand = list(input().split())

def play(table, hand):
	for i in hand:
		if i[0] == table[0] or i[1] == table[1]:
			return 'YES'
	return 'NO'
print(play(table, hand))


on_table = input()
cd_num = on_table[0]
cd_type = on_table[1]
in_hand = [i for i in input().split()]
in_hand_crd = []
in_hnd_card_num = []
for i in in_hand:
	in_hnd_card_num.append(i[0])
	in_hand_crd.append(i[1])
if cd_num in in_hnd_card_num or cd_type in in_hand_crd:
	print('YES')
else:
	print('NO')


inp1 = input()
inp2 = input().split()
for i in inp2:
	if inp1[0] in i or inp1[1] in i:
		print('YES')
		break
else:
	print('NO')


def check(lst, n):
	for i in range(len(lst)):
		if lst[i] == n[0] or lst[i] == n[1]:
			return 1
	return 0
n = input()
n = list(n)
s = list(input().split())
lst = []
for i in range(len(s)):
	for j in range(len(s[i])):
		lst.append(s[i][j])
if check(lst, n):
	print('YES')
else:
	print('NO')


k = input('')
(a, b, c, d, e) = input('').split(' ')
p = k[0]
q = k[1]
t = (a, b, c, d, e)
for i in t:
	if i[0] == p or i[1] == q:
		print('YES')
		break
else:
	print('NO')


m = input()
mano = input().split(' ')
se_puede = False
for carta in mano:
	if carta[0] == m[0]:
		print('YES')
		se_puede = True
		break
	elif carta[1] == m[1]:
		se_puede = True
		print('YES')
		break
if not se_puede:
	print('NO')


curr_card = input().strip()
hand = set(input())
if curr_card[0] in hand or curr_card[1] in hand:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split(' ')
b = False
for i in range(len(hand)):
	if hand[i][0] == table[0] or hand[i][1] == table[1]:
		b = True
if b == True:
	print('YES')
else:
	print('NO')


card = input()
(rank, suit) = (card[0], card[1])
fifs = map(str, input().split())
test = False
for i in fifs:
	if i[0] == rank or i[1] == suit:
		test = True
		break
print('YES' if test else 'NO')


def check(cards, card):
	for i in range(len(cards)):
		if card[0] == cards[i][0] or card[1] == cards[i][1]:
			return 'YES'
	return 'NO'
card = input()
my_cards = input().split()
print(check(my_cards, card))


card_on_table = input()
my_cards = map(str, input().split())
ans = False
for card in my_cards:
	if card[0] == card_on_table[0] or card[1] == card_on_table[1]:
		ans = True
if ans:
	print('YES')
else:
	print('NO')


kS = input()
kar = input().split()
prov = 'NO'
for k in kar:
	if kS[0] == k[0] or kS[1] == k[1]:
		prov = 'YES'
		break
print(prov)


tc = input()
mc = [x for x in input().split()]
for c in mc:
	if c[0] in tc or c[1] in tc:
		print('YES')
		break
else:
	print('NO')


(c, s) = list(input())
i = input()
if c in i or s in i:
	print('YES')
else:
	print('NO')


card = input()
hand = input()
hand = list(hand.split(' '))
n = card[0]
s = card[1]
numbers = []
suits = []
for i in hand:
	numbers.append(i[0])
	suits.append(i[1])
numbers = set(numbers)
suits = set(suits)
if n in numbers or s in suits:
	print('YES')
else:
	print('NO')


s = input()
flag = False
k = [str(x) for x in input().split()]
i = 0
for i in k:
	if s[0] == i[0] or s[1] == i[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


hand = str(input())
table = str(input()).split()
status = True
for i in range(len(table)):
	if hand[0] == table[i][0]:
		print('YES')
		status = False
		break
	if hand[1] == table[i][1]:
		print('YES')
		status = False
		break
if status:
	print('NO')


card = input()
(rank, suit) = (card[0], card[1])
hand = input().split()
ranks = []
suits = []
i = 0
while i < 5:
	ranks.append(hand[i][0])
	suits.append(hand[i][1])
	i += 1
if suit in suits or rank in ranks:
	print('YES')
else:
	print('NO')


t = input()
y = input().replace(' ', '')
for a in y:
	if a == t[0] or a == t[1]:
		print('YES')
		break
else:
	print('NO')


c = input()
cards = {j for i in input().split() for j in i}
print('YES' if c[0] in cards or c[1] in cards else 'NO')


ish = input()
z = list(input().split())
flag = 0
for i in range(5):
	if z[i][0] == ish[0] or z[i][1] == ish[1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


a = input()
b = input()
b = b.split()
w = []
for i in range(len(b)):
	w.extend(b[i][0])
	w.extend(b[i][1])
if a[0] in w:
	print('YES')
elif a[1] in w:
	print('YES')
else:
	print('NO')


c = list(input())
d = list(input())
f = 0
for i in c:
	if i in d:
		f = 1
		print('YES')
		break
if f == 0:
	print('NO')


n = input()
li = input()
i = 0
count = 0
p = 'NO'
while i < len(li):
	if li[i] == n[0] or li[i] == n[1]:
		count = count + 1
		p = 'YES'
		break
	i = i + 1
print(p)


s = input()
a = list(s)
a1 = list(map(str, input().split()))
count = 0
for i in range(len(a1)):
	t = a1[i]
	if t[0] in a or t[1] in a:
		count = count + 1
	else:
		pass
if count >= 1:
	print('YES')
else:
	print('NO')


suit = input()
rank = input()
result = 0
for i in suit:
	if i in rank:
		result = 1
		break
if result:
	print('YES')
else:
	print('NO')


x = input()
a = [x for x in input().split()]
count = 0
for i in a:
	for (g, f) in zip(i, x):
		if g == f:
			count = 1
		else:
			continue
if count == 1:
	print('YES')
else:
	print('NO')


(a, c) = (input(), 0)
for i in input().split():
	k = [ch for ch in i]
	for j in k:
		if j in a:
			c = 1
if c == 1:
	print('YES')
else:
	print('NO')


a = input()
inp = list(input().split())
first = []
sec = []
for item in inp:
	first.append(item[0])
	sec.append(item[1])
if a[0] in first or a[1] in sec:
	print('YES')
else:
	print('NO')


in_ = input()
in_array = input().split()
flag = False
for i in range(0, len(in_array)):
	for j in range(0, len(in_array[i])):
		if in_array[i][j] == in_[j]:
			flag = True
			break
	if flag == True:
		break
if flag == True:
	print('YES')
else:
	print('NO')


card = input()
l = [x for x in input().strip().split()]
solfound = False
for i in l:
	if i[1:] == card[1:]:
		print('YES')
		solfound = True
		break
	elif i[0:1] == card[0:1]:
		print('YES')
		solfound = True
		break
if solfound == False:
	print('NO')


def solve(hand, table):
	output = ''
	for i in range(len(table)):
		if table[i].__contains__(hand[0]) or table[i].__contains__(hand[1]):
			output = 'YES'
			break
		else:
			output = 'NO'
	return output
card_hand = str(input())
cards_table = list(map(str, input().split()))
print(solve(card_hand, cards_table))


X = input()
C = list(input().split())
Y = 0
for i in C:
	if i[1] == X[1] or i[0] == X[0]:
		Y = 1
		break
if Y == 1:
	print('YES')
else:
	print('NO')


table = input()
ans = []
hand = list(input().split())
for r in hand:
	if table[0] in r or table[1] in r:
		ans.append('Y')
		break
if 'Y' in ans:
	print('YES')
else:
	print('NO')


suits = {'H': 0, 'S': 1, 'C': 2, 'D': 3}
values = {'2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, '10': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 1}
x = input()
(a, b, c, d, e) = map(str, input().split())

def split_char(str):
	return [char for char in str]
table_card = split_char(x)
hand_card1 = split_char(a)
hand_card2 = split_char(b)
hand_card3 = split_char(c)
hand_card4 = split_char(d)
hand_card5 = split_char(e)
k = 0
suit = []
suit.extend([hand_card1[1], hand_card2[1], hand_card3[1], hand_card4[1], hand_card5[1]])
val = []
val.extend([hand_card1[0], hand_card2[0], hand_card3[0], hand_card4[0], hand_card5[0]])
for s in suit:
	if s == table_card[1]:
		k = 1
for v in val:
	if v == table_card[0]:
		k = 1
if k == 1:
	print('YES')
else:
	print('NO')


st = input()
List = [str(j) for j in input().split(' ')]
count = 0
for i in range(5):
	if List[i][1] in st or List[i][0] in st:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


n = input()
str = input()
print('YES') if str.find(n[0]) != -1 or str.find(n[1]) != -1 else print('NO')


h = input()
count = {}

def splitThis(word):
	(a, b) = word
	count[a] = 1
	count[b] = 1
counter = list(map(splitThis, input().split()))
if h[0] in count or h[1] in count:
	print('YES')
else:
	print('NO')


A = sorted(list(str(input())))
B = sorted(list(str(input())))
a = A[0]
b = A[1]
if a in B:
	print('YES')
elif b in B:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
rank = table[0]
suit = table[1]
in_hd = hand[0][0]
l = []
for i in range(5):
	if rank in hand[i][0]:
		l.append('YES')
	if suit in hand[i][1]:
		l.append('YES')
	else:
		l.append('NO')
if int(l.count('YES')) > 0:
	print('YES')
else:
	print('NO')


(card, suit) = [x for x in list(input())]
cards = []
suits = []
input_lines = input().split()
for input_line in input_lines:
	data = list(input_line)
	cards.append(data[0])
	suits.append(data[1])
if card in cards or suit in suits:
	print('YES')
else:
	print('NO')


s = input()
a = list(input().split())
a = ''.join(a)
for i in a:
	if i in s:
		exit(print('YES'))
print('NO')


g = input()
my5 = input()
if g[0] in my5[::3] or g[1] in my5[1::3]:
	print('YES')
else:
	print('NO')


s = input()
flag = 0
for i in map(str, input().strip().split()):
	for j in i:
		if j in s:
			print('YES')
			flag = 1
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


s = input()
a = input().split()

def f():
	for e in a:
		if s[0] == e[0] or s[1] == e[1]:
			print('YES')
			return
	print('NO')
f()


in1 = input()
in2 = input()
y = 0
for x in in2:
	if in1[0] == x or in1[1] == x:
		y = 1
if y == 1:
	print('YES')
else:
	print('NO')


print('YES' if set(input()) & set(input()) else 'NO')


cT = list(input())
cH = list(''.join(input().split(' ')))

def index(a_list, value):
	try:
		return a_list.index(value)
	except ValueError:
		return -1
if index(cH, cT[0]) != -1 or index(cH, cT[1]) != -1:
	print('YES')
else:
	print('NO')


on_table = input()
in_hand = input().split()
flag = -1
for card in in_hand:
	if on_table[0] == card[0] or on_table[1] == card[1]:
		print('YES')
		flag = 0
		break
if flag == -1:
	print('NO')


import sys
s = input()
lst = list(input().split(' '))
ans = False
for i in range(len(lst)):
	if s[0] == lst[i][0] or s[1] == lst[i][1]:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


table_card = input()
hand_cards = ''.join(input().split())
h = [1 for t in table_card if t in hand_cards]
print('NYOE S'[1 in h::2])


suit = input('')
suit = suit.upper()
(c1, c2, c3, c4, c5) = input().split(' ')
if suit[0] == c1[0] or suit[1] == c1[1] or suit[0] == c1[1] or (suit[1] == c1[0]):
	print('YES')
elif suit[0] == c2[0] or suit[1] == c2[1] or suit[0] == c2[1] or (suit[1] == c2[0]):
	print('YES')
elif suit[0] == c3[0] or suit[1] == c3[1] or suit[0] == c3[1] or (suit[1] == c3[0]):
	print('YES')
elif suit[0] == c4[0] or suit[1] == c4[1] or suit[0] == c4[1] or (suit[1] == c4[0]):
	print('YES')
elif suit[0] == c5[0] or suit[1] == c5[1] or suit[0] == c5[1] or (suit[1] == c5[0]):
	print('YES')
else:
	print('NO')


table_card = list(input())
hand_cards = input().split()
for card in hand_cards:
	if table_card[0] in card or table_card[1] in card:
		print('YES')
		exit(0)
print('NO')


s = input()
l = list(map(str, input().split()))
a = s[0]
b = s[1]
flag = 0
for i in range(len(l)):
	if l[i][0] == a or l[i][1] == b:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


x = input()
y = list(map(str, input().split()))
s = set([i[0] for i in y])
s1 = set([i[1] for i in y])
if x[0] in s:
	print('YES')
elif x[1] in s1:
	print('YES')
else:
	print('NO')


def mn(a, b):
	return a[0] == b[0] or a[1] == b[1]
tc = input()
yc = list(input().split())
ans = any((mn(tc, a) for a in yc))
print('YES' if ans else 'NO')


On_The_Table = input()
In_The_Hand = list(map(str, input().split()))
for i in In_The_Hand:
	if i[0] == On_The_Table[0]:
		print('YES')
		exit()
	elif i[1] == On_The_Table[1]:
		print('YES')
		exit()
print('NO')


import re

def sm(v):
	(f, s) = v
	p = '|'.join(f)
	m = re.search(p, s)
	return ('yes' if m else 'no').upper()
v = [input() for _ in range(2)]
print(sm(v))


(n, r) = (input(), 'NO')
cr = list(map(str, input().split()))
for i in cr:
	if i[0] == n[0] or i[1] == n[1]:
		r = 'YES'
		break
print(r)


s = list(input())
a = [list(str(x)) for x in input().split()]
c = 0
for i in range(len(a)):
	if a[i][0] in s or a[i][1] in s:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


from sys import stdin
a = stdin.readline()
A = a[0]
B = a[1]
a = stdin.readline()
c = 0
K = 0
d = 1
while c < 13:
	if a[c] == A:
		K = 1
	c += 3
while d < 14:
	if a[d] == B:
		K = 1
	d += 3
if K == 1:
	print('YES')
else:
	print('NO')


q = input()
w = input()
print('YES' if q[0] in w or q[1] in w else 'NO')


a = str(input())
b = list(map(str, input().split()))
for i in a:
	c = 0
	if i == b[0][0] or i == b[0][1] or i == b[1][0] or (i == b[1][1]) or (i == b[2][0]) or (i == b[2][1]) or (i == b[3][0]) or (i == b[3][1]) or (i == b[4][0]) or (i == b[4][1]):
		c = 1
		break
	else:
		c = 0
if c == 1:
	print('YES')
else:
	print('NO')


def gen_and_card_game():
	card = input()
	my_cards = list(input().split(sep=' '))
	for i in my_cards:
		if i[0] == card[0] or i[1] == card[1]:
			print('YES')
			break
	else:
		print('NO')
gen_and_card_game()


card = input()
hand = list(map(str, input().split()))
flag = False
for i in range(0, 5):
	if hand[i][0] == card[0] or hand[i][1] == card[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
card_hand = input()
p = 0
FLAG = 0
for i in range(len(card_hand)):
	if card_hand[i] == s[0] or card_hand[i] == s[1]:
		FLAG = 1
if FLAG == 1:
	print('YES')
else:
	print('NO')


import re, math, decimal, bisect

def read():
	return input().strip()

def iread():
	return int(input().strip())

def viread():
	return [int(_) for _ in input().strip().split()]
card = read()
mine = read().split()
for c in mine:
	if c[0] == card[0] or c[1] == card[1]:
		print('YES')
		return
print('NO')


table = input()
hand = input().split()
a = 0
for i in hand:
	if i[1] == table[1]:
		a += 1
		break
	elif i[0] == table[0]:
		a += 1
		break
if a > 0:
	print('YES')
else:
	print('NO')


a = input()
bs = input().split()
ok = False
for i in range(5):
	b = bs[i]
	if b[0] == a[0] or b[1] == a[1]:
		ok = True
		break
if ok:
	print('YES')
else:
	print('NO')


a = input()
str = input()
print('YES' if a[0] in str or a[1] in str else 'NO')


n = input()
a = input().split()
for i in range(len(a)):
	d = a[i]
	if d[0] == n[0] or d[1] == n[1]:
		print('YES')
		break
else:
	print('NO')


a = input()

def solve():
	arr = [x for x in input().split()]
	for item in arr:
		if item[0] == a[0] or item[1] == a[1]:
			return 'YES'
	return 'NO'
print(solve())


card = input()
hand = input().split(' ')
print('YES' if card[0] in [x[0] for x in hand] or card[1] in [x[1] for x in hand] else 'NO')


n = input()
kart = input().split()
for item in kart:
	if item[0] == n[0]:
		print('YES')
		break
	elif item[1] == n[1]:
		print('YES')
		break
else:
	print('NO')


table_card = input()
table_rank = table_card[0]
table_suit = table_card[1]
hand = list(map(str, input().split()))
hand_ranks = [i[0] for i in hand]
hand_suits = [i[1] for i in hand]
if table_rank in hand_ranks or table_suit in hand_suits:
	print('YES')
else:
	print('NO')


onTable = input()
inHand = ''.join(input().split())
if onTable[0] in inHand or onTable[1] in inHand:
	print('YES')
else:
	print('NO')


(r, s) = input()
H = input()
print(('NO', 'YES')[r in H or s in H])


x = input()
flag = 0
p = list(map(str, input().split()))
for y in p:
	if x[0] == y[0] or x[1] == y[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


def func():
	card = input()
	(rank, suit) = (card[0], card[1])
	hand = input().split(' ')
	for c in hand:
		if rank in c or suit in c:
			print('YES')
			return
	print('NO')
func()


(Yedige, Askar) = input()
kapkarashka = input()
print(('NO', 'YES')[Yedige in kapkarashka or Askar in kapkarashka])


n = input()
l = list(map(str, input().split()))
flag = 0
for i in range(len(l)):
	if n[0] == l[i][0] or n[1] == l[i][1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


s = input()
st = input().split(' ')
f = False
for i in st:
	if s[-1] == i[-1] or s[0] == i[0]:
		f = True
		break
if f:
	print('YES')
else:
	print('NO')


on_table = input()
cards = [str(i) for i in input().split()]
flag = 0
for i in cards:
	if on_table[0] == i[0] or on_table[1] == i[1]:
		print('YES')
		flag = 1
		break
if flag is 0:
	print('NO')


import math
s = input()
a = list(map(str, input().split()))
c = 0
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


a = input()
cards = input().split()
r = []
for v in cards:
	if a[0] == v[0] or a[1] == v[1]:
		r.append(True)
	else:
		r.append(False)
if True in r:
	print('YES')
else:
	print('NO')


s = input()
(a, b, c, d, e) = input().split()
f = False
t = [a, b, c, d, e]
for x in t:
	if s[0] == x[0] or s[1] == x[1]:
		f = True
if f:
	print('YES')
else:
	print('NO')


table = input()
arr = list(input().split())
ok = False
for i in arr:
	if table[0] == i[0] or table[1] == i[1]:
		ok = True
		break
print('YES' if ok else 'NO')


import re

def numberGatherer():
	generalArray = re.findall('[+-]?\\d+', input(''))
	for index in range(0, len(generalArray)):
		generalArray[index] = int(generalArray[index])
	return generalArray
tableCard = input()
tableCardCharacters = []
for element in tableCard:
	tableCardCharacters.append(element)
handCards = input()
handCardsCharacters = []
for element in handCards:
	if element != ' ':
		handCardsCharacters.append(element)
for index in range(0, len(handCardsCharacters)):
	if handCardsCharacters[index] == tableCardCharacters[0] or handCardsCharacters[index] == tableCardCharacters[1]:
		print('YES')
		break
	elif index == len(handCardsCharacters) - 1:
		print('NO')


table = list(input())
hands = list(input().split(' '))
for i in range(5):
	if hands[i][0] in table or hands[i][1] in table:
		print('YES')
		break
	if i == 4:
		print('NO')


s = input()
t = input()
if s[0] in t:
	print('YES')
elif s[1] in t:
	print('YES')
else:
	print('NO')


st = input()
sh = input().split()
flag = 0
for i in range(len(sh)):
	if st[0] == sh[i][0] or st[1] == sh[i][1]:
		flag = 1
		print('YES')
		break
if flag == 0:
	print('NO')


def good(s, s_1):
	a = ''
	b = ''
	for i in range(0, len(s), 3):
		a = a + s[i]
	for i in range(1, len(s), 3):
		b = b + s[i]
	if s_1[0] in a or s_1[1] in b:
		print('YES')
	else:
		print('NO')
s_1 = input()
s = input()
good(s, s_1)


import sys
s = input()
rank = s[0]
suit = s[1]
T = input().split()
for t in T:
	if t[0] == rank or t[1] == suit:
		print('YES')
		sys.exit()
print('NO')


my_card = input()
cards_on_table = input()
if my_card[0] in cards_on_table or my_card[1] in cards_on_table:
	print('YES')
else:
	print('NO')


def read(type=1):
	if type:
		file = open('input.dat', 'r')
		card = file.readline()
		line = file.readline().split()
		file.close()
	else:
		card = input().strip()
		line = input().strip().split()
	return (card, line)

def solve():
	for c in cards:
		if c[0] == card[0] or c[1] == card[1]:
			return 1
	return 0
(card, cards) = read(0)
if solve():
	print('YES')
else:
	print('NO')


on_table = input()
on_table = on_table.upper()
your = input()
your = your.upper()
s = ''
for i in range(len(your)):
	if on_table[0] in your or on_table[1] in your:
		s = 'YES'
	else:
		s = 'NO'
print(s)


n = input()
for i in input().split():
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		quit()
print('NO')


c = input()
t = list(input().split())
count = 0
for card in t:
	if c[0] in card or c[1] in card:
		count = 1
if count == 1:
	print('YES')
else:
	print('NO')


table = input()
tab = list(table)
hand = input()
han = list(hand)
m = 0
for item in han:
	for index in tab:
		if item is index:
			m += 1
		else:
			continue
if m == 0:
	print('NO')
elif m > 0:
	print('YES')


(number, suit) = input()
t = False
for x in input():
	if number in x or suit in x:
		t = True
if t:
	print('YES')
else:
	print('NO')


t = input()
(t, t1) = map(str, t)
h = []
a = input()
for i in range(0, 5):
	h.append(a)
for i in h:
	for j in i:
		if str(j) == t or str(j) == t1:
			flag = True
			break
		else:
			flag = False
	if flag == False:
		print('NO')
		break
	else:
		print('YES')
		break


n = input()
m = input()
l1 = list(n)
l2 = list(m)
if l1[0] in l2 or l1[1] in l2:
	print('YES')
else:
	print('NO')


t = input()
string = input().strip().split()
count = 0
for i in string:
	if i[0] in t or i[1] in t:
		count += 1
if count >= 1:
	print('YES')
else:
	print('NO')


count = 0
card_hand = input('')
(card1, card2, card3, card4, card5) = map(str, input().split(' '))
x = -1
l = []
l.append(card1)
l.append(card2)
l.append(card3)
l.append(card4)
l.append(card5)
a = 0
for i in l:
	x = x + 1
	if x == 4:
		x = 3
	if set(i[0]).intersection(set(card_hand[0])):
		a = 5
	else:
		count = count + 1
	if set(i[1]).intersection(set(card_hand[1])):
		a = 5
	else:
		count = count - 1
if a == 5:
	print('YES')
elif a == 0:
	print('NO')


t = input()
h = list(input().split())
a = 0
for i in range(5):
	if t[0] == h[i][0] or t[1] == h[i][1]:
		a = a + 1
if a == 0:
	print('NO')
else:
	print('YES')


s = input()
a = input()
print('NYOE S'[any((i in a for i in s))::2])


import sys
from math import floor

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

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

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

def listinput():
	return list(map(int, input().split()))
s = input()
answer = 'NO'
l = list(map(str, input().split()))
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		answer = 'YES'
		break
print(answer)


a = input()
x = list(map(str, input().split()))
if a[0] in x[0] or a[1] in x[0] or a[0] in x[1] or (a[1] in x[1]) or (a[0] in x[2]) or (a[1] in x[2]) or (a[0] in x[3]) or (a[1] in x[3]) or (a[0] in x[4]) or (a[1] in x[4]):
	print('YES')
else:
	print('NO')


board = input()
hand = input().split(' ')
ok = 0
for card in hand:
	if card[0] == board[0] or card[1] == board[1]:
		ok = 1
		break
if ok == 1:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split(' ')
rank = list(map(lambda x: x[0], hand))
suit = list(map(lambda x: x[1], hand))
print('YES' if table[0] in rank or table[1] in suit else 'NO')


n = input()
a = input().split()
f = 1
for i in a:
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		f = 0
		break
if f:
	print('NO')


is_debug = False
table = input()
hands = input().split()
table_suit = table[0]
table_rank = table[1]
can_play = False
for hand in hands:
	hand_suit = hand[0]
	hand_rank = hand[1]
	can_play = can_play or table_suit == hand_suit or table_rank == hand_rank
print(f"{('YES' if can_play else 'NO')}")


s = input()
l = input().split()
flag = True
for i in l:
	if any((c in s for c in i)):
		print('YES')
		flag = False
		break
if flag:
	print('NO')


a = input()
b = input()
ans = 'NO'
for elem in b:
	if elem in a:
		ans = 'YES'
		break
print(ans)


card0 = input()
(card1, card2, card3, card4, card5) = input().split()
cards = [card1, card2, card3, card4, card5]
color = card0[0]
num = card0[1]
colors = []
nums = []
for i in cards:
	colors.append(i[0])
	nums.append(i[1])
if color in colors or num in nums:
	print('YES')
else:
	print('NO')


a = input()
s = list(input().split(' '))
for elem in s:
	if elem[0] == a[0] or elem[1] == a[1]:
		print('YES')
		exit()
print('NO')


a = input()
b = input().split()
c = [b[0][0], b[1][0], b[2][0], b[3][0], b[4][0]]
d = [b[0][1], b[1][1], b[2][1], b[3][1], b[4][1]]
e = 0
for i in range(5):
	if c[i] == a[0]:
		e = e + 1
		break
	if d[i] == a[1]:
		e = e + 1
		break
if e == 1:
	print('YES')
else:
	print('NO')


f = input()
l = list(input().split())
rank = []
suit = []
a = l[0]
b = l[1]
c = l[2]
d = l[3]
e = l[4]
rank.append(a[0])
rank.append(b[0])
rank.append(c[0])
rank.append(d[0])
rank.append(e[0])
suit.append(a[1])
suit.append(b[1])
suit.append(c[1])
suit.append(d[1])
suit.append(e[1])
r = f[0]
s = f[1]
if r in rank or s in suit:
	print('YES')
else:
	print('NO')


OnTable = input()
hand = list(map(str, input().split()))
for i in range(5):
	if OnTable[0] == hand[i][0] or OnTable[1] == hand[i][1]:
		print('YES')
		break
	elif i == 4:
		print('NO')


s = input()
s1 = input()
l = list(s1.split(' '))
c = 0
for i in l:
	if s[0] == i[0] or s[1] == i[1]:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


s = input()
a = list(map(str, input().split()))
n = 5
flag = 0
for i in range(0, 5):
	if a[i][0] == s[0] or a[i][0] == s[1] or a[i][1] == s[0] or (a[i][1] == s[1]):
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


st = input()
(num, mas) = (st[0], st[1])
st = input()
if num in st or mas in st:
	print('YES')
else:
	print('NO')


def get_solution(cot, mc):
	for card in mc:
		if card.find(cot[0]) != -1:
			return 'YES'
		if card.find(cot[1]) != -1:
			return 'YES'
	return 'NO'
card_on_table = input()
my_cards = input().split()
print(get_solution(card_on_table, my_cards))


import sys
tc = input()
hands = input().split()
for h in hands:
	if h[0] == tc[0] or h[1] == tc[1]:
		print('YES')
		sys.exit()
print('NO')


s = input()
ru = input().split()
rum = [i[1] for i in ru]
ruz = [i[0] for i in ru]
if s[0] in ruz or s[1] in rum:
	print('YES')
else:
	print('NO')


t = input()
I = input().split()

def check(t, I):
	for i in range(len(I)):
		if t[0] == I[i][0] or t[1] == I[i][1]:
			return 'YES'
	return 'NO'
print(check(t, I))


print(['YES', 'NO'][not set(input()) & set(input())])


table = input()
cards = list(map(str, input().split()))
result = 'NO'
count = 0
for i in table:
	for x in cards:
		letter = list(x)
		if i == letter[count]:
			result = 'YES'
			break
	count += 1
print(result)


from sys import exit as sys_return
card = input()
for i in input().split():
	if i[0] == card[0] or i[1] == card[1]:
		print('YES')
		sys_return(0)
print('NO')


card = input()
(c1, c2, c3, c4, c5) = input().split(' ')
yourCard = [c1, c2, c3, c4, c5]
fCard = []
lCard = []
for f in yourCard:
	fCard.append(f[0])
for l in yourCard:
	lCard.append(l[1])
if card[0] in fCard or card[1] in lCard:
	print('YES')
else:
	print('NO')


t = input()
l = [i for i in input().split()]
count = 0
for i in l:
	if i[-1] == t[-1] or i[0] == t[0]:
		print('YES')
		break
	else:
		count += 1
if count == len(l):
	print('NO')


t = list(input())
s = input()
flag = False
if t[0] in s:
	flag = True
if t[1] in s:
	flag = True
if flag:
	print('YES')
else:
	print('NO')


(a, d) = (input(), input())
print('YES' if a[0] in d or a[1] in d else 'NO')


a = input()
b = input().split()
fl = False
for i in b:
	if i[0] == a[0] or a[1] == i[1]:
		fl = True
if fl:
	print('YES')
else:
	print('NO')


print('YES' if len(set(input()) & set(input())) > 0 else 'NO')


hand = input()
table = input().split()[:5]
answer = 'NO'
for card in table:
	if hand[0] == card[0] or hand[1] == card[1]:
		answer = 'YES'
		break
print(answer)


def move(board, hand):
	for card in hand:
		if board[0] == card[0] or board[1] == card[1]:
			return True
	return False
rank = ['2', '3', '4', '5', '6', '7', '8', 'T', 'J', 'Q', 'K', 'A']
suit = ['D', 'C', 'S', 'H']
board = input()
inp = list(input().rstrip().split())
if move(board, inp):
	print('YES')
else:
	print('NO')


a = input()
b = input()
i = 0
flag = 0
while i < len(b):
	if a[0] in b or a[1] in b:
		flag = 1
		break
	i += 1
if flag:
	print('YES')
else:
	print('NO')


import sys

def solve():
	rank = str(input())
	board = list(map(str, input().split()))
	for c in enumerate(board):
		if str(c[1][0]) == rank[0] or str(c[1][1]) == rank[1]:
			return 'YES'
	return 'NO'
print(solve())


class Solution:

	def solve(self, cardOnTable, cards):
		for card in cards:
			if card[0] == cardOnTable[0] or card[1] == cardOnTable[1]:
				return True
		return False
sol = Solution()
cardOnTable = input().strip()
cards = list(input().strip().split())
print('YES' if sol.solve(cardOnTable, cards) else 'NO')


(k, m) = (input(), input())
print('YES' if k[0] in m or k[1] in m else 'NO')


card = input()
hand = input().split()
yes = False
for i in hand:
	if i[0] in card or i[1] in card:
		yes = True
		break
print('YES' if yes else 'NO')


A = input()
B = input().split()
S = 0
for i in B:
	if A[0] == i[0] or A[1] == i[1]:
		S += 1
if S > 0:
	print('YES')
else:
	print('NO')


str = input()
c = 0
a = [x for x in input().split()]
for x in a:
	if x[0] == str[0] or x[1] == str[1]:
		c = c + 1
		break
if c > 0:
	print('YES')
else:
	print('NO')


s = input()
l = [x for x in input().split()]
f = 0
for i in range(len(l)):
	if l[i][0] == s[0]:
		f = 1
		print('YES')
		break
	elif l[i][1] == s[1]:
		f = 1
		print('YES')
		break
if f == 0:
	print('NO')


import sys
string = input()
array = input().split()
for i in range(len(array)):
	if array[i][0] == string[0] or array[i][1] == string[1]:
		print('YES')
		sys.exit(0)
print('NO')


s = input()
l = input().split()
c = 0
for i in l:
	if s[0] == i[0] or s[1] == i[1]:
		c += 1
if c != 0:
	print('YES')
else:
	print('NO')


card_on_deck = input()
cards_in_hand = input().split()
can_play = 'NO'
for card in cards_in_hand:
	if card[0] == card_on_deck[0] or card[1] == card_on_deck[1]:
		can_play = 'YES'
		break
print(can_play)


n = list(map(str, input()))
(a, b, c, d, e) = map(str, input().split())
l = []
l.append(list(a))
l.append(list(b))
l.append(list(c))
l.append(list(d))
l.append(list(e))
count = 0
for items in l:
	for item in n:
		if item in items:
			count += 1
if count > 0:
	print('YES')
else:
	print('NO')


a = str(input())
input_string = input()
userList = input_string.split()
results = list(map(str, userList))
b = a[0:1]
c = a[1:2]
list_one = []
for i in range(0, 5):
	list_one.append(results[i][0])
list_two = []
for i in range(0, 5):
	list_two.append(results[i][1])
if b in list_one:
	print('YES')
elif c in list_two:
	print('YES')
else:
	print('NO')


s1 = input()
a = input().split()
ist = False
for i in a:
	ist = s1[0] == i[0] or s1[1] == i[1]
	if ist:
		print('YES')
		break
if not ist:
	print('NO')


c = input()
a = [x for x in input().split()]
flag = 0
for i in a:
	if c[0] in i or c[1] in i:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


a = input()
b = input()
print(('NO', 'YES')[a[0] in b or a[1] in b])


table = input()
hand = input()
for i in table:
	if hand.find(i) != -1:
		print('YES')
		quit()
print('NO')


def main():
	table = input()
	cards = input().split()
	for card in cards:
		if card[0] == table[0] or card[1] == table[1]:
			print('YES')
			return
	print('NO')
main()


a = input()
arr = input().split()
res = 'NO'
for i in arr:
	if i[0] == a[0] or i[1] == a[1]:
		res = 'YES'
		break
print(res)


card = input()
cset = input()
if card[0] in cset or card[1] in cset:
	print('YES')
else:
	print('NO')


s = input()
s1 = list(map(str, input().split()))
arr = []
arr1 = []
for i in range(len(s1)):
	arr.append(s1[i][0])
	arr1.append(s1[i][1])
if s[0] in arr or s[1] in arr1:
	print('YES')
else:
	print('NO')


table = input()
hand = input()
found = 0
for i in table:
	if hand.find(i) != -1:
		found = 1
		break
if found == 0:
	print('NO')
else:
	print('YES')


mc = input()
cs = [x for x in input().split()]
for c in cs:
	if mc[0] == c[0] or mc[1] == c[1]:
		print('YES')
		exit()
print('NO')


first = input()
c = 0
hand = list(input().split())
for i in range(5):
	if first[0] == hand[i][0]:
		c += 1
		break
	elif first[1] == hand[i][1]:
		c += 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input()
for i in s1:
	if i in s2:
		print('YES')
		exit(0)
print('NO')


a = list(input())
b = input().split()
ans = 0
for i in range(len(b)):
	if a[0] == b[i][0] or a[0] == b[i][1] or a[1] == b[i][0] or (a[1] == b[i][1]):
		ans = 1
if ans == 0:
	print('NO')
else:
	print('YES')


def main():
	table = input()
	hand = input()
	print('YES') if len(list(set(table).intersection(hand))) > 0 else print('NO')
main()


def test(o, cards):
	for c in cards:
		if c[0] == o[0]:
			return True
		if c[1] == o[1]:
			return True
	return False
o = input()
cards = input()
if test(o, cards.split()):
	print('YES')
else:
	print('NO')


s = input()
s1 = input()
if s1.count(s[0]) > 0 or s1.count(s[1]) > 0:
	print('YES')
else:
	print('NO')


s = input()
cards = list(map(str, input().split()))
x = s[0]
y = s[1]
f = 0
for card in cards:
	if x in card or y in card:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


def program(n):
	for i in n:
		if i[0] in a or i[1] in a:
			return 'YES'
	return 'NO'
a = input()
n = list(map(str, input().strip().split()))
print(program(n))


table = input()
mycard = input()
if table[0] in mycard or table[1] in mycard:
	print('YES')
else:
	print('NO')


n = input()
a = n[:1]
b = n[1:]
cards = list(input().split(' '))
ls = []
for i in cards:
	if i[:1] == a or i[1:] == b:
		ls.append('YES')
	else:
		ls.append('NO')
res = ls.count('YES')
if res > 0:
	print('YES')
else:
	print('NO')


card_on_table = list(input())
card_in_hands = input().split()
output = 'NO'
for card in card_in_hands:
	card = list(card)
	if card_on_table[0] == card[0]:
		output = 'YES'
		break
	elif card_on_table[1] == card[1]:
		output = 'YES'
		break
print(output)


def solve(card_deck, cards):
	for card in cards:
		card_arr = [char for char in card]
		for c in card_arr:
			if c in [ch for ch in card_deck]:
				return 'YES'
	return 'NO'
card_on_deck = input()
cards_on_hand = []
cards_on_hand = list(map(str, input().split()))
print(solve(card_on_deck, cards_on_hand))


c = set(input())
s = set(input())
if len(c & s) > 0:
	print('YES')
else:
	print('NO')


s = input()
arr = list(input().split())
done = False
for i in range(len(arr)):
	if arr[i][0] == s[0] or arr[i][1] == s[1]:
		done = True
		break
print('YES' if done else 'NO')


def is_possible(card, cards):
	for c in cards:
		if c[0] == card[0] or c[1] == card[1]:
			return 'YES'
	return 'NO'
given_card = input()
print(is_possible(given_card, input().split()))


(r, c, s) = (False, input(), input())
if c[0] in s or c[1] in s:
	r = True
if r:
	print('YES')
else:
	print('NO')


c = input()
x = input().split()
for i in c:
	for j in x:
		if i in j:
			print('YES')
			import sys
			sys.exit(0)
print('NO')


st = str(input())
(a, b, c, d, e) = map(str, input().split())
(st1, st2, a1, a2, b1, b2, c1, c2, d1, d2, e1, e2, zy, ans) = (st[0], st[1], a[0], a[1], b[0], b[1], c[0], c[1], d[0], d[1], e[0], e[1], 0, 0)
sp1 = [a1, b1, c1, d1, e1]
sp2 = [a2, b2, c2, d2, e2]
for i in sp1:
	if st1 == i:
		ans = 'YES'
		break
if ans == 0:
	for i in sp2:
		if st2 == i:
			ans = 'YES'
			break
if ans == 0:
	print('NO')
elif ans != 0:
	print(ans)


stol = input()
a = [i for i in input().split()]
index = [a[i][0] for i in range(len(a))]
mast = [a[i][1] for i in range(len(a))]
if stol[0] in index or stol[1] in mast:
	print('YES')
else:
	print('NO')


c = input()
a = list(input().split())
flag = False
for i in a:
	if c[0] in i or c[1] in i:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


a = input()
(b, c, d, e, f) = map(str, input().split())
a1 = a[0]
a2 = a[1]
b += c + d + e + f
if a1 in b or a2 in b:
	print('YES')
else:
	print('NO')


c = input()
p = input()
if c[0] in p or c[1] in p:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
(rank, s) = (table[0], table[1])
for each in hand:
	if rank in each or s in each:
		print('YES')
		break
else:
	print('NO')


s1 = input()
ls = input().split()
print('YES' if any((any((s1[i] == ls[j][i] for i in range(2))) for j in range(5))) else 'NO')


s = str(input())
a = input()
r = s[0]
su = s[1]
if r in a or su in a:
	print('YES')
else:
	print('NO')


hand = input().strip()
table = input().strip().split(' ')
ranks = [x[0] for x in table]
masts = [x[1] for x in table]
if hand[0] in ranks or hand[1] in masts:
	print('YES')
else:
	print('NO')


s = input()
k = 0
s1 = list(input().split(' '))
for i in s1:
	if i[0] == s[0]:
		k = 1
		break
	elif i[1] == s[1]:
		k = 1
		break
if k == 1:
	print('YES')
else:
	print('NO')


on_table = input()
cards = input()
first = cards.find(on_table[0])
second = cards.find(on_table[1])
if first >= 0 or second >= 0:
	print('YES')
else:
	print('NO')


a = input()
n = list(input().split())
c = 0
for i in n:
	if a == i or a[0] == i[0] or a[-1] == i[-1]:
		c = 1
		break
print('YES' if c == 1 else 'NO')


a = input()
l = input().split()
yes = 0
for i in l:
	if i[0] == a[0] or i[1] == a[1]:
		yes = 1
		break
if yes:
	print('YES')
else:
	print('NO')


a = input()
b = 'NO'
for e in input().split():
	if a[0] == e[0] or a[1] == e[1]:
		b = 'YES'
print(b)


card = input()
hand = input().split(' ')
rankOnCard = card[0]
suitOnCard = card[1]
ranksInHand = [x[0] for x in hand]
suitsInHand = [x[1] for x in hand]
print('YES' if rankOnCard in ranksInHand or suitOnCard in suitsInHand else 'NO')


h = input()
c = [x for x in input().split()]
check = 0
for i in range(5):
	if h[0] == c[i][0] or h[1] == c[i][1]:
		check += 1
if check > 0:
	print('YES')
else:
	print('NO')


def first():
	a = input()
	b = input().split()
	for i in b:
		if i[1] == a[1] or i[0] == a[0]:
			return 'YES'
	return 'NO'
print(first())


first = input()
arr = map(list, input().split())
check = 0
for i in arr:
	if i[0] == first[0]:
		check = 1
	if i[1] == first[1]:
		check = 1
if check:
	print('YES')
else:
	print('NO')


import sys
fline = input()
sline = input()
(rank, suit) = (fline[0], fline[1])
for cand in sline.split(' '):
	if cand[0] == rank or cand[1] == suit:
		print('YES')
		sys.exit()
print('NO')


x = input()
y = list(input().split())
switch = 0
for i in range(5):
	if x[0] == y[i][0]:
		print('YES')
		switch = 1
		break
	elif x[1] == y[i][1]:
		print('YES')
		switch = 1
		break
	else:
		continue
if switch == 0:
	print('NO')
else:
	pass


a = input()
b = input().split()
for i in range(5):
	if a[0] == b[i][0]:
		print('YES')
		exit()
for i in range(5):
	if a[1] == b[i][1]:
		print('YES')
		exit()
print('NO')


a = str(input())
s = [str(i) for i in input().split()]
p = a[0]
k = 0
for i in range(5):
	if s[i][0] == p:
		print('YES')
		k = 1
		break
if k == 0:
	q = a[1]
	for i in range(5):
		if s[i][1] == q:
			print('YES')
			k = 1
			break
if k == 0:
	print('NO')


q = input()
h = input().split()
h = [i for x in h for i in x]
if q[0] in h or q[1] in h:
	print('YES')
else:
	print('NO')


while True:
	try:
		now = input()
		nex = map(str, input().split())
		flag = 1
		for i in nex:
			if i[0] == now[0] or i[1] == now[1]:
				print('YES')
				flag = 0
				break
		if flag:
			print('NO')
	except:
		break


(rank, suit) = list(input())
hand = input().split()
rank_list = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
can_play = False
for card in hand:
	if rank in card:
		can_play = True
		break
	elif suit in card:
		can_play = True
		break
print('YES') if can_play else print('NO')


def solve(n, l):
	for i in l:
		if i[1] == n[1] or i[0] == n[0]:
			print('YES')
			return
	print('NO')

def main():
	n = input()
	solve(n, input().split(' '))
main()


card = input()
hand = list(input().split())
for x in hand:
	for y in x:
		if y in card:
			print('YES')
			exit()
print('NO')


start_card = input()
cards_hand = list(input().split())
available_card = 'NO'
for card in cards_hand:
	if card[0] == start_card[0]:
		available_card = 'YES'
	elif card[1] == start_card[1]:
		available_card = 'YES'
print(available_card)


card = input()
my = input().split()
ans = 'NO'
for i in range(5):
	if card[0] == my[i][0] or card[1] == my[i][1]:
		ans = 'YES'
print(ans)


n = input()
m = input().split(' ')
true = False
for i in m:
	if n[0] == i[0] or n[1] == i[1]:
		true = True
if true:
	print('YES')
else:
	print('NO')


s = set()
c = input()
l = list(input())
for i in range(len(l)):
	s.add(l[i])
for i in c:
	if i in s:
		print('YES')
		break
else:
	print('NO')


cot = input()
crd = input()
print('YES' if cot[0] in crd or cot[1] in crd else 'NO')


a = input()
b = list(map(str, input().split()))
flag = False
for x in b:
	if x[0] == a[0] or x[1] == a[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


def main():
	t = input().strip()
	hs = input().strip().split()
	for h in hs:
		if t[0] == h[0] or t[1] == h[1]:
			return True
	return False
print(['NO', 'YES'][main()])


t = input()
h = list(map(str, input().split()))
count = 0
for i in range(len(h)):
	if h[i][0] == t[0] or h[i][1] == t[1]:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


ch = input()
l = [e for e in input().split()]
i = 0
s = False
while i < len(l):
	if ch[0] == l[i][0] or ch[1] == l[i][1]:
		s = True
		break
	else:
		i += 1
if s == True:
	print('YES')
else:
	print('NO')


ka = str(input())
(k1, k2, k3, k4, k5) = map(str, input().split())
k = ka[0]
a = ka[1]
if k in k1[0] or a in k1[1]:
	print('YES')
elif k in k2[0] or a in k2[1]:
	print('YES')
elif k in k3[0] or a in k3[1]:
	print('YES')
elif k in k4[0] or a in k4[1]:
	print('YES')
elif k in k5[0] or a in k5[1]:
	print('YES')
else:
	print('NO')


s = str(input())
k = str(input())
if k.find(s[1]) != -1 or k.find(s[0]) != -1:
	print('YES')
else:
	print('NO')


a = input()
b = list(map(str, input().split()))
j = 0
for i in range(len(b)):
	if a[0] in b[i] or a[1] in b[i]:
		j += 1
	else:
		continue
if j > 0:
	print('YES')
else:
	print('NO')


c = input()
cards = list(map(str, input().split()))
ans = 'NO'
for card in cards:
	if c[0] == card[0] or c[1] == card[1]:
		ans = 'YES'
print(ans)


def card_game():
	table = list(input())
	hand = input()
	hand = hand.split()
	x = 0
	kokotina = []
	for items in hand:
		for kokot in items:
			kokotina.append(kokot)
	for item in kokotina:
		if item == table[0] or item == table[1]:
			return 'YES'
	return 'NO'
print(card_game())


def cardGame():
	tableCard = input()
	cards = input().split()
	for i in cards:
		if tableCard[0] == i[0]:
			return 'YES'
		elif tableCard[1] == i[1]:
			return 'YES'
	return 'NO'
print(cardGame())


table = input()
hand = input().split(' ')
c = 1
for i in range(len(hand)):
	if hand[i][0] == table[0] or hand[i][1] == table[1]:
		c = 0
if c == 1:
	print('NO')
else:
	print('YES')


s = input()
a = list(input().split())
f = int(0)
for i in a:
	if s[0] == i[0] or s[1] == i[1]:
		f = 1
if f:
	print('YES')
else:
	print('NO')


s = list(input())
t = list(input())
if s[0] in t or s[1] in t:
	print('YES')
else:
	print('NO')


s = input()
cards = list(map(str, input().split()))
for i in range(len(cards)):
	if cards[i][0] == s[0] or cards[i][1] == s[1]:
		print('YES')
		exit()
print('NO')


while 1:
	try:
		x = input()
		p = str([str(e) for e in input().split()])
	except:
		break
	if p.count(x[0]) > 0:
		print('YES')
	elif p.count(x[1]) > 0:
		print('YES')
	else:
		print('NO')


import sys
t = sys.stdin.readline()
h = sys.stdin.readline().split(' ')
state = 0
for i in range(0, 5):
	for j in range(0, 2):
		if t[j] == h[i][j]:
			if state == 0:
				print('YES')
				state = 1
if state == 0:
	print('NO')


s = input()
a = list(input().split())
k = 0
for i in range(5):
	if a[i][0] == s[0] or a[i][1] == s[1]:
		k = 1
		print('YES')
		break
if k == 0:
	print('NO')


s1 = input()
s2 = input()
if s1[0] in s2:
	print('YES')
elif s1[1] in s2:
	print('YES')
else:
	print('NO')


table = input().strip()
card = input().strip().split()
found = False
for a in card:
	if a[0] == table[0] or a[1] == table[1]:
		print('YES')
		found = True
		break
if not found:
	print('NO')


t = input()
(a, b, c, d, e) = input().split()
flag = False
if a[0] == t[0] or a[1] == t[1]:
	flag = True
if b[0] == t[0] or b[1] == t[1]:
	flag = True
if c[0] == t[0] or c[1] == t[1]:
	flag = True
if d[0] == t[0] or d[1] == t[1]:
	flag = True
if e[0] == t[0] or e[1] == t[1]:
	flag = True
if flag:
	print('YES')
else:
	print('NO')


l = input()
s = list(map(str, input().split()))
count = 0
for i in s:
	if i[0] == l[0]:
		count = 1
		break
	elif i[1] == l[1]:
		count = 1
		break
if count == 1:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
for i in range(len(hand)):
	if hand[i][0:1] == table[0:1]:
		print('YES')
		break
	if hand[i][1:2] == table[1:2]:
		print('YES')
		break
	if i == len(hand) - 1:
		print('NO')


def solve():
	card_on_the_table = input()
	cards_on_the_hand = [k for k in input().split()]
	found = False
	for card in cards_on_the_hand:
		if card[0] == card_on_the_table[0] or card[1] == card_on_the_table[1]:
			found = True
			break
	print('YES' if found else 'NO')
solve()


def f(s, t):
	if s[0] == t[0]:
		return True
	elif s[1] == t[1]:
		return True
	else:
		return False
a = input()
b = input().split()
for i in range(5):
	if f(a, b[i]):
		print('YES')
		exit()
print('NO')


c = input()
cards = list(map(str, input().split()))
r = False
for card in cards:
	if card[0] == c[0] or card[1] == c[1]:
		r = True
		break
print('YNEOS'[not r::2])


b = ['D', 'C', 'S', 'H']
k = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
n = input()
a = list(map(str, input().split()))
for i in range(len(a)):
	if a[i][0] == n[0] or a[i][1] == n[1]:
		print('YES')
		exit()
print('NO')


c = input()
mc = input().split()
for i in mc:
	if i[0] == c[0] or i[1] == c[1]:
		print('YES')
		break
else:
	print('NO')


a = input()
sa = input()
if a[0] in sa or a[1] in sa:
	print('YES')
else:
	print('NO')


from sys import exit
d = input()
e = input()
e.replace(' ', '')
for i in d:
	for j in e:
		if i == j:
			print('YES')
			exit()
print('NO')


strr = input()
cards = input()
if strr[0] in cards or strr[1] in cards:
	print('YES')
else:
	print('NO')


card = input()
five = list(input().split())
for i in five:
	if i[0] == card[0] or i[1] == card[1]:
		print('YES')
		exit()
print('NO')


s = input()
l = list(map(str, input().split()))
flag = 0
for i in range(len(l)):
	if l[i][0] == s[0] or l[i][0] == s[1] or l[i][1] == s[0] or (l[i][1] == s[1]):
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


a = input()
b = list(map(str, input().split()))
c = 'NO'
for i in range(len(b)):
	if a[0] == b[i][0] or a[1] == b[i][1]:
		print('YES')
		exit(0)
print('NO')


a = input()
b = input().split()
A = set([b[0][0], b[1][0], b[2][0], b[3][0], b[4][0]])
B = set([b[0][1], b[1][1], b[2][1], b[3][1], b[4][1]])
if a[0] in A or a[1] in B:
	print('YES')
else:
	print('NO')


a = input('')
x = a[0]
y = a[1]
l = list(map(str, input().split(' ')))
for i in l:
	if i[0] == x or i[1] == y:
		print('YES')
		break
else:
	print('NO')


i1 = input()
i2 = input().split()
d = []
for i in range(5):
	if i2[i][0] == i1[0] or i2[i][1] == i1[1]:
		d.append(1)
if len(d) > 0:
	print('YES')
else:
	print('NO')


c = input()
cs = input()
s = [x for x in c if x in cs]
if s == []:
	print('NO')
else:
	print('YES')


def card(string1, values):
	for i in range(len(values)):
		if values[i][0] == string1[0] or values[i][1] == string1[1]:
			return 'YES'
	else:
		return 'NO'
string1 = input()
values = list(map(str, input().split()))
print(card(string1, values))


a = input()
k11 = a[:1]
k22 = a[1:]
k = 0
b = input().split()
z = []
for i in range(len(b)):
	z = b[i]
	k1 = z[:1]
	k2 = z[1:]
	if k1 >= k11 and k2 == k22 or k2 == k22 or k1 == k11:
		k += 1
if k != 0:
	print('YES')
else:
	print('NO')


x = input()
y = input().split()
cnt = 0
for a in y:
	if a[0] == x[0] or a[1] == x[1]:
		cnt += 1
		break
if cnt == 0:
	print('NO')
else:
	print('YES')


c = input()
a = input().split()
res = 0
for x in a:
	res |= c[0] == x[0] or c[1] == x[1]
print('YNEOS'[not res::2])


(a, b) = input()
c = input()
print(('NO', 'YES')[a in c or b in c])


card_on_table = input()
hand = input()
result = 'NO'
if card_on_table[0] in hand or card_on_table[1] in hand:
	result = 'YES'
print(result)


t = input()
(a, b, c, d, e) = input().split()

def chec(c):
	if t[0] == c[0] or t[1] == c[1]:
		return 1
	else:
		return 0
if chec(a):
	print('YES')
elif chec(b):
	print('YES')
elif chec(c):
	print('YES')
elif chec(d):
	print('YES')
elif chec(e):
	print('YES')
else:
	print('NO')


a = input()
h = ''.join(input().split())
if a[0] in h or a[1] in h:
	print('YES')
else:
	print('NO')


def solve(t, h):
	t_rank = t[0]
	t_suit = t[1]
	for c in h:
		rank = c[0]
		suit = c[1]
		if rank == t_rank or suit == t_suit:
			return 'YES'
	return 'NO'
t = input()
h = map(str, input().split())
print(solve(t, h))


hand_card = input()
table_cards = input().split()
for card in table_cards:
	if card[0] == hand_card[0] or card[1] == hand_card[1]:
		print('YES')
		break
else:
	print('NO')


stol = input()
ruka = input()
if stol[0] in ruka or stol[1] in ruka:
	print('YES')
else:
	print('NO')


table_card = input()
hand_cards = input()
if table_card[0] in hand_cards or table_card[1] in hand_cards:
	print('YES')
else:
	print('NO')


on_table = str(input())
(c1, c2, c3, c4, c5) = map(str, input().split())
if on_table[0] == c1[0] or on_table[0] == c2[0] or on_table[0] == c3[0] or (on_table[0] == c4[0]) or (on_table[0] == c5[0]):
	print('YES')
elif on_table[1] == c1[1] or on_table[1] == c2[1] or on_table[1] == c3[1] or (on_table[1] == c4[1]) or (on_table[1] == c5[1]):
	print('YES')
else:
	print('NO')


s = set(input())
a = set(input())
print('YES' if s & a else 'NO')


def solve(card, myHand):
	for c in myHand:
		if c[0] == card[0] or c[1] == card[1]:
			return True
	return False
card = input()
myHand = input().split()
print('YNEOS'[not solve(card, myHand)::2])


t = input()
t = list(t)
k = 0
x = list(map(str, input().split()))
for i in range(0, len(x)):
	if t[1] == x[i][1] or t[0] == x[i][0]:
		k = -1
		print('YES')
		break
if k == 0:
	print('NO')


tc = str(input())
hc = str(input())
tcl = list(tc)
hcl = list(hc)
tcl0 = tcl[0]
tcl1 = tcl[1]
m0 = []
for i in range(len(hcl)):
	c0 = hcl[i]
	if c0 == tcl0 or c0 == tcl1:
		m0.append('YES')
	else:
		m0.append('NO')
c1 = 0
for j in range(len(m0)):
	c2 = m0[j]
	if c2 == 'YES':
		c1 += 1
if c1 >= 1:
	print('YES')
else:
	print('NO')


t = input()
l = [str(x) for x in input().split()]
p = 0
for i in range(5):
	if t[0] == l[i][0] or t[1] == l[i][1]:
		print('YES')
		p = 1
		break
if p == 0:
	print('NO')


s = input()
a = input().split()
ans = 'NO'
for x in a:
	if s[1] == x[1] or s[0] == x[0]:
		ans = 'YES'
		break
print(ans)


def canPlay(card, cardList):
	for i in card:
		if any([i in cardl for cardl in cardList]):
			return 'YES'
	return 'NO'
card = input()
cardList = list(input().split(' '))
print(canPlay(card, cardList))


(m, n) = input()
o = input()
if m in o or n in o:
	print('YES')
else:
	print('NO')


a = input()
X = input().split()
for x in X:
	if x[0] == a[0] or x[1] == a[1]:
		print('YES')
		break
else:
	print('NO')


field = input()
hand = input().split()
for card in hand:
	if card[0] == field[0] or card[1] == field[1]:
		print('YES')
		break
else:
	print('NO')


(n, m) = input()
a = list(input().split())
q = False
for i in a:
	if n == i[0]:
		q = True
	if m == i[1]:
		q = True
print('YES' if q else 'NO')


given_card = input()
cards_at_hand = list(input().split(' '))
out = 'NO'
for i in cards_at_hand:
	if given_card[0] == i[0] or given_card[1] == i[1]:
		out = 'YES'
		break
print(out)


table = input()
hand = input().split(' ')
x = []
y = []
for i in range(len(hand)):
	y.append(hand[i][1])
	x.append(hand[i][0])
if table[0] in x:
	print('YES')
elif table[1] in y:
	print('YES')
if table[1] not in y and table[0] not in x:
	print('NO')


table_card = str(input())
your_cards = str(input())
your_cards = your_cards.split(' ')
can_play = 'NO'
for current_card in your_cards:
	if current_card[0] == table_card[0] or current_card[1] == table_card[1]:
		can_play = 'YES'
print(can_play)


x = input()
x1 = x[0]
x2 = x[1]
cnt = 0
a = map(str, input().split())
for i in a:
	z1 = i[0]
	z2 = i[1]
	if x1 == z1 or x2 == z1 or x1 == z2 or (x2 == z2):
		cnt = 1
		break
print('YES' if cnt == 1 else 'NO')


n = input()
p = list(map(str, input().split()))
kam = ''.join(p)
if n[0] in kam or n[1] in kam:
	print('YES')
else:
	print('NO')


c1 = input()
clist = list(map(str, input().strip().split()))
flag = False
for i in range(len(clist)):
	if clist[i][0].lower() == c1[0].lower():
		flag = True
		break
	if clist[i][1].lower() == c1[1].lower():
		flag = True
		break
if flag == True:
	print('YES')
else:
	print('NO')


a = input()
l = list(map(str, input().split()))
count = 0
for i in l:
	if i[0] == a[0] or i[1] == a[1]:
		count += 1
	else:
		pass
if count > 0:
	print('YES')
else:
	print('NO')


s = input()
l = []
st = input()
c = 0
l = st.split(' ')
for i in l:
	if i[0] == s[0]:
		c = 1
		print('YES')
		break
	elif i[1] == s[1]:
		c = 1
		print('YES')
		break
if c == 0:
	print('NO')


t = input()
j = list(map(str, input().split()))
flag = 0
for i in range(5):
	if t[0] == j[i][0] or t[1] == j[i][1]:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
f = False
for i in a:
	if i[1] == s[1] or i[0] == s[0]:
		print('YES')
		quit()
print('NO')


s = input()
l = input().split()
l = ''.join(l)
c = 0
if s[0] in l:
	c = 1
if s[1] in l:
	c = 1
if c == 1:
	print('YES')
else:
	print('NO')


def func(n):
	h = list(map(str, input().split()))
	num = n[0]
	sign = n[1]
	for i in h:
		if num in i or sign in i:
			print('YES')
			return
	print('NO')
n = input()
func(n)


table = input()
cards = input().split()
for card in cards:
	if table[0] == card[0] or table[1] == card[1]:
		print('YES')
		exit(0)
print('NO')


master = input()
cards = input().split()
flag = 0
for card in cards:
	for ch in card:
		if ch in master:
			print('YES')
			flag = 1
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


c = input()
cs = input()
css = cs.split()
op = 'NO'
for i in css:
	if c[0] == i[0] or c[1] == i[1]:
		op = 'YES'
		break
print(op)


from math import sqrt, gcd

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())
s = si()
f = 0
s1 = [x for x in input().split()]
for i in range(5):
	if s[0] == s1[i][0] or s[1] == s1[i][1]:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split(' ')
res = 'NO'
for i in range(len(hand)):
	if hand[i][0] == table[0] or hand[i][1] == table[1]:
		res = 'YES'
print(res)


s = input()
c = 0
a = list(input().split())
for x in a:
	if (s[0] == x[0] or s[1] == x[1]) and c < 1:
		c += 1
if c > 0:
	print('YES')
else:
	print('NO')


import sys

class Game:

	def playCard(self, hands, card):
		for h in hands:
			if h[0] == card[0] or h[1] == card[1]:
				return True
		return False

def main():
	card = sys.stdin.readline()
	hands = sys.stdin.readline().split()
	t = Game()
	print('YES') if t.playCard(hands, card) else print('NO')
main()


card_on_table = list(input())
cards_in_hand = list(map(list, input().split(' ')))
for i in range(0, 5):
	if cards_in_hand[i][0] == card_on_table[0] or cards_in_hand[i][1] == card_on_table[1]:
		print('YES')
		exit(0)
print('NO')


s = input()
t = input().split()
ok = False
for ch in t:
	if ch[0] == s[0] or ch[1] == s[1]:
		ok = True
if ok == False:
	print('NO')
else:
	print('YES')


s = input()
x = []
y = []
for i in s:
	x.append(i)
y = [k for k in input().split(' ')]
j = 0
while j < 5:
	if x[0] in y[j] or x[1] in y[j]:
		print('YES')
		break
	j = j + 1
if j == 5:
	print('NO')


s = str(input())
t = str(input())
for i in range(len(s)):
	if s[i] in t:
		print('YES')
		exit()
print('NO')


def main():
	card = input()
	mycards = [x for x in input().split()]
	for c in mycards:
		if card[0] == c[0] or card[1] == c[1]:
			print('YES')
			return
	print('NO')
main()


x = input()
mano = list(map(str, input().replace(' ', '')))
sw = 0
for i in x:
	if mano.count(i) != 0:
		sw = 1
		break
if sw == 1:
	print('YES')
else:
	print('NO')


karta = input()
k = 0
x = list(input().split())
for i in x:
	if i[0] == karta[0] or i[1] == karta[1]:
		k = 1
if k == 1:
	print('YES')
else:
	print('NO')


g = [i for i in input().strip()]
h = [i for i in input().split(' ')]
for i in h:
	if g[0] in i:
		print('YES')
		exit()
	elif g[1] in i:
		print('YES')
		exit()
print('NO')


import sys
import math
input = sys.stdin.readline
t = input().strip()
h = input().strip().split(' ')
for hi in h:
	if hi[0] == t[0] or hi[1] == t[1]:
		print('YES')
		break
else:
	print('NO')


first = input()
your_cards = list(map(str, input().split()))
a = 0
for i in your_cards:
	if i[0] == first[0]:
		a += 1
	elif i[1] == first[1]:
		a += 1
if a == 0:
	print('NO')
else:
	print('YES')


s = input()
a = [s[:1], s[-1:]]
s = input().split()
hand = []
for i in range(len(s)):
	hand.append(set({s[i][:-1], s[i][-1:]}))
flag = False
for i in range(len(hand)):
	if a[0] in hand[i] or a[1] in hand[i]:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


(card, arr) = (input(), input())
if card[0] in arr or card[1] in arr:
	print('YES')
else:
	print('NO')


n = []
while True:
	try:
		line = input()
	except EOFError:
		break
	n.append(line)
tb = n.pop(0)
tbnumber = tb[0]
tbsuit = tb[1]
hand = n[0]
handnumber = []
handsuit = []
k = 0
for x in range(5):
	handnumber.append(hand[x * 3])
	handsuit.append(hand[x * 3 + 1])
for x in handnumber:
	if x == tbnumber:
		print('YES')
		k = 1
		break
for x in handsuit:
	if x == tbsuit and k == 0:
		print('YES')
		k = 1
		break
if k == 0:
	print('NO')


s = input()
arr = list(input().split(' '))
count = 0
for i in arr:
	if s[0] == i[0] or s[1] == i[1]:
		count += 1
print('YES' if count >= 1 else 'NO')


(r, s) = [c for c in input()]
hand = input().split(' ')
for card in hand:
	if card[0] == r or card[1] == s:
		print('YES')
		exit(0)
print('NO')


tableCard = input()
handCards = input().split()
canPlay = False
for i in handCards:
	if i[0] == tableCard[0] or i[1] == tableCard[1]:
		canPlay = True
if canPlay:
	print('YES')
else:
	print('NO')


s = input()
a = [e for e in input().split()]
r = False
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		r = True
print('YES' if r else 'NO')


def isCheck(cards, check1, check2):
	if check1 in cards or check2 in cards:
		return True
	return False
text1 = input()
text = input()
check1 = text1[0]
check2 = text1[1]
cards = list()
for letter in text:
	if letter != ' ':
		cards.append(letter)
if isCheck(cards, check1, check2):
	print('YES')
else:
	print('NO')


a = input()
b = input()
blist = list(b.split())
alist = list(a[:])
blist1 = []
res = 0
for i in blist:
	m = list(i[:])
	for j in m:
		blist1.append(j)
for k in alist:
	if k in blist1:
		res += 1
if res == 0:
	print('NO')
else:
	print('YES')


n = input()
n = list(n)
s = input().split()
c = []
k = 0
for i in range(0, len(s)):
	c = list(s[i])
	for j in range(0, len(c)):
		if n[j] == c[j]:
			k += 1
		else:
			k += 0
	c = []
if k == 0:
	print('NO')
else:
	print('YES')


card = input()
five_cards = list(input().split())
yes = 0
no = 0
for i in range(5):
	if card[0] == five_cards[i][0] or card[1] == five_cards[i][1]:
		yes += 1
	else:
		no += 1
if no == 5:
	print('NO')
else:
	print('YES')


s = list(input())
a = list(input().split()[:5])
b = []
z = []
for i in range(5):
	b.append(a[i][1])
	k = a[i][0]
	z.append(k)
if s[0] in z or s[1] in b:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
ans = 'NO'
for i in range(0, 5):
	if table[0] == hand[i][0] or table[1] == hand[i][1]:
		ans = 'YES'
print(ans)


s = input().strip()
a = list(input().split())
fl = False
for s1 in a:
	if s1[0] == s[0] or s1[1] == s[1]:
		fl = True
if fl:
	print('YES')
else:
	print('NO')


s = input()
arr = input().split()
p = False
for i in arr:
	if i[0] in s or i[1] in s:
		p = True
if p:
	print('YES')
else:
	print('NO')


l1 = set(input())
l2 = set(input())
l3 = l2.intersection(l1)
print('YES') if len(l3) >= 1 else print('NO')


n = input()
n1 = input()
if n[0] in n1:
	print('YES')
	exit()
elif n[1] in n1:
	print('YES')
	exit()
print('NO')


suits = 'DCSH'
ranks = '23456789TJQKA'
need = input()
has = [x for x in input().split()]
ans = 'NO'
for x in has:
	if x[0] == need[0] or x[1] == need[1]:
		ans = 'YES'
		break
print(ans)


def rahul(word):
	return [char for char in word]
a = rahul(input())
b = input().split()
d = 0
r = 0
while r < 5:
	c = rahul(b[r])
	if str(c[0]) == str(a[0]) or c[1] == a[1]:
		d = d + 1
		break
	r = r + 1
if d > 0:
	print('YES')
else:
	print('NO')


s = input()
l = input().split()
flag = 0
for i in l:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


i = input()
k = input()
if k.find(i[0]) != -1 or k.find(i[1]) != -1:
	print('YES')
else:
	print('NO')


table = input()
ls = list(map(str, input().split()))
one = 0
two = 0
three = 0
for i in range(5):
	x = ls[i]
	if table[0] == x[0] and table[1] != x[1]:
		one += 1
	elif table[0] != x[0] and table[1] == x[1]:
		two += 1
	elif table[0] == x[0] and table[1] == x[1]:
		three += 1
if one > 0 or two > 0 or three > 0:
	print('YES')
else:
	print('NO')


(ts, tr) = [x for x in input()]
hands = input().split()
no = True
for h in hands:
	if h[0] == ts or h[1] == tr:
		print('YES')
		no = not no
		break
if no:
	print('NO')


x = str(input())
hands = str(input()).split()
c = 0
for i in range(5):
	if x[0] in hands[c]:
		print('YES')
		break
	elif x[1] in hands[c]:
		print('YES')
		break
	elif i == 4:
		print('NO')
	c = c + 1


s = input()
l = input().split()
for i in l:
	for z in i:
		if z in s:
			print('YES')
			exit()
print('NO')


b = []
a = []
b = input()
a = input()
c = 0
d = 0
e = 0
while c < 14:
	if a[c] == b[0]:
		d = d + 1
	c = c + 3
c = 1
while c < 14:
	if a[c] == b[1]:
		e = e + 1
	c = c + 3
if e + d != 0:
	print('YES')
else:
	print('NO')


s = input()
l = list(s)
p = 0
s1 = input()
l1 = list(s1)
m = l1.count(l[0])
n = l1.count(l[1])
if m >= 1 or n >= 1:
	p = 1
if p == 1:
	print('YES')
else:
	print('NO')


t = input()
l = ''
flag = 0
s = input().split()
for i in range(len(s)):
	l += s[i]
for i in range(len(l)):
	if t[0] in l or t[1] in l:
		flag = 1
if flag:
	print('YES')
else:
	print('NO')


def card_game_gndy(tbl, hnd):
	(c, s) = (tbl[0], tbl[1])
	for i in hnd:
		if i[0] == c or i[1] == s:
			return 'YES'
	return 'NO'
tbl = input().strip(' ')
hnd = list(input().strip(' ').split(' '))
print(card_game_gndy(tbl, hnd))


f = input()
s = input()
o = f[0]
t = f[1]
tr = False
for c in s:
	if c == o:
		tr = True
	if c == t:
		tr = True
if tr:
	print('YES')
else:
	print('NO')


a = list(input())
l = list(input())
if a[0] in l or a[1] in l:
	print('YES')
else:
	print('NO')


t = str(input())
(t1, t2) = (t[0], t[1])
hand = list(map(str, input().split()))
for i in hand:
	if t1 in i or t2 in i:
		print('YES')
		break
else:
	print('NO')


card = input()
print('YES' if any((my_card[0] == card[0] or my_card[1] == card[1] for my_card in input().split(' '))) else 'NO')


def cards(s, ip):
	a = s.split(' ')
	for i in a:
		if i[0] == ip[0] or i[1] == ip[1]:
			print('YES')
			return
		else:
			res = 'NO'
	if res == 'NO':
		print('NO')
		return
ip = input()
s = input()
cards(s, ip)


k = str(input())
r = str(input())
y = list(k)
b = 0
for i in range(2):
	if y[i] in r:
		b += 1
if b != 0:
	print('YES')
else:
	print('NO')


import math

def solve():
	a = list(input())
	b = list(input().split())
	for i in b:
		if a[0] == i[0] or a[1] == i[1]:
			print('YES')
			return
	print('NO')
	return
solve()


x = input()
s = input()
s = s.split(' ')
flag = 0
for i in range(5):
	if s[i][0] == x[0] or s[i][1] == x[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


ranks = []
suits = []
hand = list(input())
dealt_cards = input().split()
for card in dealt_cards:
	ranks.append(card[0])
	suits.append(card[1])
index = 0
found = False
while not found and index < len(ranks):
	if ranks[index] == hand[0] or suits[index] == hand[1]:
		found = True
	index += 1
if found:
	print('YES')
else:
	print('NO')


try:
	s = input()
	l = list(map(str, input().split()))
	q = []
	w = []
	for i in l:
		q.append(i[0])
		w.append(i[1])
	if s[0] in q or s[1] in w:
		print('YES')
	else:
		print('NO')
except:
	pass


import sys
n = input()
m = list(input().split())
for i in m:
	if i[0] == n[0]:
		print('YES')
		sys.exit(0)
	if i[1] == n[1]:
		print('YES')
		sys.exit(0)
print('NO')


a = input()
our = input().split()
a1 = a[0]
a2 = a[1]
c = 0
for i in range(5):
	if a1 in our[i] or a2 in our[i]:
		c = 1
		break
if c == 0:
	print('NO')
else:
	print('YES')


c = input()
h = input().split(' ')
answer = 'NO'
for char in c:
	for card in h:
		if char in card:
			answer = 'YES'
print(answer)


import math

def modi(a, m):
	return pow(a, m - 2, m)
s = str(input())
arr = [x for x in input().split()]
ans = 'NO'
for i in range(5):
	if arr[i][0] == s[0]:
		ans = 'YES'
	if arr[i][1] == s[1]:
		ans = 'YES'
print(ans)


s = input()
found = False
for i in list(input().split()):
	if s[0] == i[0] or s[1] == i[1]:
		found = True
		break
print('YES' if found else 'NO')


it = input()
ih = input().split()
cp = False
for i in range(5):
	if ih[i][0] == it[0] or ih[i][1] == it[1]:
		cp = True
		break
print('YES' if cp else 'NO')


(s1, s2) = input()
s = input()
if s1 in s or s2 in s:
	print('YES')
else:
	print('NO')


card = list(input())
MyCards = list(input())
if MyCards.count(card[0]) == 0 and MyCards.count(card[1]) == 0:
	print('NO')
else:
	print('YES')


def f():
	curr = input()
	you = list(input().split())
	for i in you:
		for j in range(2):
			if i[j] in curr:
				return 'YES'
	return 'NO'
print(f())


hand = input()
hand = [char for char in hand]
n = input().split(' ')
table = [[char for char in n[0]], [char for char in n[1]], [char for char in n[2]], [char for char in n[3]], [char for char in n[4]]]
output = 'NO'
for x in range(0, 5):
	if table[x][0] == hand[0] or table[x][1] == hand[1]:
		output = 'YES'
print(output)


card = input()
second = input().split()
for c in second:
	if card[0] == c[0] or card[1] == c[1]:
		print('YES')
		break
else:
	print('NO')


n = str(input())
arr = list(map(str, input().split()))
result = 'NO'
for i in range(len(arr)):
	if arr[i][0] == n[0] or arr[i][1] == n[1]:
		result = 'YES'
		break
print(result)


f = input()
a = input()
if a.find(f[0]) != -1 or a.find(f[1]) != -1:
	print('YES')
else:
	print('NO')


CT = str(input())
r = CT[0]
s = CT[1]
CH = list(map(str, input().split()))
rank = []
suit = []
for i in CH:
	rank.append(i[0])
	suit.append(i[1])
if r in rank or s in suit:
	print('YES')
else:
	print('NO')


a = input()
b = input()
c = False
if a[0] in b or a[1] in b:
	c = True
if c:
	print('YES')
else:
	print('NO')


rank = 0
suit = 1
g = list(input())
y = list(map(str, input().split()))
for i in range(5):
	if g[rank] == y[i][rank] or g[rank] == y[i][suit] or g[suit] == y[i][rank] or (g[suit] == y[i][suit]):
		print('YES')
		exit()
print('NO')


ref = input()
y = input()
z = y.split()
a = 0
for i in range(5):
	for j in range(2):
		if ref[j] in z[i]:
			a += 1
	if a != 0:
		print('YES')
		quit()
print('NO')


card = input()
rank = card[0]
suit = card[1]
cards = input().split(' ')
ranks = []
suits = []
for c in cards:
	ranks.append(c[0])
	suits.append(c[1])
if rank in ranks or suit in suits:
	print('YES')
else:
	print('NO')


c = input()
L = input().split()
Flag = False
for i in L:
	if c[0] in i or c[1] in i:
		Flag = True
		break
if Flag:
	print('YES')
else:
	print('NO')


f = input()
s = input().split()
for i in s:
	if i[0] == f[0] or i[1] == f[1]:
		print('YES')
		break
	if s.index(i) == len(s) - 1:
		print('NO')


t = input()
hand = list(input().split())
res = 'NO'
for i in hand:
	if t[0] == i[0] or t[1] == i[1]:
		res = 'YES'
print(res)


ih = input()
ot = input().split()
c = 0
for i in range(5):
	if ih[0] == ot[i][0] or ih[1] == ot[i][1]:
		c = 1
		break
	else:
		c = 0
if c > 0:
	print('YES')
else:
	print('NO')


f = input()
a = input()
k = 0
for i in range(2):
	if int(f[i] in a) == 1:
		k += 1
if k == 0:
	print('NO')
else:
	print('YES')


b = input()
d = input().split()
flag = 0
for i in b:
	for j in d:
		for k in j:
			if i == k:
				flag += 1
if flag != 0:
	print('YES')
else:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
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 [int(x) for x in sys.stdin.readline().split()]

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

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

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

def S():
	return input()

def main():
	s = S()
	l = LS()
	l1 = []
	l2 = []
	for x in l:
		l1.append(x[0])
		l2.append(x[1])
	if l1.count(s[0]) > 0 or l2.count(s[1]) > 0:
		return 'YES'
	return 'NO'
print(main())


n = input()
n_1 = n[0]
n_2 = n[1]
a = list(input().split())
flag = 0
for i in range(len(a)):
	if a[i][0] == n_1 or a[i][1] == n_2:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


table = list(input())
cards = input().split()

def ans(table, cards):
	for card in cards:
		card = list(card)
		if table[0] == card[0] or table[1] == card[1]:
			return 'YES'
	else:
		return 'NO'
print(ans(table, cards))


t = list(map(str, input().split()))
u = list(map(str, input().split()))
count = 0
for i in range(5):
	if t[0][0] == u[i][0]:
		count += 1
	if t[0][1] == u[i][1]:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


table = input()
hands = input()
num_list = [x for x in list(table)]
hand_list = [p for p in list(hands)]

def generator(n, k):
	for i in n:
		for x in k:
			yield (i, x)
for (a, b) in generator(num_list, hand_list):
	if a == b:
		print('YES')
		break
else:
	print('NO')


def f(s, l):
	for i in l:
		if s[0] in i:
			return 1
	for i in l:
		if s[1] in i:
			return 1
	return 0
s = input()
l = list(input().split())
if f(s, l) == 1:
	print('YES')
else:
	print('NO')


c = input()
h = input().split()
p = 'NO'
for a in h:
	for b in c:
		if b in a:
			p = 'YES'
print(p)


mcard = input()
fcard = input()
card = [str(i) for i in fcard.split(' ')]
p = 0
for i in range(len(card)):
	if mcard[0] == card[i][0]:
		print('YES')
		break
	elif mcard[1] == card[i][1]:
		print('YES')
		break
	else:
		p += 1
		if p == 5:
			print('NO')


s1 = input()
s2 = list(input().split(' '))
s2 = ''.join(s2)
if s1[0] in s2 or s1[1] in s2:
	print('YES')
else:
	print('NO')


s = input()
l = list(map(str, input().split()))
if (s[0] == l[0][0] or s[1] == l[0][1]) or (s[0] == l[1][0] or s[0] == l[1][1]) or (s[0] == l[2][0] or s[1] == l[2][1]) or (s[0] == l[3][0] or s[1] == l[3][1]) or (s[0] == l[4][0] or s[1] == l[4][1]):
	print('YES')
else:
	print('NO')


ss = input()
a = input().split()
b = set()
c = set()
for x in a:
	b.add(x[0])
	c.add(x[1])
if ss[0] in b or ss[1] in c:
	print('YES')
else:
	print('NO')


x = input()
deck = list(input().split())
get = False
for d in deck:
	if d[0] == x[0]:
		get = True
	if d[1] == x[1]:
		get = True
if get:
	print('YES')
else:
	print('NO')


onTable = input()
inHand = input().split()
equal = lambda a, b: a[0] == b[0] or a[1] == b[1]
for i in inHand:
	if equal(i, onTable):
		print('YES')
		break
else:
	print('NO')


n = input()
a = [x for x in input().split()]
flag = 0
for i in range(len(a)):
	if n[0] == a[i][0] or n[1] == a[i][1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


n = input()
s = input().split()
ans = 'NO'
for i in s:
	if i[0] == n[0] or i[1] == n[1]:
		ans = 'YES'
print(ans)


b = input()
a = input().split()
check = lambda i: any(map(lambda x: x[i] == b[i], a))
print('YES' if check(0) or check(1) else 'NO')


inp = input()
rank = inp[0]
suit = inp[1]
inp = input().split(' ')
lst = []
for i in range(5):
	item = inp[i]
	lst.append(item[0])
	lst.append(item[1])
if rank in lst or suit in lst:
	print('YES')
else:
	print('NO')


x = input()
q = []
(a1, a2, a3, a4, a5) = input().split(' ')
q.append(a1)
q.append(a2)
q.append(a3)
q.append(a4)
q.append(a5)
c = 'NO'
j = 0
while c == 'NO' and j < 5:
	if x[0] == q[j][0] or x[1] == q[j][1]:
		c = 'YES'
	j = j + 1
print(c)


a = list(input())
b = input().split()
b = ''.join(b)
set(b)
for i in range(0, len(b)):
	if b[i] == a[0] or b[i] == a[1]:
		print('YES')
		break
else:
	print('NO')


table_card = input()
hand_cards = [*map(str, input().split())]
n = False
for _ in hand_cards:
	if table_card[0] == _[0] or table_card[1] == _[1]:
		print('YES')
		n = True
		break
if not n:
	print('NO')


CartaEnMesa = input()
CartaEnMano = input()
print('YES' if len(set(CartaEnMesa) & set(CartaEnMano)) > 0 else 'NO')


ch = input()
ct = input().split()
ct0 = ct[0]
ct1 = ct[1]
ct2 = ct[2]
ct3 = ct[3]
ct4 = ct[4]
x1 = ct0[0]
x2 = ct0[1]
y1 = ct1[0]
y2 = ct1[1]
z1 = ct2[0]
z2 = ct2[1]
u1 = ct3[0]
u2 = ct3[1]
k1 = ct4[0]
k2 = ct4[1]
if ch[0] == x1 or ch[0] == y1 or ch[0] == z1 or (ch[0] == u1) or (ch[0] == k1):
	print('YES')
elif ch[1] == x2 or ch[1] == y2 or ch[1] == z2 or (ch[1] == u2) or (ch[1] == k2):
	print('YES')
else:
	print('NO')


from typing import List

def process(board_card: str, cards: List[str]):
	for card in cards:
		if board_card[0] == card[0] or board_card[1] == card[1]:
			return 'YES'
	return 'NO'

def read_int_row(row):
	return map(int, row.split())

def parse(input_iter):
	return (next(input_iter), next(input_iter).split())

def get_std_input():
	while True:
		yield input()

def main():
	print(process(*parse(get_std_input())))
main()


t = input()
h = [x for x in input().split()]
t1 = list(t)
h1 = [list(x) for x in h]
f = 0
for l in h1:
	if t1[0] in l or t1[1] in l:
		f = 1
		print('YES')
		break
if f == 0:
	print('NO')


card = input()
num1 = input()
a = []

def get_the_data(count, num, arr):
	for i in range(0, len(num)):
		if num[i] == ' ':
			arr.append(num[count:i])
			count = i + 1
		elif i == len(num) - 1:
			arr.append(num[count:len(num)])
	return arr
arr1 = get_the_data(0, num1, a)
move = False
for i in arr1:
	if card[0] == i[0] or card[1] == i[1]:
		move = True
		break
if move is True:
	print('YES')
else:
	print('NO')


n = input()
g = input()
p = set()
p1 = set()
p.add(n[0])
w = set()
w1 = set()
w.add(n[1])
for i in range(5):
	p1.add(g[3 * i])
	w1.add(g[3 * i + 1])
if len(p & p1) != 0 or len(w & w1) != 0:
	print('YES')
else:
	print('NO')


f = input()
arr = input().split()
ans = 'NO'
for i in arr:
	if i[0] == f[0] or i[1] == f[1]:
		ans = 'YES'
print(ans)


(mast, rang) = tuple(input())
my_card = input().split(' ')
if any((mast in x or rang in x for x in my_card)):
	print('YES')
else:
	print('NO')


a = input()
r = 0
l = list(map(str, input().split()))
for i in l:
	if i[0] == a[0] or i[1] == a[1]:
		r = 1
		break
if r == 0:
	print('no'.upper())
else:
	print('yes'.upper())


import sys
a = input()
b = input().split()
for c in b:
	if a[0] == c[0] or a[1] == c[1]:
		print('YES')
		sys.exit()
print('NO')


mesa = input()
mano = input().split()
jugable = False
for carta in mano:
	for x in range(2):
		if mesa[x] == carta[x]:
			jugable = True
			break
	if jugable == True:
		break
if jugable == True:
	print('YES')
else:
	print('NO')


card_on_table = input()
cards_you_have = input().split()

def cards_play():
	for i in cards_you_have:
		if card_on_table[0] in i or card_on_table[1] in i:
			print('YES', end='')
			return
	else:
		print('NO')
cards_play()


s = input()
si = input()
a = False
for char in s:
	if char in si and (not a):
		print('YES')
		a = True
if not a:
	print('NO')


import sys
n = sys.stdin.readline()
k = sys.stdin.readline().split()

def gennady(n, k):
	(rank, suit) = ([], [])
	for card in k:
		rank.append(card[0])
		suit.append(card[1])
	if n[0] in rank or n[1] in suit:
		print('YES')
	else:
		print('NO')
gennady(n, k)


our_card = str(input())
other_cards = list(map(str, input().split()))
answer = 'NO'
for i in range(len(other_cards)):
	if our_card[0] == other_cards[i][0] or our_card[1] == other_cards[i][1]:
		answer = 'YES'
		break
print(answer)


card = input()
inhand = list(input().split())
card_suit = card[1]
card_rank = card[0]
playable = False
for i in inhand:
	if i[0] == card_rank or i[1] == card_suit:
		playable = True
		break
if playable:
	print('YES')
else:
	print('NO')


hand = []
hand.append(input())
flag = 0
table = list(map(str, input().split()))
for i in range(5):
	if hand[0][0] == table[i][0]:
		flag = 1
	if hand[0][1] == table[i][1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


t = input()
c = input().split()
verdict = 'NO'
for i in c:
	if i[0] == t[0] or t[1] == i[1]:
		verdict = 'YES'
		break
print(verdict)


carta = input()
cartas = [x for x in input().split()]
for c in cartas:
	if c[0] == carta[0] or c[1] == carta[1]:
		print('YES')
		break
else:
	print('NO')


s = input()
a = []
b = []
u = False
l = list(input().split())
for i in range(5):
	s1 = l[i]
	if s1[0] == s[0] or s1[1] == s[1]:
		u = True
if u:
	print('YES')
else:
	print('NO')


str1 = input()
lst1 = list(map(str, input().split()))
k = 0
for i in lst1:
	if str1[0] == i[0] or str1[1] == i[1]:
		print('YES')
		k = 1
		break
if k == 0:
	print('NO')


try:
	l = input()
	(a, b) = (l[0], l[1])
	l2 = map(str, input().split())
	for _ in l2:
		if _[0] == a or _[1] == b:
			print('YES')
			break
		else:
			continue
	else:
		print('NO')
except:
	pass


n = str(input())
c = [str(x) for x in input().split()]
for i in c:
	if n[0] == i[0] or n[1] == i[1]:
		print('YES')
		break
else:
	print('NO')


table = input()
hand = input().split(' ')
f = False
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		print('YES')
		f = True
		break
if not f:
	print('NO')


a = input()
l = list(map(str, input().split()))
for i in l:
	if i[0] == a[0] or i[1] == a[1]:
		print('YES')
		exit(0)
print('NO')


one = input()
arr = [x for x in input().split()]
a = one[0]
b = one[1]
flag = 0
for i in arr:
	c = i[0]
	d = i[1]
	if a == c or b == d:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


a = input()
ans = 'NO'
c = list(map(str, input().split()))
for i in range(len(c)):
	if a[1] == c[i][1]:
		ans = 'YES'
	elif a[0] == c[i][0]:
		ans = 'YES'
print(ans)


s1 = input()
s2 = input().split()
flag = 0
for i in s2:
	item = i
	if item[0] == s1[0] or item[1] == s1[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


card = list(input())
cards = list(map(str, input().split()))
flag = False
for i in range(len(cards)):
	if cards[i][0] in card or cards[i][1] in card:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


t = input().lower()
f = list(input().lower().split())
s = []
for i in range(5):
	if t[0] == f[i][0] or t[1] == f[i][1]:
		s.append(f[i])
	elif len(t) == 3 and t[2] == f[i][1]:
		s = [1]
	elif len(f[i]) == 3 and t[1] == f[i][2]:
		s = [1]
	elif len(t) == 3 and len(f[i]) == 3:
		s = [1]
if len(s) >= 1:
	print('YES')
else:
	print('NO')
quit()


table = input()
cards = input()
k = cards.count(table[1]) + cards.count(table[0])
print('YES') if k > 0 else print('NO')


hand = input()
table = list(input().split())
can_play = False
for i in hand:
	for j in table:
		for k in j:
			if k == i:
				can_play = True
				break
		if can_play:
			break
	if can_play:
		break
if can_play:
	print('YES')
else:
	print('NO')


table = input()
hands = input()
num_list = [x for x in list(table)]
hand_list = [p for p in list(hands)]
count = 0
for x in num_list:
	for v in hand_list:
		if x == v:
			count += 1
		else:
			pass
if count > 0:
	print('YES')
else:
	print('NO')


t = input()
l = input()
if t[0] in l or t[1] in l:
	print('YES')
else:
	print('NO')


import sys
import math

def read_int():
	return int(input().strip())

def read_int_list():
	return list(map(int, input().strip().split()))

def read_string():
	return input().strip()

def read_string_list(delim=' '):
	return input().strip().split(delim)
table_c = read_string()
cards = read_string_list()
for c in cards:
	if c[0] == table_c[0] or c[1] == table_c[1]:
		print('YES')
		return
print('NO')


s1 = input()
s2 = input().split()
c = 0
for i in s2:
	if i[1] == s1[1] or i[0] == s1[0]:
		c += 1
if c == 0:
	print('NO')
else:
	print('YES')


s = input()
n = list(input().split())
z = 0
for i in range(len(n)):
	if s[0] == n[i][0]:
		z += 1
		break
	if s[1] == n[i][1]:
		z += 1
		break
if z == 0:
	print('NO')
else:
	print('YES')


from sys import stdin
table = list(stdin.readline())
hand = stdin.readline().split()
card = set()
for element in hand:
	arr = list(element)
	card.add(arr[0])
	card.add(arr[1])
if table[0] in card or table[1] in card:
	print('YES')
else:
	print('NO')


table_card = input()
your_cards = list(input().split())
get_out = 0
for i in range(5):
	if get_out == 1:
		break
	for g in range(2):
		card = your_cards[i]
		if card[g] == table_card[g]:
			print('YES')
			get_out = 1
			break
if get_out == 0:
	print('NO')


on_table = input()
in_hand = input().rstrip().split()

def play(on_t, in_h):
	for i in in_hand:
		if i[0] == on_table[0] or i[1] == on_table[1]:
			return 'YES'
	return 'NO'
print(play(on_table, in_hand))


import sys
from collections import defaultdict, deque
from math import sqrt

def input():
	return sys.stdin.readline()[:-1]
(a, b) = [x for x in input()]
if any([a in x or b in x for x in input().split()]):
	print('YES')
else:
	print('NO')


s = set(input())
l = input().split()
ans = set()
for i in l:
	for j in i:
		ans.add(j)
for i in s:
	if i in ans:
		print('YES')
		exit()
print('NO')


a = input()
b = list(map(str, input().split()))
c = 0
for i in b:
	if a[1] == i[1]:
		c = 1
	elif a[0] == i[0]:
		c = 1
if c == 1:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
for card in hand:
	if card[0] == table[0]:
		print('YES')
		break
	elif card[1] == table[1]:
		print('YES')
		break
	if card == hand[-1]:
		print('NO')


x = input()
y = input().split()

def card(x, y):
	for i in y:
		if x[0] == i[0] or x[1] == i[1]:
			return 'YES'
	return 'NO'
print(card(x, y))


a = input()
(card1, card2, card3, card4, card5) = input().split()
if a[0] == card1[0] or a[0] == card2[0] or a[0] == card3[0] or (a[0] == card4[0]) or (a[0] == card5[0]):
	print('YES')
elif a[1] == card1[1] or a[1] == card2[1] or a[1] == card3[1] or (a[1] == card4[1]) or (a[1] == card5[1]):
	print('YES')
else:
	print('NO')


n = input()
h = input().split()
play = False
for c in h:
	if c[0] == n[0] or c[1] == n[1]:
		play = True
		break
print('YES') if play else print('NO')


a = list(input())
s = input().split()
f = 'NO'
for x in range(len(s)):
	if list(s[x])[0] == a[0]:
		f = 'YES'
	elif list(s[x])[1] == a[1]:
		f = 'YES'
print(f)


s1 = [str(i) for i in input()]
s2 = [str(i) for i in input() if i != ' ']
if s2.count(s1[0]) >= 1 or s2.count(s1[1]) >= 1:
	print('YES')
else:
	print('NO')


p = input()
l = input().split()
print(['NO', 'YES'][any((i[0] == p[0] or i[1] == p[1] for i in l))])


n = input()
k = input()
print('YES' if n[0] in k or n[1] in k else 'NO')


p = str(input())
ele = list(map(str, input().split()))
count = 0
for i in p:
	for j in ele:
		for k in j:
			if i == k:
				count += 1
if count >= 1:
	print('YES')
else:
	print('NO')


table_card = input()
hand_cards = input().split()
can_play: bool = False
for card in hand_cards:
	if card[0] == table_card[0] or card[1] == table_card[1]:
		can_play = True
if can_play:
	print('YES')
else:
	print('NO')


p = list(input())
l = list(input())
for j in l:
	if j == ' ':
		l.remove(j)
for j in range(0, len(l) - 1, 2):
	if p[0] == l[j] or p[1] == l[j + 1]:
		print('YES')
		exit()
print('NO')


def mi():
	return map(int, input().split(' '))
card = input()
a = card[0]
b = card[1]
li = list(map(str, input().split(' ')))
for i in li:
	if a == i[0]:
		print('YES')
		exit(0)
	elif b == i[1]:
		print('YES')
		exit(0)
print('NO')


def main():
	s = input()
	for t in input().split():
		if s[0] == t[0] or s[1] == t[1]:
			print('YES')
			return
	print('NO')
main()


def f():
	a = input()
	b = input()
	a1 = a[0]
	a2 = a[1]
	if a1 in b:
		print('YES')
		return
	elif a2 in b:
		print('YES')
		return
	else:
		print('NO')
f()


t = input()
h = input()
for c in h:
	if c in t:
		print('YES')
		exit()
print('NO')


tbl = input()
hand = input()
if tbl[1] in hand or tbl[0] in hand:
	print('YES')
else:
	print('NO')


card = input()
cards = list(map(str, input().strip().split()))
break1 = 0
for mycard in cards:
	if mycard[0] == card[0] or mycard[1] == card[1]:
		print('YES')
		break1 = 1
		break
if not break1:
	print('NO')


card = list(input().lower())
cards = input().lower()
for obj in card:
	if obj in cards:
		print('YES')
		break
else:
	print('NO')


s = input()
a = list(map(str, input().split(' ')))
ans = 'NO'
for c in a:
	if c[0] == s[0] or c[1] == s[1]:
		ans = 'YES'
		break
print(ans)


card = input()
(dignity, suit) = (set(), set())
for value in input().split():
	dignity.add(value[0])
	suit.add(value[1])
if card[0] in dignity or card[1] in suit:
	print('YES')
else:
	print('NO')


n = input()
hands = input().split(' ')
pl = False
for card in hands:
	if n[0] == card[0] or n[1] == card[1]:
		pl = True
		break
print('YES' if pl else 'NO', flush=True)


t = input()
a = input()
if t[0] in a or t[1] in a:
	print('YES')
else:
	print('NO')


prov = input()
mass = input().split()
check = True
for i in mass:
	if i[0] == prov[0] or i[1] == prov[1]:
		check = False
if check:
	print('NO')
else:
	print('YES')


def split(word):
	return [char for char in word]

def split2(list):
	return [char for char in list]
n = input()
y = split(n)
count = 0
x = list(map(str, input().split()))
for i in range(5):
	if y[0] in x[i] or y[1] in x[i]:
		count = count + 1
if count > 0:
	print('YES')
else:
	print('NO')


def ok(s1, s2):
	return s1[0] == s2[0] or s1[1] == s2[1]
card = input()
hand = input().split()
flag = False
for c in hand:
	if ok(card, c):
		flag = True
if flag:
	print('YES')
else:
	print('NO')


n = input()
a = n[0]
b = n[1]
c = input().strip().split()
z = 1
for i in c:
	for j in range(2):
		if j == 0 and a == i[0] and (i[1] != b) and z:
			print('YES')
			z = 0
			break
		if j == 1 and b == i[1] and (i[0] != a) and z:
			z = 0
			print('YES')
			break
if z:
	print('NO')


table_card = input()
hand_cards = list(input().split())
flag = 0
for c in hand_cards:
	if c[0] == table_card[0] or c[1] == table_card[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


table_card = input()
chances = [str(i) for i in input().split(' ')]
t = 1
for i in range(5):
	if table_card[0] == chances[i][0] or table_card[1] == chances[i][1]:
		t = 2
		break
if t == 2:
	print('YES')
else:
	print('NO')


n = input()
c = 0
l = list(map(str, input().split()))
for i in range(5):
	if str(n[0]) == str(l[i][0]):
		c = 1
		print('YES')
		break
	elif str(n[1]) == str(l[i][1]):
		c = 1
		print('YES')
		break
if c == 0:
	print('NO')


a = input()
b = list(map(str, input().split()))
fl = False
for i in range(len(b)):
	if b[i][0] == a[0] or b[i][1] == a[1]:
		fl = True
		print('YES')
		break
if not fl:
	print('NO')


ct = input()
ch = input().split()
if ct[0] in set((i[0] for i in ch)) or ct[1] in set((i[1] for i in ch)):
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
print('YES' if any([table[0] == card[0] or table[1] == card[1] for card in hand]) else 'NO')


a = input()
l = list(map(str, input().split()))
d = 0
for i in l:
	if i.find(a[0]) == -1 and i.find(a[1]) == -1:
		d = d + 1
print('YES' if d != len(l) else 'NO')


r = input()
p = r[0]
k = r[1]
l = input()
m = k in l
n = p in l
if m == True or n == True:
	print('YES')
else:
	print('NO')


s = input()
h = list(map(str, input().split()))
c = 0
for i in range(5):
	if s[0] in h[i]:
		c = c + 1
	if s[1] in h[i]:
		c = c + 1
if c > 0:
	print('YES')
else:
	print('NO')


t = input()
h = [i for i in input().split(' ')]
count = 0
for i in h:
	if i[0] == t[0] or i[1] == t[1]:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


def main():
	tableCard = input()
	handCards = input().split(' ')
	canPlay = False
	for card in handCards:
		if card[0] == tableCard[0] or card[1] == tableCard[1]:
			canPlay = True
			break
	if canPlay:
		print('YES')
	else:
		print('NO')
main()


card_table = input()
cards_hand = input().replace(' ', '')
if card_table[0] in cards_hand or card_table[1] in cards_hand:
	print('YES')
else:
	print('NO')


(a, b) = input()
x = input().split()

def yes_no(x):
	for card in x:
		(m, n) = card
		if (m == a) | (n == b):
			return 'YES'
	return 'NO'
print(yes_no(x))


n = input()
count = 0
p = [x for x in input().split()]
for i in p:
	if i[0] == n[0] or i[1] == n[1]:
		print('YES')
		break
	else:
		count += 1
if count == len(p):
	print('NO')


a = input()
b = input().split()
u = 0
for i in range(5):
	if a[0] in b[i]:
		u = 1
	else:
		pass
for i in range(5):
	if a[1] in b[i]:
		u = 1
	else:
		pass
if u == 0:
	print('NO')
else:
	print('YES')


import sys
from itertools import islice
fin = sys.stdin
fout = sys.stdout
lines = (line.strip() for line in fin)
(rank, suit) = next(lines)
hand = next(lines).split()
ranks = map(lambda card: card[0], hand)
suits = map(lambda card: card[1], hand)
print('YES' if rank in ranks or suit in suits else 'NO', file=fout)


q = input()
s = list(map(str, input().split()))
c = 0
for i in s:
	if i[0] == q[0]:
		c += 1
	elif i[1] == q[1]:
		c += 1
if c != 0:
	print('YES')
else:
	print('NO')


k = input()
ts = input().split()
passed = False
for t in ts:
	if k[0] == t[0] or k[1] == t[1]:
		print('YES')
		passed = True
		break
if not passed:
	print('NO')


def check(t, h):
	for i in t:
		for j in range(0, len(h)):
			for k in h[j]:
				if k == i:
					print('YES')
					return
	print('NO')
	return
t = input()
h = input().split()
check(t, h)


current_card = input()
hand_cards = input().split(' ')
flag = 0
for item in hand_cards:
	if item[0] == current_card[0] or item[1] == current_card[1]:
		flag = 1
	else:
		pass
if flag == 1:
	print('YES')
else:
	print('NO')


c = input()
cs = input().split()
for c1 in cs:
	if c1[0] == c[0] or c1[1] == c[1]:
		print('YES')
		exit()
print('NO')


def ans(s, t):
	for i in t:
		if i[0] == s[0] or i[1] == s[1]:
			return 'YES'
	return 'NO'
s = input()
t = input().strip().split()
print(ans(s, t))


card = input()
a = list(map(str, input().split()))
flag = False
for c in a:
	if c[0] == card[0]:
		flag = True
		break
	elif c[1] == card[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


t = input()
f = 0
l = input().split()
for i in range(5):
	if l[i][0] == t[0] or l[i][1] == t[1]:
		f = 1
print('YES' if f else 'NO')


card = input()
deck = input().split()
answer = 'NO'
for card_in_deck in deck:
	if card[0] == card_in_deck[0] or card[1] == card_in_deck[1]:
		answer = 'YES'
		break
print(answer)


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


table = input()
hand = [str(x) for x in input().split()]
res = 'NO'
for x in hand:
	if x[0] == table[0] or x[1] == table[1]:
		res = 'YES'
print(res)


A = input()
B = input().split()
for a in B:
	if a[0] == A[0] or a[1] == A[1]:
		print('YES')
		break
else:
	print('NO')


(a, b) = input()
t = 'NO'
c = input()
if c.find(a) != -1 or c.find(b) != -1:
	t = 'YES'
print(t)


tablecard = input()
handscards = input().split()
suits = [i[1] for i in handscards]
numbers = [i[0] for i in handscards]
if tablecard[0] in numbers or tablecard[1] in suits:
	print('YES')
else:
	print('NO')


karta = input()
l = list(input().split())
OP = 'NO'
for x in l:
	if karta[0] == x[0]:
		OP = 'YES'
		break
	elif karta[1] == x[1]:
		OP = 'YES'
		break
print(OP)


import sys
table = input()
hand = input().split(' ')
isPlayable = False
for card in hand:
	if isPlayable:
		break
	test1 = card[0]
	test2 = card[1]
	if test1 == table[0] or test2 == table[1]:
		isPlayable = True
if isPlayable:
	print('YES')
else:
	print('NO')


x = input()
l = list(map(str, input().split()))
for i in range(len(l)):
	if x[0] in l[i] or x[1] in l[i]:
		print('YES')
		break
else:
	print('NO')


n = input()
y = input().split(' ')
for i in range(0, 5):
	if n[0] == y[i][0]:
		print('YES')
		break
	if n[1] == y[i][1]:
		print('YES')
		break
if i == 4 and (n[0] != y[4][0] and n[1] != y[4][1]):
	print('NO')


h = input()
list = [x for x in input().split(' ')]
flag = 0
for item in list:
	if item[0] == h[0] or item[1] == h[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


table_card = list(input())
hand = list(input().split())
card_in_hand = []
for element in hand:
	for x in element:
		card_in_hand.append(x)
if table_card[0] in card_in_hand or table_card[1] in card_in_hand:
	print('YES')
else:
	print('NO')


def main():
	table = sys.stdin.readline()
	cards = sys.stdin.readline().split()
	for card in cards:
		if card[0] == table[0] or card[1] == table[1]:
			print('YES')
			return
	print('NO')
import sys
main()


l = []
x = input()
x = list(x)
y = input()
y = list(y)
for i in x:
	if i in y:
		print('YES')
		exit(0)
print('NO')


table = input()
strr = input()
lst = strr.split()
truth = 'NO'
for i in lst:
	if i[0] == table[0] or i[1] == table[1]:
		truth = 'YES'
print(truth)


x = set(list(input()))
y = set(list(input()))
if len(x.intersection(y)) != 0:
	print('YES')
else:
	print('NO')


card = input()
hand = input()
res = 'NO'
for c in card:
	if c in hand:
		res = 'YES'
		break
print(res)


on_table = input()
cards = input().split()
count = 0
for card in cards:
	if on_table[0] == card[0] or on_table[1] == card[1]:
		count += 1
if count >= 1:
	print('YES')
else:
	print('NO')


def play(card, cards):
	for c in cards:
		if c[0] == card[0] or c[1] == card[1]:
			return 'YES'
	return 'NO'
card = str(input())
cards = str(input())
cards = cards.split()
print(play(card, cards))


table = input()
cards = [x for x in input().split()]
flag = False
for i in range(len(cards)):
	if cards[i][0] == table[0] or cards[i][1] == table[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


CartaEnMesa = input()
CartaEnMano = input()
print('YES' if CartaEnMesa[0] in CartaEnMano or CartaEnMesa[1] in CartaEnMano else 'NO')


x = input()
x1 = input()
x = list(x)
if x[0] in x1 or x[1] in x1:
	print('YES')
else:
	print('NO')


def rank(card):
	return card[0]

def suit(card):
	return card[1]
cardOnTable = input()
cardsInHand = input().split()
canPlay = False
for card in cardsInHand:
	if rank(card) == rank(cardOnTable) or suit(card) == suit(cardOnTable):
		canPlay = True
if canPlay:
	print('YES')
else:
	print('NO')


def solve(arr, card):
	for st in arr:
		for i in range(2):
			if st[i] == card[i]:
				print('YES')
				return
	print('NO')
card = input()
arr = input().split()
solve(arr, card)


s = list(input())
hand = list(input().split())
flag = 1
for cards in hand:
	if flag == 0:
		break
	for part in s:
		if flag == 0:
			break
		if part in cards:
			print('YES')
			flag = 0
			break
if flag == 1:
	print('NO')


rank = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
suit = ['D', 'C', 'S', 'H']
table = input()
hand = list(map(str, input().strip().split(' ')))
s = 'NO'
for h in hand:
	if h[0] == table[0]:
		s = 'YES'
		break
	elif h[1] == table[1]:
		s = 'YES'
		break
print(s)


n = input()
li = list(map(str, input().split()))
rank = n[0]
suit = n[1]
flag = 0
for i in li:
	if rank in i or suit in i:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


import sys
table = set(sys.stdin.readline().strip())
hand = set(sys.stdin.readline().strip())
if table.intersection(hand):
	print('YES')
else:
	print('NO')


from collections import deque
import heapq
import bisect
import math

def main():
	s = input()
	cards = list(input().split())
	for c in cards:
		if s[0] == c[0] or s[1] == c[1]:
			print('YES')
			exit()
	print('NO')
main()


a = input()
k = 0
a1 = input()
for i in range(0, 15, 3):
	if a[0] == a1[i] or a[1] == a1[i + 1]:
		k = 1
if k == 1:
	print('YES')
else:
	print('NO')


table = input()
cards = input().split()
flag = 0
for i in cards:
	if i[1] == table[1] or i[0] == table[0]:
		flag = flag + 1
		break
if flag > 0:
	print('YES')
else:
	print('NO')


s = input()
d = input().split()
p = 0
for i in range(5):
	if d[i][0] == s[0] or d[i][1] == s[1]:
		p += 1
if p:
	print('YES')
else:
	print('NO')


def func(card, cards):
	for ele in cards:
		if card[0] == ele[0] or card[1] == ele[1]:
			return 'YES'
	return 'NO'
card = input()
cards = list(map(str, input().split(' ')))
print(func(card, cards))


t = input()
(a, b, c, d, e) = input().split()
x = t[0]
y = t[1]
if (x in a or x in b or x in c or (x in d) or (x in e)) or (y in a or y in b or y in c or (y in d) or (y in e)):
	print('YES')
else:
	print('NO')


tablecard = input()
l = input().split()
for i in range(5):
	if tablecard[0] == l[i][0] or tablecard[1] in l[i][1]:
		print('YES')
		break
	if i == 4:
		print('NO')


def input_func():
	card_table = list(input())
	cards_hand = list(''.join(input().split()))
	return (card_table, cards_hand)

def check_play(card_table, cards_hand):
	match = False
	for i in card_table:
		if cards_hand.count(i) != 0:
			match = True
	if match:
		print('YES')
	else:
		print('NO')
(card_table, cards_hand) = input_func()
check_play(card_table, cards_hand)


n = input()
t = n[0]
u = n[1]
f = 0
li = []
k = list(map(str, input().split()))
for i in k:
	for j in i:
		li.append(j)
if t in li:
	f = 1
if u in li:
	f = 1
if f == 1:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
if a[0] == b[0][0] or a[0] == b[1][0] or a[0] == b[2][0] or (a[0] == b[3][0]) or (a[0] == b[4][0]) or (a[1] == b[0][1]) or (a[1] == b[1][1]) or (a[1] == b[2][1]) or (a[1] == b[3][1]) or (a[1] == b[4][1]):
	print('YES')
else:
	print('NO')


nums = 0
sums = 0
n = input()
myList = list(map(str, input().split()))
for i in myList:
	if n[0] == i[0]:
		nums += 1
	if n[1] == i[1]:
		sums += 1
if sums > 0 or nums > 0:
	print('YES')
else:
	print('NO')


s = input()
g = ''
a = input()
for i in a:
	if i != ' ':
		g += i
l = s[0]
m = s[1]
if l in g:
	print('YES')
elif m in g:
	print('YES')
else:
	print('NO')


s = input()
k = input()
if s[0] in k or s[1] in k:
	print('YES')
else:
	print('NO')


down = input()
hand = input()
(r, s) = (down[0], down[1])
if r in hand or s in hand:
	print('YES')
else:
	print('NO')


card_on_table = input()
card_hand = input().split()
rank = card_on_table[0]
suit = card_on_table[1]

def solve():
	for card in card_hand:
		if card[0] == rank or card[1] == suit:
			print('YES')
			return
	print('NO')
solve()


gi = lambda : list(map(int, input().strip().split()))
c = input()
cs = input().split()
if c[0] in [e[0] for e in cs] or c[1] in [e[1] for e in cs]:
	print('YES')
else:
	print('NO')


(r, s) = input()
h = input()
print(('NO', 'YES')[r in h or s in h])


import collections
a = str(input())
(x, y) = (a[0], a[1])
s = str(input())
rank = collections.defaultdict(bool)
suit = collections.defaultdict(bool)
for i in s.split():
	rank[i[0]] = True
	suit[i[1]] = True
if rank[x] == True or suit[y] == True:
	print('YES')
else:
	print('NO')


c0 = input()
(c1, c2, c3, c4, c5) = input().split()
if c1[0] == c0[0] or c2[0] == c0[0] or c3[0] == c0[0] or (c4[0] == c0[0]) or (c5[0] == c0[0]) or (c1[1] == c0[1]) or (c2[1] == c0[1]) or (c3[1] == c0[1]) or (c4[1] == c0[1]) or (c5[1] == c0[1]):
	print('YES')
else:
	print('NO')


ct = input()
lc = input().split()
vrai = 'NO'
for i in lc:
	if i[0] == ct[0] or i[1] == ct[1]:
		vrai = 'YES'
print(vrai)


card_on_table = input()
cards = input().split()
output = 'NO'
for i in cards:
	if i[0] == card_on_table[0]:
		output = 'YES'
	if i[1] == card_on_table[1]:
		output = 'YES'
	else:
		pass
print(output)


table = input()
hand = input()
hand_list = hand.split(' ')
play = False
for elem in hand_list:
	if elem[0] == table[0] or elem[1] == table[1]:
		play = True
if play:
	print('YES')
else:
	print('NO')


def main():
	c = input()
	h = input().split()
	for i in h:
		if i[0] == c[0] or i[1] == c[1]:
			print('YES')
			return
	print('NO')
main()


cd_table = input()
cd_hand = input().split(' ')
for a in cd_hand:
	if cd_table[0] in a or cd_table[1] in a:
		print('YES')
		break
else:
	print('NO')


x = input()
l = list(map(str, input().split()))
flag = False
for i in range(5):
	if x[0] == l[i][0] or x[1] == l[i][1]:
		flag = True
		break
if flag == True:
	print('YES')
else:
	print('NO')


s = input()
x = s[0]
y = s[1]
f = 0
l = list(map(str, input().split()))
(a, b) = ([], [])
for i in l:
	a.append(i[0])
	b.append(i[1])
if x in a:
	f = 1
elif y in b:
	f = 1
if f == 1:
	print('YES')
else:
	print('NO')


s = input()
a = [x for x in input().split()]
(rank, suit) = ('', '')
for i in a:
	rank += i[0]
	suit += i[1]
if s[0] in rank or s[1] in suit:
	print('YES')
else:
	print('NO')


tableCard = input()
boolean = 'NO'
cards = [x for x in input().split(' ')]
for card in cards:
	if card[0] == tableCard[0] or card[1] == tableCard[1]:
		boolean = 'YES'
		break
print(boolean)


import sys
data = sys.stdin.readlines()
hand = data[1].split()
str = ''
for k in range(5):
	if hand[k][0] == data[0][0] or hand[k][1] == data[0][1]:
		str = 'YES'
		break
if str == '':
	str = 'NO'
sys.stdout.write(str)


X = input()
y = input().split()
z = ''.join(y)
if X[0] in z or X[1] in z:
	print('YES')
else:
	print('NO')


tcard = input()
hcards = list(input().split())
flag = False
for card in hcards:
	if tcard[0] == card[0]:
		print('YES')
		flag = True
		break
	elif tcard[1] == card[1]:
		print('YES')
		flag = True
		break
if flag == False:
	print('NO')


import sys
input = sys.stdin.readline
s = input()
a = s[0]
b = s[1]
l = list(map(str, input().split()))
l = l[::-1]
l.pop
f = 0
for i in l:
	if i[0] == a or i[1] == b:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


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

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

def li():
	return list(mi())
c = input().strip()
a = input().split()
ans = any((s[0] == c[0] or s[1] == c[1] for s in a))
print('YES' if ans else 'NO')


table = input()
hand = input()
handList = hand.split()
amountTried = 0
ans = 0
while amountTried < 5:
	currentCard = handList[amountTried]
	if currentCard[0:1] == table[0:1]:
		ans = 1
	if currentCard[1:] == table[1:]:
		ans = 1
	if ans == 1:
		print('YES')
		break
	if amountTried >= 4 and ans == 0:
		print('NO')
	amountTried += 1


x = input()
y = list(x)
z = list(map(str, input().split()))
YES = 0
for i in range(5):
	if y[0] in z[i] or y[1] in z[i]:
		YES = 1
if YES == 1:
	print('YES')
else:
	print('NO')


k1 = list(input())
mas = input().split()
for i in mas:
	for z in range(2):
		if list(i)[z] == k1[z]:
			print('YES')
			raise SystemExit
print('NO')


n = input()
(a, b, c, d, e) = input().split(' ')
flag = 0
for i in range(2):
	if n[i] == a[i] or n[i] == b[i] or n[i] == c[i] or (n[i] == d[i]) or (n[i] == e[i]):
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


card = input()
hand = list(input().split())
play = False
for i in hand:
	if card[0] == i[0]:
		play = True
		break
	if card[1] == i[1]:
		play = True
		break
if play:
	print('YES')
else:
	print('NO')


s = input()
x = input()
p = False
for i in x:
	if s[0] == i or s[1] == i:
		p = True
		break
if p == True:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
(nom, mast) = (s[0], s[1])
ind = False
for k in a:
	if k[0] == nom or k[1] == mast:
		ind = True
		break
if ind:
	print('YES')
else:
	print('NO')


card_on_table = input()
lst = input().split()
for i in lst:
	if i[0] in card_on_table or i[1] in card_on_table:
		print('YES')
		break
else:
	print('NO')


t = list(input())
my = input()
if my.find(t[0]) != -1 or my.find(t[1]) != -1:
	print('YES')
else:
	print('NO')


card = input()
l = [set(s) for s in input().split()]
values = set()
for e in l:
	values |= e
print('YES' if set(card) & values else 'NO')


import sys
g = input()
hs = input().split()
for h in hs:
	if h[0] == g[0] or h[1] == g[1]:
		print('YES')
		sys.exit(0)
print('NO')


x = input()
y = input().split()
a = 0
for i in y:
	if x[0] in i or x[1] in i:
		a = 1
if a == 1:
	print('YES')
else:
	print('NO')


inp = input()
lis = list(input().split())
flag = 0
for i in lis:
	if inp[0] == i[0] or inp[1] == i[1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


def compute(card_on_table, cards_in_hand):
	if card_on_table[0] in cards_in_hand or card_on_table[1] in cards_in_hand:
		print('YES')
	else:
		print('NO')

def main():
	card_on_table = input()
	cards_in_hand = input()
	compute(card_on_table, cards_in_hand)
main()


def func(tc, hc):
	for card in hc:
		if tc[0] == card[0] or tc[1] == card[1]:
			return True
	return False
tc = input()
hc = []
cards = input()
hc = cards.split()
if func(tc, hc) == True:
	print('YES')
else:
	print('NO')


t = input()
a = t[0]
b = t[1]
(c, d, e, f, g) = input().split()
l = []
str = ''
l.extend((c[0], c[1], d[0], d[1], e[0], e[1], f[0], f[1], g[0], g[1]))
for i in l:
	if a == i or b == i:
		str = 'YES'
		break
if len(str) > 0:
	print(str)
else:
	print('NO')


s1 = input()
s2 = input()
s2 = s2.split(' ')
for i in range(0, 5):
	if s1[0] in s2[i][0]:
		print('YES')
		exit()
	if s1[1] in s2[i][1]:
		print('YES')
		exit()
print('NO')


str1 = input()
str2 = input()
if str1[0] in str2 or str1[1] in str2:
	print('YES')
else:
	print('NO')


def main():
	my_table = str(input().strip())
	my_hand = str(input().strip())
	my_hand = my_hand.replace(' ', '')
	my_table = [i for i in my_table]
	for i in my_table:
		for j in my_hand:
			if i == j:
				print('YES')
				return 0
	print('NO')
main()


T = str(input())
N = list(map(str, input().split()))
c = 0
for i in N:
	if T[0] == i[0] or T[1] == i[1]:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


import sys
hand = input()
table = input()
something = False
for roba in hand:
	for char in table:
		if roba in char:
			something = True
if something:
	print('YES')
else:
	print('NO')


(rank, suit) = input()
cards = input().split()
for (r, s) in cards:
	if r == rank or s == suit:
		print('YES')
		exit()
print('NO')


table = input()
rank = table[0]
tier = table[1]
cards = input().split()
ans = ''
for card in cards:
	if card[0] == rank or card[1] == tier:
		ans += 'YES'
		break
if len(ans) == 0:
	print('NO')
else:
	print(ans)


import sys
table = sys.stdin.readline().strip()
hand = sys.stdin.readline().strip().split()
v = False
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		v = True
if v == True:
	print('YES')
else:
	print('NO')


import sys
counter = -1
for lin in sys.stdin:
	line = lin.rstrip()
	counter += 1
	if counter == 0:
		him = line
	else:
		u = line.split()
		break
t = False
for c in u:
	if c[0] == him[0] or c[1] == him[1]:
		print('YES')
		t = True
		break
if not t:
	print('NO')


import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue

class Scanner:

	@staticmethod
	def int():
		return int(sys.stdin.readline().rstrip())

	@staticmethod
	def string():
		return sys.stdin.readline().rstrip()

	@staticmethod
	def map_int():
		return [int(x) for x in Scanner.string().split()]

	@staticmethod
	def string_list(n):
		return [input() for i in range(n)]

	@staticmethod
	def int_list_list(n):
		return [Scanner.map_int() for i in range(n)]

	@staticmethod
	def int_cols_list(n):
		return [int(input()) for i in range(n)]

class Math:

	@staticmethod
	def gcd(a, b):
		if b == 0:
			return a
		return Math.gcd(b, a % b)

	@staticmethod
	def lcm(a, b):
		return a * b // Math.gcd(a, b)

	@staticmethod
	def round_up(a, b):
		return -(-a // b)

	@staticmethod
	def is_prime(n):
		if n < 2:
			return False
		if n == 2:
			return True
		if n % 2 == 0:
			return False
		d = int(n ** 0.5) + 1
		for i in range(3, d + 1, 2):
			if n % i == 0:
				return False
		return True

class PriorityQueue:

	def __init__(self, l=[]):
		self.q = l
		heapq.heapify(self.q)
		return

	def push(self, n):
		heapq.heappush(self.q, n)
		return

	def pop(self):
		return heapq.heappop(self.q)
MOD = int(1000000000.0) + 7
INF = int(1000000000000000.0)

def main():
	A = Scanner.string()
	X = Scanner.string()
	ans = False
	for a in A:
		if a in X:
			ans = True
	print('NYOE S'[ans::2])
main()


(a, b) = input()
h = input().split()
for i in h:
	if a in i or b in i:
		print('YES')
		break
else:
	print('NO')


a = input()
p = set()
q = set()
for x in input().split():
	p.add(x[0])
	q.add(x[1])
if a[0] in p or a[1] in q:
	print('YES')
else:
	print('NO')


s = input()
hand = input()
if hand.find(s[0]) != -1 or hand.find(s[1]) != -1:
	print('YES')
else:
	print('NO')


a = input()
p = input().split()
value = [i[0] for i in p]
suit = [i[1] for i in p]
if a[0] in value or a[1] in suit:
	print('YES')
else:
	print('NO')


s1 = input()
f = 1
l = [i for i in input().split()]
for s2 in l:
	if s1[0] == s2[0] or s1[1] == s2[1]:
		f = 0
		break
if f:
	print('NO')
else:
	print('YES')


s = str(input())
card_on_tab = list(map(str, input().split()))
x = ''.join(card_on_tab)
for i in s:
	if s[0] in x or s[-1] in x:
		print('YES')
		break
	else:
		print('NO')
		break


from sys import stdin
(r, s) = stdin.readline().rstrip()
hand = stdin.readline().rstrip().split(' ')
possible = False
for card in hand:
	(rank, suit) = card
	if rank == r or suit == s:
		possible = True
print('YES' if possible else 'NO')


s = input()
lst = list(map(str, input().split()))
flag = 0
for i in range(5):
	str1 = lst[i]
	if str1[0] == s[0] or str1[1] == s[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


card = input()
hand = list(input().split(' '))
for x in hand:
	if x[0] == card[0] or x[1] == card[1]:
		print('YES')
		exit()
print('NO')


x = list(input())
y = list(map(str, input().split()))
for i in range(len(y)):
	y[i] = list(y[i])
flag = 0
for i in range(len(y)):
	if x[0] == y[i][0] or x[1] == y[i][1]:
		flag = 1
		print('YES')
		break
if flag == 0:
	print('NO')


x = input()
a = input().split()
q = []
p = []
for (i, j) in a:
	q.append(i)
	p.append(j)
q = set(q)
p = set(p)
print('YES' if q & set(x[0]) | p & set(x[1]) else 'NO')


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


s = list(input())
l = list(input())
a = s[0]
b = s[1]
if a in l:
	print('YES')
elif b in l:
	print('YES')
else:
	print('NO')


n = input()
a = input().split()
t = 0
for i in a:
	if i[0] == n[0]:
		t = 1
	elif i[1] == n[1]:
		t = 1
if t == 1:
	print('YES')
else:
	print('NO')


ans = 'NO'
onTable = input()
onHand = input()
for card in onHand.split():
	if onTable[0] == card[0] or onTable[1] == card[1]:
		ans = 'YES'
print(ans)


from sys import stdin, exit
h = list(stdin.readline().rstrip())
t = stdin.readline().rstrip().split(' ')
s = set()
for p in t:
	(rank, suit) = list(p)
	s.add(rank)
	s.add(suit)
for part in h:
	if part in s:
		print('YES')
		exit()
print('NO')


x = input()
s = input().split()
ans = 'NO'
for i in range(2):
	for j in range(5):
		if x[i] == s[j][i]:
			ans = 'YES'
			break
print(ans)


x = input()
y = list(input().split())
flag = True
for i in y:
	if x[1] in i or x[0] in i:
		print('YES')
		flag = False
		break
if flag == True:
	print('NO')


card = input()
mycard = input()
mycardsuit = mycard[1::3]
mycardnum = mycard[::3]
if card[0] in mycardnum or card[1] in mycardsuit:
	print('YES')
else:
	print('NO')


Table = input()
hand = list(input().split())
flag = 0
for i in range(5):
	if Table[0] == hand[i][0]:
		flag = 1
		break
for i in range(5):
	if Table[1] == hand[i][1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


c0 = input()
C = input().split()
for c in C:
	if c[0] == c0[0] or c[1] == c0[1]:
		print('YES')
		break
else:
	print('NO')


s = input()
Q = map(str, input().split())
flag = 0
for S in Q:
	if s[0] == S[0] or s[1] == S[1]:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


n = input()
five = input().split()
for c in five:
	if c[0] == n[0] or c[1] == n[1]:
		print('YES')
		break
else:
	print('NO')


card = input()
cards = input().split()
if any((c[0] == card[0] or c[1] == card[1] for c in cards)):
	print('YES')
else:
	print('NO')


hand = input()
table = input().split()
res = 'NO'
for k in table:
	for j in hand:
		if (j in k[0]) | (j in k[1]):
			res = 'YES'
print(res)


A = 'ME CHUPA UN GÜEBO'
myCard = input()
cardTable = list(map(str, input().split()))
count = 0
for i in range(5):
	if myCard[1] == cardTable[i][1]:
		count += 1
	if myCard[0] == cardTable[i][0]:
		count += 1
if count:
	print('YES')
else:
	print('NO')


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if ll[mid] == val:
			return mid
		elif ll[mid] > val:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
s = str(input())
l = list(map(str, input().split(' ')))
boo = False
for i in range(len(l)):
	if l[i][0:1] == s[0:1] or l[i][1:2] == s[1:2]:
		boo = True
		break
if boo:
	print('YES')
else:
	print('NO')


first = input()
cards = input().split()
ans = 'NO'
for c in cards:
	if c[0] is first[0] or c[1] is first[1]:
		ans = 'YES'
		break
print(ans)


start_card = input()
my_cards = input().split(' ')
res = 'NO'
for card in my_cards:
	if start_card[0] == card[0] or start_card[1] == card[1]:
		res = 'YES'
		break
print(res)


import math
import os
import random
import re
import sys
s = input()
t = input()
tb = t.split(' ')
l = len(tb)
ans = False
for x in range(0, l):
	if tb[x][0] == s[0] or tb[x][1] == s[1]:
		ans = True
if ans:
	print('YES')
else:
	print('NO')


a = 0
table = input()
rank_t = table[0]
suit_t = table[1]
hand = input()
rank = [hand[0], hand[3], hand[6], hand[9], hand[12]]
suit = [hand[1], hand[4], hand[7], hand[10], hand[13]]
for i in range(5):
	if rank[i] == rank_t:
		a = 1
		print('YES')
		break
	if suit[i] == suit_t:
		a = 1
		print('YES')
		break
if a == 0:
	print('NO')


table = input()
hand = input().split()
ans = 'NO'
for card in hand:
	for feature in card:
		if feature in table:
			ans = 'YES'
print(ans)


(r, s) = [str(x) for x in input()]
for (rt, st) in [str(x) for x in input().split()]:
	if rt == r or st == s:
		print('YES')
		break
else:
	print('NO')


carta = input()
mazo = input()
if mazo.find(carta[0]) != -1 or mazo.find(carta[1]) != -1:
	print('YES')
else:
	print('NO')


c = input()
cards = input().split()
for i in range(5):
	if cards[i][0] == c[0]:
		print('YES')
		quit()
	elif cards[i][1] == c[1]:
		print('YES')
		quit()
print('NO')


c = input()
flag = 0
(a, b, c1, d, e) = map(str, input().split())
if a[0] == c[0] or a[1] == c[1]:
	flag = 1
elif b[0] == c[0] or b[1] == c[1]:
	flag = 1
elif c1[0] == c[0] or c1[1] == c[1]:
	flag = 1
elif d[0] == c[0] or d[1] == c[1]:
	flag = 1
elif e[0] == c[0] or e[1] == c[1]:
	flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


card = input()
player_cards = input()

def can_play(input_card, player_cards):
	(rank, suit) = [e for e in input_card]
	for card in player_cards.split():
		if rank in card or suit in card:
			return True
	return False
print('YES' if can_play(card, player_cards) else 'NO')


table = input().strip()
res = 'NO'
for ch in input():
	if ch == table[0] or ch == table[1]:
		res = 'YES'
		break
print(res)


s = [n for n in input()]
z = [n for n in input()]
if s[0] in z:
	print('YES')
elif s[1] in z:
	print('YES')
else:
	print('NO')


table = input()
(a, b, c, d, e) = input().split(' ')
first = a[0] + b[0] + c[0] + d[0] + e[0]
second = a[1] + b[1] + c[1] + d[1] + e[1]
if table[0] in first or table[1] in second:
	print('YES')
else:
	print('NO')


n = input()
l = input().split()
a = []
for i in range(len(l)):
	if l[i][0] == n[0]:
		a.append('YES')
	elif l[i][1] == n[1]:
		a.append('YES')
	else:
		a.append('NO')
if 'YES' in a:
	print('YES')
else:
	print('NO')


table = input()
hands = input().split()
first = [hands[i][0] for i in range(5)]
second = [hands[i][1] for i in range(5)]
if table[0] in first or table[1] in second:
	print('YES')
else:
	print('NO')


import sys
import math
from collections import defaultdict

def getInputFromLine():
	return [int(x) for x in input().split()]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
temp = input()
(num, kind) = (temp[0], temp[1])
temp = [x for x in input().split()]
suit = set()
numbers = set()
for c in temp:
	numbers.add(c[0])
	suit.add(c[1])
if num in numbers or kind in suit:
	print('YES')
else:
	print('NO')


table = input()
hand = input()
hands = hand.split(' ')
flag = 0
for i in hands:
	if flag == 1:
		break
	for j in i:
		if j in table:
			print('YES')
			flag = 1
			break
if flag == 0:
	print('NO')


TABLE_CARD = input()
HAND = input().split(' ')
FLAG = False
for c in HAND:
	if c[0] in TABLE_CARD or c[1] in TABLE_CARD:
		FLAG = True
		break
if FLAG:
	print('YES')
else:
	print('NO')


import math
import re
import sys
import string
import bisect as bi

def main():
	t = input().strip()
	a = input().strip().split()
	res = False
	for i in a:
		if t[0] == i[0] or t[1] == i[1]:
			res = True
			break
	if res:
		print('YES')
	else:
		print('NO')
main()


table_card = input()
hand_cards = input().split()
target_rank = table_card[0]
target_suit = table_card[1]
available_ranks = list(set(map(lambda x: x[0], hand_cards)))
available_suits = list(set(map(lambda x: x[1], hand_cards)))
if target_rank in available_ranks or target_suit in available_suits:
	print('YES')
else:
	print('NO')


a = input()
s = input().split()
for i in range(len(s)):
	if s[i].count(a[0]) > 0 or s[i].count(a[1]) > 0:
		print('YES')
		exit()
print('NO')


def split(word):
	return [char for char in word]
(rank, suit) = split(input())
lst = list(input().split())
res = False
for i in range(len(lst)):
	if rank in lst[i] or suit in lst[i]:
		res = True
	elif res == True:
		break
	else:
		res = False
		continue
if res == True:
	print('YES')
else:
	print('NO')


s = input()
t = list(input().split())
f = 0
for x in t:
	if x[0] == s[0] or x[1] == s[1]:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


n = str(input())
a = str(input())
q = 0
for i in range(0, len(a), 3):
	if a[i] == n[0]:
		q += 1
	else:
		for x in range(1, len(a), 3):
			if a[x] == n[1]:
				q += 1
if q > 0:
	print('YES')
else:
	print('NO')


s = input()
li = list(map(str, input().split()))
c = 0
for i in range(len(s)):
	for j in range(len(li)):
		if s[i] in li[j][i]:
			c = 1
if c == 1:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
ans = any([True if v[0] == table[0] or v[1] == table[1] else False for v in hand])
print('YES') if ans == True else print('NO')


d = input().strip()
cards = [s for s in input().split()]
done = False
for c in cards:
	if c[0] == d[0] or c[1] == d[1]:
		print('YES')
		done = True
		break
if not done:
	print('NO')


t = input()
c = 0
h = [x for x in input().split()]
for i in range(5):
	if t[0] == h[i][0] or t[1] == h[i][1]:
		print('YES')
		exit()
	else:
		continue
print('NO')


c = input()
x = input().split()
cl = []
for i in str(c):
	cl.append(i)
mcl = []
for j in str(x):
	mcl.append(j)

def compare(list1, list2):
	for i in range(len(list1)):
		for j in range(len(list2)):
			if list2[j] == list1[i]:
				return 'YES'
	return 'NO'
print(compare(cl, mcl))


c = input()
cards = [' '.join(x).split() for x in input().split()]
if c[0] in ''.join([x[0] for x in cards]) or c[1] in ''.join([x[1] for x in cards]):
	print('YES')
else:
	print('NO')


(r, s) = list(input())
rS = []
sS = []
inp = input().split()
for i in inp:
	rS.append(i[0])
	sS.append(i[1])
if r in rS or s in sS:
	print('YES')
else:
	print('NO')


x = input()
y = [z for z in input().split()]
f = False
for i in range(len(y)):
	if x[0] == y[i][0] or x[1] == y[i][1]:
		f = True
if f == True:
	print('YES')
else:
	print('NO')


a = input()
b = list(map(str, input().split()))
c = 0
for i in b:
	if i[0] == a[0] or i[1] == a[1]:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


cart = input()
for i in list(input().split()):
	if cart[0] == i[0] or cart[1] == i[1]:
		print('YES')
		exit(0)
print('NO')


s = input()
l = input().split()
a = s[0]
b = s[1]
c = 0
for i in range(len(l)):
	if a in l[i] or b in l[i]:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


str1 = input()
str2 = input()
a = str1[0]
b = str1[1]
s = 0
i = 0
l = len(str2)
for i in range(0, l):
	if str2[i] == a or str2[i] == b:
		s = 1
if s == 1:
	print('YES')
if s == 0:
	print('NO')


s = input()
s1 = s[0]
s2 = s[1]
s3 = input().split()
arr = []
for ele in s3:
	arr.append(ele)
c = 0
for ele in arr:
	if s1 in ele or s2 in ele:
		print('YES')
		c = 1
		break
if c == 0:
	print('NO')


stack = input()
(q, w, e, r, t) = input().split()
hand = q + w + e + r + t
s = []
h = []
y = 0
for x in range(len(hand)):
	if stack[0] == hand[x]:
		y = y + 1
	if stack[1] == hand[x]:
		y = y + 1
if y > 0:
	print('YES')
else:
	print('NO')


s = input()
cs = input().split()
ok = False
for c in cs:
	if c[0] == s[0] or s[1] == c[1]:
		ok = True
print('YNEOS'[1 - ok::2])


s = input()
lists = list(map(str, input().split()))
listi = []
listis = []
for i in lists:
	listi.append(i[0])
	listis.append(i[1])
if s[0] in listi or s[1] in listis:
	print('YES')
else:
	print('NO')


t = input()
y = ''.join((i for i in input().split()))
print('YES' if t[0] in y or t[1] in y else 'NO')


n = list(input())
cat = list(input().split())
ch = []
d = 0
for (count, item) in enumerate(cat):
	ch.append(list(item))
for item in ch:
	if item[0] == n[0] or item[1] == n[1]:
		print('YES')
		break
	else:
		d += 1
if d == 5:
	print('NO')


x = input()
y = list(map(str, input().split()))
k = 0
for i in y:
	if i[0] == x[0]:
		k = 1
		break
	if i[1] == x[1]:
		k = 1
		break
if k == 0:
	print('NO')
else:
	print('YES')


tab = input()
hand = input().split()
ans = False
for i in hand:
	if tab[0] == i[0] or tab[1] == i[1]:
		ans = True
if ans:
	print('YES')
else:
	print('NO')


tk = input()
m = tk[0]
n = tk[1]
flag = 0
inp2 = list(map(str, input().split()))
for st in inp2:
	if st[0] == m:
		print('YES')
		flag = 1
		break
	elif st[1] == n:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


p = 0
s = input()
for i in input().split():
	if i[0] == s[0] or i[1] == s[1]:
		p = 1
if p == 1:
	print('YES')
else:
	print('NO')


cardTable = input()
cardsHand = input().split()
find = False
for card in cardsHand:
	if cardTable[0] == card[0]:
		find = True
		print('YES')
		break
	elif cardTable[1] in card[1]:
		find = True
		print('YES')
		break
if find == False:
	print('NO')


cot = input()
cin = input()
if cin.find(cot[0]) != -1:
	print('YES')
elif cin.find(cot[1]) != -1:
	print('YES')
else:
	print('NO')


a = input()
(x, y) = (a[0], a[1])
l = []
w = input().split()
for i in range(len(w)):
	if w[i][0] == x or w[i][1] == y:
		print('YES')
		exit()
print('NO')


card_on_table = input()
cards_on_hand = input().split()

def checkIfCanLay():
	for card in cards_on_hand:
		if card[0] in card_on_table[0]:
			return True
		if card[1] in card_on_table[1]:
			return True
if checkIfCanLay() == True:
	print('YES')
else:
	print('NO')


n = str(input())
arr = list(map(str, input().split()))
a = n[:1]
b = n[1:]
s = ''
for i in arr:
	s += i
if a in s or b in s:
	print('YES')
else:
	print('NO')


t = input()
h = list(input())
try:
	for i in range(len(h)):
		if h[i] == ' ':
			h.pop(i)
except:
	pass
flag = 0
for i in range(0, len(h), 2):
	if h[i] == t[0]:
		flag = 1
for i in range(1, len(h) + 1, 2):
	if h[i] == t[1]:
		flag = 1
if flag != 0:
	print('YES')
else:
	print('NO')


b = True
s = input()
s2 = input()
if s[0] in s2:
	b = False
if s[1] in s2:
	b = False
if b:
	print('NO')
else:
	print('YES')


import sys
from atexit import register
from io import StringIO as stream
inf = float('inf')
mod = 1000000007

def fast_io():
	sys.stdin = stream(sys.stdin.read())
	sys.stdout = stream()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

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

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

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

def main():
	s = input()
	arr = list(input().split())
	for i in arr:
		if i[0] == s[0] or i[1] == s[1]:
			print('YES')
			return
	print('NO')
main()


t = input()
c = input().split()
print('YES' if t[0] in [x[0] for x in c] or t[1] in [x[1] for x in c] else 'NO')


s1 = [i for i in input()]
cd = [[k for k in i] for i in input().split()]
flag = False
for i in cd:
	if i[0] == s1[0] or i[1] == s1[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


def sprav(target, ammo):
	for shell in ammo:
		if shell[0] == target[0] or shell[1] == target[1]:
			return 'YES'
	return 'NO'
card = input()
cards = input().split()
print(sprav(card, cards))


def main():
	table_card = input()
	table_split = []
	for letter in table_card:
		table_split.append(letter)
	hand_cards = list(input())
	hand_cards = ''.join(hand_cards)
	output = check(hand_cards, table_split)
	print(output)

def check(hand, table):
	for letter in hand:
		if letter in table:
			return 'YES'
		else:
			pass
	return 'NO'
main()


(r, s) = input()
f = False
for c in input().split():
	(rc, sc) = c
	if rc == r or sc == s:
		f = True
		break
if f:
	print('YES')
else:
	print('NO')


x = input()
query = list(input().split())
count = 0
for j in query:
	if x[0] == j[0] or x[1] == j[1]:
		count = 1
		break
if count == 0:
	print('NO')
else:
	print('YES')


n = str(input())
alist = input().split(' ')
for i in alist:
	if i[0] == n[0]:
		print('YES')
		exit(0)
	elif i[-1] == n[-1]:
		print('YES')
		exit(0)
print('NO')


s = input()
l = list(map(str, input().split()))
t = False
for i in range(5):
	if s[0] == l[i][0] or s[1] == l[i][1]:
		t = True
if t:
	print('YES')
else:
	print('NO')


c = input()
a = input().split()
for k in a:
	if k[0] == c[0] or k[1] == c[1]:
		print('YES')
		break
else:
	print('NO')


card = input()
cards = list(map(str, input().split(' ')))
rang = []
mast = []
for i in cards:
	rang.append(i[0])
	mast.append(i[1])
if card[0] in rang or card[1] in mast:
	print('YES')
else:
	print('NO')


table = input()
hand = input()
d = table[0]
m = table[1]
if hand.find(d) > -1 or hand.find(m) > -1:
	print('YES')
else:
	print('NO')


table = input()
cards = list(map(str, input().split()))
cards_full = []
for card in cards:
	cards_full.extend([char for char in card])
result = any((elem in [char for char in table] for elem in cards_full))
if result:
	print('YES')
else:
	print('NO')


def A():
	table = input()
	hand = input().split()
	(numero, palo) = (table[0], table[1])
	for h in hand:
		if h[0] == numero:
			print('YES')
			return
		if h[1] == palo:
			print('YES')
			return
	print('NO')
A()


c_on_table = input()[:2]
c_on_hand = list(map(str, input().split()))[:5]
flag = 0
for i in range(5):
	if c_on_hand[i][0] == c_on_table[0] or c_on_hand[i][1] == c_on_table[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


inp1 = ['']
inp1 = input()
inp2 = input()
for i in range(0, 13, 3):
	if inp1[0] == inp2[i]:
		print('YES')
		exit()
	elif inp2[i + 1] == inp1[1]:
		print('YES')
		exit()
print('NO')


t = str(input())
card = str(input())
card = list(card.split(' '))
for i in range(len(t)):
	for j in range(len(card)):
		if card[j][0] == t[i] or card[j][1] == t[i]:
			print('YES')
			exit()
print('NO')


my_card = input()
all_cards = input().split()
ranks = [i[0] for i in all_cards]
suits = [i[1] for i in all_cards]
if my_card[0] in ranks or my_card[1] in suits:
	print('YES')
else:
	print('NO')


a = input()
b = input()
s = 0
for c in b:
	if a[0] == c or a[1] == c:
		s += 1
if s > 0:
	print('YES')
else:
	print('NO')


a = str(input())
(z, x, c, v, b) = map(str, input().split())
if a[0] == z[0] or a[0] == x[0] or a[0] == c[0] or (a[0] == v[0]) or (a[0] == b[0]) or (a[1] == z[1]) or (a[1] == x[1]) or (a[1] == c[1]) or (a[1] == v[1]) or (a[1] == b[1]):
	print('YES')
else:
	print('NO')


check = list(map(str, input()))
checker = list(map(str, input()))
if check[0] in checker or check[1] in checker:
	print('YES')
else:
	print('NO')


cards = ['2D', '2C', '2S', '2H', '3D', '3C', '3S', '3H', '4D', '4C', '4S', '4H', '5D', '5C', '5S', '5H', '6D', '6C', '6S', '6H', '7D', '7C', '7S', '7H', '8D', '8C', '8S', '8H', '9D', '9C', '9S', '9H', 'TD', 'TC', 'TS', 'TH', 'JD', 'JC', 'JS', 'JH', 'QD', 'QC', 'QS', 'QH', 'KD', 'KC', 'KS', 'KH', 'AD', 'AC', 'AS', 'AH']
t = list(input())
s = input().split(' ')
can = False
for i in s:
	if t[0] == i[0] or t[1] == i[1]:
		can = True
print('YES' if can else 'NO')


a = input()
mao = input().split(' ')
o = 0
for i in mao:
	if i[0] == a[0] or i[1] == a[1]:
		o = 1
		break
if o == 1:
	print('YES')
else:
	print('NO')


card_on_table = input()
your_cards = input().split()
out = 'NO'
for i in range(0, 5):
	if card_on_table[0] in your_cards[i][0] or card_on_table[1] in your_cards[i][1]:
		out = 'YES'
		break
print(out)


tableCard = input()
cards = list(input().strip().split())
yes = False
for i in range(2):
	for j in range(5):
		if tableCard[i] == cards[j][i]:
			yes = 1
			break
if yes:
	print('YES')
else:
	print('NO')


card_on_table = input()
cards_in_hand = input()
if card_on_table[0] in cards_in_hand or card_on_table[1] in cards_in_hand:
	print('YES')
else:
	print('NO')


def can_play(t, h):
	for x in h:
		if x[0] == t[0] or x[1] == t[1]:
			return True
	return False
table = input()
hand = [x for x in input().split()]
print('YES' if can_play(table, hand) else 'NO')


table = input()
hand = input().split()
rank = table[0]
suit = table[1]
flag = False
for cart in hand:
	if rank == cart[0] or suit == cart[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


def solve(c1, c2, b):
	for elt in b:
		if elt[0] == c1:
			return 'YES'
	for elt in b:
		if elt[1] == c2:
			return 'YES'
	return 'NO'
a = input()
(c1, c2) = a
b = input().split()
print(solve(c1, c2, b))


s = input()
(f, se, t, fo, fi) = input().split()
s0 = s[0]
s1 = s[1]
l0 = [f[0], se[0], t[0], fo[0], fi[0]]
l1 = [f[1], se[1], t[1], fo[1], fi[1]]
if s0 in l0 or s1 in l1:
	print('YES')
else:
	print('NO')


a = input()
y = list(a)
x = input().split()
r = 0
for t in x:
	m = list(t)
	for l in y:
		if l in m:
			r = 1
			break
if r == 1:
	print('YES')
else:
	print('NO')


class Cards(object):

	def cards(self):
		self.present = False
		self.c = input()
		self.cards = list(map(str, input().split()))
		(self.c1, self.c2) = (self.c[0], self.c[1])
		for i in self.cards:
			if i[0] == self.c1 or i[1] == self.c2:
				self.present = True
		if self.present:
			print('YES')
		if not self.present:
			print('NO')

	def print_all(self):
		print(self.c1)
		print(self.cards)
cc = Cards()
cc.cards()


FirstCard = input()
strFive = input()
Cards = [[0, 0], [0, 0], [0, 0], [0, 0], [0, 0]]
(Cards[0][0], Cards[0][1]) = (strFive[0], strFive[1])
(Cards[1][0], Cards[1][1]) = (strFive[3], strFive[4])
(Cards[2][0], Cards[2][1]) = (strFive[6], strFive[7])
(Cards[3][0], Cards[3][1]) = (strFive[9], strFive[10])
(Cards[4][0], Cards[4][1]) = (strFive[12], strFive[13])

def C():
	for i in range(5):
		if FirstCard[0] == Cards[i][0]:
			return True
		elif i == 4 and FirstCard[0] != Cards[i][0]:
			for m in range(5):
				if FirstCard[1] == Cards[m][1]:
					return True
				elif m == 4 and FirstCard[1] != Cards[i][1]:
					return False
if C() == True:
	print('YES')
else:
	print('NO')


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : li(ent())
carta = inp()
cartas = inp().split(' ')
for i in cartas:
	if i[0] == carta[0] or i[1] == carta[1]:
		print('YES')
		break
else:
	print('NO')


card_on_table = input()
answer = 'NO'
hand_of_cards = list(map(str, input().split()))
for i in range(len(card_on_table)):
	for card in hand_of_cards:
		if i == 0 and card_on_table[i] == card[i]:
			answer = 'YES'
		elif i == 1 and card_on_table[i] == card[i]:
			answer = 'YES'
print(answer)


a = input()
r = 0
b = list(map(str, input().split()))
for i in range(5):
	if b[i][0] == a[0] or b[i][1] == a[1]:
		r = 1
		break
	else:
		r = 0
if r:
	print('YES')
else:
	print('NO')


d = input()
h = input().split()
h1 = h[:][0]
h2 = h[:][1]
f = True
for i in h:
	if i[0] == d[0] or i[1] == d[1]:
		print('YES')
		f = False
		break
if f:
	print('NO')


def answer():
	card = list(input())
	value = card[0]
	suit = card[1]
	board = input().split()
	for x in board:
		if x[0] == value or x[1] == suit:
			return 'YES'
	return 'NO'
print(answer())


card = input().strip()
table = list(input().strip().split())
for i in table:
	if i[0] == card[0] or i[1] == card[1]:
		print('YES')
		exit()
print('NO')


n = input()
s = 0
n1 = input().split()
for i in n1:
	for j in i:
		if j == n[0] or j == n[1]:
			s = s + 1
if s >= 1:
	print('YES')
else:
	print('NO')


input_card = input()
hand = input().split()
rank = [2, 3, 4, 5, 6, 7, 8, 9]
rank_symbol = {'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
ans = 'NO'
for card in hand:
	if input_card[1] == card[1] or input_card[0] == card[0]:
		print('YES')
		exit()
print(ans)


table_card = list(input())
cards = input().split()
for card in cards:
	if card[0] == table_card[0] or card[1] == table_card[1]:
		print('YES')
		break
else:
	print('NO')


mesa = input()
mano = input()
mano = mano.split()
respuesta = 'NO'
for x in mano:
	if mesa[0] == x[0] or mesa[1] == x[1]:
		respuesta = 'YES'
print(respuesta)


table = list(input())
hand = list(input().split(' '))
ans = 'NO'
for c in hand:
	card = list(c)
	if c[0] == table[0] or c[1] == table[1]:
		ans = 'YES'
		break
print(ans)


s = input()
l = list(map(str, input().split()))
flag = 1
for x in l:
	if x[0] == s[0] or x[1] == s[1]:
		flag = -1
if flag == -1:
	print('YES')
else:
	print('NO')


tablecard = input()
mycards = input().split(' ')
playable = False
for i in range(5):
	if tablecard[0] == mycards[i][0]:
		playable = True
		break
	if tablecard[1] == mycards[i][1]:
		playable = True
		break
if playable == True:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input()
if s1[0] in s2 or s1[1] in s2:
	print('YES')
else:
	print('NO')


s1 = str(input())
s2 = str(input())
s1r = s1[0]
s1s = s1[1]
r = 0
if s1r == s2[0] or s1r == s2[3] or s1r == s2[6] or (s1r == s2[9]) or (s1r == s2[12]) or (s1s == s2[1]) or (s1s == s2[4]) or (s1s == s2[7]) or (s1s == s2[10]) or (s1s == s2[13]):
	r = 1
if r == 1:
	print('YES')
else:
	print('NO')


(a, b, f) = (input(), list(input().split()), 0)
for i in b:
	if i[0] == a[0] or i[1] == a[1]:
		print('YES')
		f = 1
		break
if not f:
	print('NO')


s = input()
l = list(map(str, input().split()))
flag = 0
for i in l:
	g = i[0]
	f = i[1]
	if g in s or f in s:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


(rank, suit) = list(input())
temp = input().split(' ')
ranks = set()
suits = set()
for thing in temp:
	ranks.add(thing[0])
	suits.add(thing[1])
if rank in ranks or suit in suits:
	print('YES')
else:
	print('NO')


from sys import stdin
onTable = stdin.readline().rstrip()
cardSet = stdin.readline().split()
end = False
for i in cardSet:
	if end:
		break
	for j in onTable:
		if j in i:
			print('YES')
			end = True
			break
	if end:
		break
else:
	print('NO')


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


import math
hand = input()
other = input()
if hand[0] in other or hand[1] in other:
	print('YES')
else:
	print('NO')


s = input()
myCards = input().split()
a = False
for i in myCards:
	if s[0] == i[0] or s[1] == i[1]:
		a = True
print(('NO', 'YES')[a])


n = input()
l = input()
check = 1
for i in l:
	if i == n[0] or i == n[1]:
		print('YES')
		break
else:
	print('NO')


s = input()
a = []
a.append(input().split())
for i in a[0]:
	if i[0] in s or i[-1] in s:
		print('YES')
		exit()
print('NO')


a = input()
list1 = list(input().split())
tlist = [x for x in a]
for x in range(5):
	if tlist[0] in list1[x] or tlist[1] in list1[x]:
		print('YES')
		break
else:
	print('NO')


board = input()
hand = input().split()

def solve():
	global board, hand
	for el in hand:
		if el[0] == board[0] or el[1] == board[1]:
			return 'YES'
	return 'NO'
print(solve())


n = input()
lists = list(map(str, input().split()))
for i in lists:
	if n[0] == i[0] or n[1] == i[1]:
		print('YES')
		break
else:
	print('NO')


def main():
	values = {'2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'}
	suits = {'D', 'C', 'S', 'H'}
	t = input()
	(t_val, t_suit) = (t[0], t[1])
	h = input().split()
	h_vals = {h_c[0] for h_c in h}
	h_suits = {h_c[1] for h_c in h}
	if t_val in h_vals or t_suit in h_suits:
		print('YES')
	else:
		print('NO')
main()


on_table = input()
hand = input().split()
sol = False
for card in hand:
	if card[0] == on_table[0] or card[1] == on_table[1]:
		sol = True
if sol:
	print('YES')
else:
	print('NO')


ar = {}
table = input()
ar = input().split()
flag = 0
for i in range(0, 5):
	if ar[i][0] == table[0] or ar[i][1] == table[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


arr = []
s = ''
s = input()
flag = 0
arr = list(input().split())
for i in range(0, 5):
	if arr[i][0] == s[0] or arr[i][1] == s[1]:
		flag = 1
if flag == 0:
	print('NO')
else:
	print('YES')


c = input()
s = list(input().split())
print('YES' if any((c[0] == x[0] or c[1] == x[1] for x in s)) else 'NO')


desk = str(input())
hand = str(input()).split()
for rank in range(len(hand)):
	currentCard = hand[rank]
	if desk[0:1] == currentCard[0:1]:
		print('YES')
		exit()
for suit in range(len(hand)):
	if desk[1:2] == hand[suit][1:2]:
		print('YES')
		exit()
print('NO')


s = input()
ans = 'NO'
mass = input().split()
for t in mass:
	for k in t:
		if k == s[0] or k == s[1]:
			ans = 'YES'
print(ans)


you = input()
me = [i for i in input().split()]
go = 'NO'
for i in me:
	(x, y) = i
	if x in you or y in you:
		go = 'YES'
print(go)


firstcard = input()
cards = input().split()
play = False
for c in cards:
	if c[0] == firstcard[0] or c[1] == firstcard[1]:
		play = True
		break
if play:
	print('YES')
else:
	print('NO')


find_term = input()
arr = input().split()
flag = 0
for i in arr:
	if find_term[0] == i[0] or find_term[1] == i[1]:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


txt = input()
sp = input().split()
x = False
for i in sp:
	for j in i:
		if j in txt:
			x = True
if x:
	print('YES')
else:
	print('NO')


x = input()
y = input()
arrayX = [0] * len(x)
arrayY = [0] * len(y)
for i in range(len(arrayX)):
	arrayX[i] += ord(x[i])
for i in range(len(arrayY)):
	arrayY[i] += ord(y[i])
stts = False
for i in range(len(arrayY)):
	for j in range(len(arrayX)):
		if arrayY[i] == arrayX[j]:
			stts = True
			break
if stts == True:
	print('YES')
else:
	print('NO')


def func(arr, string):
	bo = False
	for x in arr:
		if x[0] == string[0]:
			bo = True
			break
		if x[1] == string[1]:
			bo = True
			break
	return bo

def main():
	string = input()
	arr = input().split()
	if func(arr, string):
		print('YES')
	else:
		print('NO')
main()


m = input()
(a, b, c, d, e) = map(str, input().split())
if a[0] == m[0] or a[1] == m[1]:
	print('YES')
	exit()
if b[0] == m[0] or b[1] == m[1]:
	print('YES')
	exit()
if c[0] == m[0] or c[1] == m[1]:
	print('YES')
	exit()
if d[0] == m[0] or d[1] == m[1]:
	print('YES')
	exit()
if e[0] == m[0] or e[1] == m[1]:
	print('YES')
	exit()
print('NO')


s = input()
ai = input().split()
for i in ai:
	if s[0] == i[0] or s[1] == i[1]:
		print('YES')
		break
else:
	print('NO')


def solve():
	table = input()
	for check in (s for s in input().split()):
		if check[0] == table[0] or check[1] == table[1]:
			print('YES')
			break
	else:
		print('NO')
solve()


i = input()
i2 = input().split(' ')
out = False
for s in i2:
	if s[0] == i[0] or s[1] == i[1]:
		out = True
		break
if out:
	print('YES')
else:
	print('NO')


v = input()
dicts = {}
for i in v:
	if i not in dicts:
		dicts[i] = 1
	else:
		dicts[i] += 1
gg = input()
flag = 0
for i in gg:
	if i in dicts:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


t = input()
h = input().split()
count = 0
for i in range(len(h)):
	count += 1
	if t[0] == h[i][0] or t[1] == h[i][1]:
		print('YES')
		break
	if count == len(h):
		print('NO')


t1 = str(input())
t2 = map(str, input().split())
flag = 0
for i in t2:
	if i[0] == t1[0]:
		flag = 1
	if i[1] == t1[1]:
		flag = 1
if flag:
	print('YES')
else:
	print('NO')


card = str(input())
arr = list(map(str, input().split()))
half1 = card[:1]
half2 = card[1:]
es = 0
for i in range(len(arr)):
	word = arr[i]
	if word[:1] == half1 or word[1:] == half2:
		es = 1
if es == 1:
	print('YES')
if es == 0:
	print('NO')


tcard = input()
lst = [x for x in input().split()]
c = 0
for card in lst:
	if card[0] == tcard[0]:
		print('YES')
		c += 1
		break
	if card[1] == tcard[1]:
		print('YES')
		c += 1
		break
if c == 0:
	print('NO')


a = input()
B = input().split()
x = any([a[0] == b[0] or a[1] == b[1] for b in B])
print('YES') if x else print('NO')


in1 = input()
in2 = input().split()
for i in range(5):
	if in2[i][0] == in1[0] or in2[i][1] == in1[1]:
		print('YES')
		break
else:
	print('NO')


a = input()
arr = list(map(str, input().split()))
aa = a[0]
bb = a[1]
req = [aa, bb]
f = 0
for i in arr:
	x = i[0]
	y = i[1]
	if x in req or y in req:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


tc = input()
hc = input().split(' ')
answer = 'NO'
for rhc in hc:
	if rhc[0] == tc[0]:
		answer = 'YES'
for shc in hc:
	if shc[1] == tc[1]:
		answer = 'YES'
print(answer)


g = input()
hand = list(input().split())
g_r = g[0]
g_s = g[1]
c = 0
for card in hand:
	if card[0] == g_r or card[1] == g_s:
		c += 1
if c > 0:
	print('YES')
else:
	print('NO')


x = input()
y = input().split()
v = x[0]
t = x[1]
PLAY = []
for a in y:
	if a[0] == v or a[1] == t:
		PLAY.append(a)
		break
if PLAY == []:
	print('NO')
else:
	print('YES')


table = input()
hand = str(input()).split()

def bool_answer():
	for card in hand:
		if card[0] == table[0] or card[1] == table[1]:
			return True
	return False
bool = bool_answer()
if bool:
	print('YES')
else:
	print('NO')


t = input()
cards = input().split()
for i in cards:
	if i[0] == t[0] or i[1] == t[1]:
		print('YES')
		exit()
print('NO')


the = input()
my_cards = input().strip()
res = 'NO'
for item in my_cards:
	if item[0] == the[0] or item[-1] == the[-1]:
		res = 'YES'
print(res)


s = input()
a = list(input().split(' '))
c = 1
for i in range(5):
	if a[i][0] == s[0]:
		print('YES')
		c = 0
		break
	elif a[i][1] == s[1]:
		print('YES')
		c = 0
		break
if c == 1:
	print('NO')
5


i = input()
Str = input()
x = i[0]
y = i[1]
if Str.count(x) >= 1 or Str.count(y) >= 1:
	print('YES')
else:
	print('NO')


table_card = input()
your_card = list(map(str, input().split()))
counter = 0
for x in your_card:
	if table_card[0] == x[0] or table_card[1] == x[1]:
		print('YES')
		break
	counter += 1
if counter == 5:
	print('NO')


(a, b) = input()
for (c, d) in input().split():
	if a == c or b == d:
		print('YES')
		break
else:
	print('NO')


card = input()
a = input().split()
card = list(card)
flag = 0
for i in range(5):
	aux = a[i]
	aux = list(aux)
	if aux[0] == card[0] or aux[1] == card[1]:
		flag = 1
		break
	else:
		continue
if flag == 1:
	print('YES')
else:
	print('NO')


m = list(input())
print('YES' if len([i for i in [list(i) for i in input().split(' ')] if len([j for j in i if j in m])]) else 'NO')


x = input().strip()
y = list(map(str, input().split(' ')))
flag = False
for k in y:
	if k[0] == x[0] or k[1] == x[1]:
		flag = True
if flag == True:
	print('YES')
else:
	print('NO')


c = input()
s = input().split()
ans = 'NO'
for i in s:
	if i[0] == c[0] or i[1] == c[1]:
		ans = 'YES'
		break
print(ans)


card = str(input())
coloda = str(input())
i = 0
flag = str()
while i < len(coloda):
	if card[0] == coloda[i] or card[1] == coloda[i]:
		flag = 'YES'
	else:
		flag2 = 'NO'
	i += 1
if flag == 'YES':
	print(flag)
else:
	print(flag2)


rank = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A']
cardSuit = ['D', 'C', 'S', 'H']
card_on_table = input()
hand = [x for x in input().split()]
rank_hand = []
card_suit = []
for i in range(len(hand)):
	rank_hand.append(hand[i][0])
	card_suit.append(hand[i][1])
if card_on_table[0] in rank_hand or card_on_table[1] in card_suit:
	print('YES')
else:
	print('NO')


key = input()
lst = list(map(str, input().split()))
flag = 0
for i in range(len(lst)):
	if key[0] == lst[i][0]:
		flag = 1
		break
	elif key[1] == lst[i][1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


(r, s) = list(input())
l = input().split()
rs = [x[0] for x in l]
ss = [x[1] for x in l]
yr = r in rs
ys = s in ss
if any([yr, ys]):
	print('YES')
else:
	print('NO')


card_on_table = input()
cards_in_hand = input().split(' ')
if card_on_table[0] in [card[0] for card in cards_in_hand] or card_on_table[1] in [card[1] for card in cards_in_hand]:
	print('YES')
else:
	print('NO')


x = input()
cards = list(map(str, input().split()))
f = 0
for i in cards:
	if x[0] == i[0] or x[1] == i[1]:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


x = str(input())
rank = x[0]
suit = x[1]
y = str(input())
l = len(y)
i = 0
while i < l:
	if rank == y[i] or suit == y[i]:
		print('YES')
		exit(0)
	else:
		i = i + 1
print('NO')


cot = input()
coh = input()
if cot[0] in coh or cot[1] in coh:
	print('YES')
else:
	print('NO')


a = input()
b = input()
c = b.split()
g = c[0]
h = c[1]
i = c[2]
j = c[3]
k = c[4]
if a[0] == g[0] or a[0] == h[0] or a[0] == i[0] or (a[0] == j[0]) or (a[0] == k[0]):
	nol = True
else:
	nol = False
if a[1] == g[1] or a[1] == h[1] or a[1] == i[1] or (a[1] == j[1]) or (a[1] == k[1]):
	satu = True
else:
	satu = False
if nol or satu:
	print('YES')
else:
	print('NO')


card = input()
hand = input().split(' ')
flag = False
for c in hand:
	if c[0] == card[0] or c[1] == card[1]:
		flag = True
print('YES') if flag else print('NO')


n = input()
var = [x for x in input().split(' ')]
n_list = [n[0], n[1]]
var_list = []
for i in var:
	for j in i:
		var_list.append(j)
if n[0] in var_list or n[1] in var_list:
	print('YES')
else:
	print('NO')


card = input()
cards = input()
for (suit, rank) in zip(cards[::3], cards[1::3]):
	if card[0] == suit or card[1] == rank:
		print('YES')
		exit()
print('NO')


s = input()
ls = list(map(str, input().split()))
for ss in ls:
	if s == ss:
		flag = 1
		break
	elif s[0] == ss[0]:
		flag = 1
		break
	elif s[1] == ss[1]:
		flag = 1
		break
	else:
		flag = 0
if flag == 1:
	print('YES')
else:
	print('NO')


def card_check(card, cards):
	for i in cards:
		if i[0] == card[0] or i[1] == card[1]:
			return 'YES'
	return 'NO'
print(card_check(input(), input().split()))


table = input()
hand = list(input().split())
table_rank = table[0]
table_suit = table[1]
found = False
for cur in hand:
	if cur[0] == table_rank or cur[1] == table_suit:
		found = True
		break
print('YES') if found else print('NO')


s = input()
s1 = s[0]
s2 = s[1]
l = list(input().split())
l1 = []
l2 = []
r = ''
for i in l:
	r += i
if s1 in r or s2 in r:
	print('YES')
else:
	print('NO')


fc = input().strip()
cards = list(filter(lambda x: x[1] == fc[1] or x[0] == fc[0], input().strip().split()))
if len(cards) > 0:
	print('YES')
else:
	print('NO')


table = input()
hand = list(map(str, input().strip().split()))
flag = 0
for i in range(len(table)):
	a = table[i]
	for j in hand:
		if j[i] == a:
			print('YES')
			flag = 1
			break
	if flag == 1:
		break
if flag == 0:
	print('NO')


n = input()
line = input().split()
sign = list()
rank = list()
for elem in line:
	rank.append(elem[0])
	sign.append(elem[1])
if n[0] in rank or n[1] in sign:
	print('YES')
else:
	print('NO')


def commonelem(x, y):
	for i in range(len(x)):
		if x[i] in y:
			return 1
	return 0
ct = str(input())
flag = 0
ch = [str(x) for x in input().split()]
for x in ch:
	if commonelem(ct, x) == 1:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


cardOnTable = input()
cardOnHand = input()
reply = ''
for x in cardOnHand:
	if cardOnTable[0] in cardOnHand or cardOnTable[1] in cardOnHand:
		reply = 'YES'
	else:
		reply = 'NO'
print(reply)


x = input()
Y = input().split()
for y in Y:
	if y[0] == x[0] or y[1] == x[1]:
		print('YES')
		break
else:
	print('NO')


start = list(str(input()))
cards = list(map(str, input().split()))
status = False
for i in cards:
	for k in list(i):
		if k == start[0] or k == start[1]:
			status = True
			break
print('YES' if status else 'NO')


def main():
	player = input()
	hand = input().split(' ')
	player_rank = player[0]
	hand_ranks = [r[0] for r in hand]
	hand_suites = [r[1] for r in hand]
	if player[0] in hand_ranks or player[1] in hand_suites:
		print('YES')
	else:
		print('NO')
main()


card = input()
arr = [i for i in filter(None, input().split(' '))]
ans = 'NO'
for i in arr:
	if i[0] == card[0] or i[1] == card[1]:
		ans = 'YES'
print(ans)


t = input()
table = list(t)
a = input().split()
a1 = list(a)
c = ''.join(a1)
card = list(c)
for m in table:
	if m in card:
		print('YES')
		break
else:
	print('NO')


cot = input()
cih = input().split()
f = 0
for i in range(0, 5):
	if cih[i][0] == cot[0]:
		f = 1
	if cih[i][1] == cot[1]:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


r = set()
s = set()
a = input()
b = input().split()
for i in b:
	r.add(i[0])
	s.add(i[1])
if a[0] in r:
	print('YES')
	exit()
if a[1] in s:
	print('YES')
	exit()
print('NO')


table = input()
hand = input().split()
play = 'NO'
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		play = 'YES'
print(play)


import sys
c = input()
hand = input().split()
for i in hand:
	if i[0] == c[0] or i[1] == c[1]:
		print('YES')
		sys.exit()
print('NO')


from sys import stdin

def find(n, k):
	for i in n:
		for j in k:
			for c in j:
				if i == c:
					return 'YES'
	return 'NO'
n = str(input())
k = [str(i) for i in stdin.readline().split()]
print(find(n, k))


import sys
a = input()
v = [str(i) for i in input().split()]
for i in range(5):
	for j in range(2):
		c = v[i]
		if a[j] == c[j]:
			print('YES')
			sys.exit()
print('NO')


table = input()
hand = input().split()
yes = 0
for i in range(5):
	temp = hand[i]
	if table[0] == temp[0]:
		yes = 1
	if table[1] == temp[1]:
		yes = 1
if yes == 1:
	print('YES')
else:
	print('NO')


N = input()
L = list(input().split())
x = 0
for i in L:
	if i[0] == N[0] or i[1] == N[1]:
		x = 1
if x:
	print('YES')
else:
	print('NO')


winner = False
x = input()
(a, b, c, d, e) = input().split()
if a[0] == x[0] or a[1] == x[1]:
	winner = True
elif b[0] == x[0] or b[1] == x[1]:
	winner = True
elif c[0] == x[0] or c[1] == x[1]:
	winner = True
elif d[0] == x[0] or d[1] == x[1]:
	winner = True
elif e[0] == x[0] or e[1] == x[1]:
	winner = True
if winner:
	print('YES')
else:
	print('NO')


a = input()
b = input()
d = b.split()
global st
st = 'NO'
for i in d:
	if i[0] == a[0] or i[1] == a[1]:
		st = 'YES'
print(st)


import re
s = input()
table = input()
if re.findall(s[0], table) or re.findall(s[1], table):
	print('YES')
else:
	print('NO')


import sys
tablecard = input()
mycards = input().split()
for card in mycards:
	if tablecard[0] == card[0] or tablecard[1] == card[1]:
		print('YES')
		sys.exit()
print('NO')


def func(x, y):
	for i in range(len(y)):
		card = y[i]
		if card[0] is x[0] or card[1] is x[1]:
			return 'YES'
	return 'NO'
x = str(input())
y = list(map(str, input().strip().split(' ')))
print(func(x, y))


t = input()
h = [s for s in input().split(' ')]
yes = False
for c in h:
	if c[0] == t[0] or c[1] == t[1]:
		yes = True
		break
if yes:
	print('YES')
else:
	print('NO')


import sys
output = 'NO'
a = []
table = sys.stdin.readline().strip()
tableRank = table[0]
tableSuit = table[1]
a = sys.stdin.readline().split()
for i in a:
	if i[0] == tableRank or i[1] == tableSuit:
		output = 'YES'
print(output)


s = input()
li = input().split()

def program():
	for i in li:
		if i[0] == s[0] or i[1] == s[1]:
			print('YES')
			return
	print('NO')
	return
program()


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nlargest, nsmallest, _heapify_max, _heapreplace_max
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as c
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

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

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
host = data()
arr = sl()
for i in arr:
	if i[1] == host[1] or i[0] == host[0]:
		out('YES')
		exit()
out('NO')


import sys
input = sys.stdin.readline
s = input()
f = input()
if s[0] in f or s[1] in f:
	print('YES')
else:
	print('NO')


(a, b) = list(input())
data = [x for x in input().split(' ')]
flag = True
for x in data:
	(m, n) = (x[0], x[1])
	if m == a or n == b:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


def CanPlay(Card, MyCards):
	Symbols = [card[0] for card in MyCards]
	Suit = [card[1] for card in MyCards]
	if Card[0] in Symbols or Card[1] in Suit:
		return 'YES'
	else:
		return 'NO'
Card = input()
MyCards = [i for i in input().split()]
print(CanPlay(Card, MyCards))


a = input()
(a1, a2, a3, a4, a5) = input().split()
if a[0] == a1[0] or a[0] == a2[0] or a[0] == a3[0] or (a[0] == a4[0]) or (a[0] == a5[0]):
	print('YES')
elif a[1] == a1[1] or a[1] == a2[1] or a[1] == a3[1] or (a[1] == a4[1]) or (a[1] == a5[1]):
	print('YES')
else:
	print('NO')


fi = input('')
secondinput = input('')
si = secondinput.split()
n = len(si)
F = False
for i in range(n):
	if fi[0] == si[i][0] or fi[1] == si[i][1]:
		F = True
if F == True:
	print('YES')
else:
	print('NO')


card = input()
list1 = input().split()
bool = 0
for i in range(5):
	if list1[i][0] == card[0] or list1[i][1] == card[1]:
		bool = 1
		break
if bool == 1:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = ''.join(input().split())
for i in s1:
	if i in s2:
		print('YES')
		break
else:
	print('NO')


st = input()
a = input().split()
b = st[0]
c = st[1]
cond = False
for i in a:
	if i[0] == b or i[1] == c:
		cond = True
if cond:
	print('YES')
else:
	print('NO')


import sys
import math
import bisect

def main():
	s = input()
	A = input().split()
	ans = False
	for a in A:
		if s[0] == a[0]:
			ans = True
		if s[1] == a[1]:
			ans = True
	if ans:
		print('YES')
	else:
		print('NO')
main()


def check1(l, s):
	for i in l:
		if i[0] == s[0] or i[1] == s[1]:
			return 1
	return 0
a = input()
b = list(input().split())
if check1(b, a):
	print('YES')
else:
	print('NO')


n = input()
(a, b, c, d, e) = input().split()
n1 = [str(x) for x in n]
f = 0
for i in n1:
	if i in a or i in b or i in c or (i in d) or (i in e):
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


t = input()
(c, d) = zip(*input().split())
print('YES' if t[0] in c or t[1] in d else 'NO')


p = input()
p = list(p)
g = ''
s = [str(x) for x in input().split()]
for i in s:
	g += i
if g.count(p[0]) or g.count(p[-1]):
	print('YES')
else:
	print('NO')


s = input()
a = list(input().split())
v = []
for i in range(len(a)):
	if a[i][0] == s[0] or a[i][1] == s[1]:
		v.append(1)
	else:
		v.append(0)
if v.count(1) != 0:
	print('YES')
else:
	print('NO')


n = list(input())
five = set(input())

def games(n, five):
	if n[0] in five:
		print('YES')
	elif n[1] in five:
		print('YES')
	else:
		print('NO')
games(n, five)


from sys import stdin
n = stdin.readline()
a = [x for x in stdin.readline().split()]
flag = 1
for i in range(5):
	if n[0] == a[i][0]:
		print('YES')
		flag = 0
		break
	if n[1] == a[i][1]:
		print('YES')
		flag = 0
		break
if flag == 1:
	print('NO')


opened_card = input()
cards_in_hand = [x for x in input().split()]
can_play = 'NO'
for i in range(len(cards_in_hand)):
	if opened_card[0] == cards_in_hand[i][0] or opened_card[1] == cards_in_hand[i][1]:
		can_play = 'YES'
print(can_play)


card_table = input()
card_hands = list(map(str, input().split()))
count = 0
for i in card_hands:
	if i[0] == card_table[0] or i[1] == card_table[1]:
		break
	count += 1
if count == 5:
	print('NO')
else:
	print('YES')


table = list(input())
num = table[0]
suite = table[1]
l = list(input().split(' '))
found = 0
for i in range(5):
	if num in l[i]:
		found = 1
		break
	elif suite in l[i]:
		found = 1
		break
if found == 1:
	print('YES')
else:
	print('NO')


s = input()
l = list(input().split())
c = 0
for i in range(5):
	if l[i][0] == s[0] or l[i][1] == s[1]:
		c = c + 1
if c == 0:
	print('NO')
else:
	print('YES')


S = input()
for t in input().split():
	if any([a == b for (a, b) in zip(S, t)]):
		print('YES')
		exit()
print('NO')


s = input()
s2 = input().split()
for i in s2:
	for j in s:
		if j in i:
			print('YES')
			exit()
print('NO')


target = input()
cards = input().split(' ')
flag = False
for card in cards:
	if card[1] == target[1] or card[0] == target[0]:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


p = input()
flag = 0
t = input().split()
for i in t:
	if i[0] == p[0] or i[1] == p[1]:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


table_card = input()
hand_card = input()
hand_card2 = hand_card.split()
boo = False
for x in hand_card2:
	if x[0] == table_card[0] or x[1] == table_card[1]:
		boo = True
		break
if boo:
	print('YES')
else:
	print('NO')


string = input()
set_str = list(map(str, input().split()))[:5]
temp = 0
for i in set_str:
	if string[0] == i[0] or string[1] == i[1]:
		temp = 1
		break
if temp == 1:
	print('YES')
else:
	print('NO')


a1 = input()
a1 = list(a1)
a2 = input().split()
s = []
f = 0
for i in a2:
	s = list(i)
	for i in range(len(s)):
		c = s[i]
		if c in a1:
			f += 1
if f > 0:
	print('YES')
else:
	print('NO')


s1 = input()
s2 = input().split()
f = False
i = 0
while not f and i < len(s2):
	f = s2[i][0] == s1[0] or s2[i][1] == s1[1]
	i += 1
print('YES' if f else 'NO')


table_card = set(input())
hand_cards = set(input())
print('NYOE S'[bool(table_card & hand_cards)::2])


def main():
	cd = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'T': 10, 'J': 11, 'Q': 12, 'K': 13, 'A': 14}
	card = input()
	carr = input().split()
	for i in carr:
		if i[0] == card[0] or i[1] == card[1]:
			print('YES')
			return
	print('NO')
	return
main()


cardOnTable = input()
cardsInHand = input().split()
Found = False
for i in cardsInHand:
	if len(set(list(i)) & set(list(cardOnTable))) >= 1:
		Found = True
		break
if Found:
	print('YES')
else:
	print('NO')


from sys import stdin

def main():
	table = stdin.readline().strip()
	cards = [x for x in stdin.readline().strip().split()]
	band = False
	for i in range(len(cards)):
		if cards[i][0] == table[0] or cards[i][1] == table[1]:
			band = True
			break
	if band:
		print('YES')
	else:
		print('NO')
main()


c = input()
d = 0
x = input().split()
for i in range(5):
	if x[i][0] == c[0] or x[i][1] == c[1]:
		print('YES')
		d = 1
		break
if not d:
	print('NO')


table = list(input())
cards = input().split()
rank = []
suit = []
for i in cards:
	rank.append(i[0])
	suit.append(i[1])
if table[0] in rank or table[1] in suit:
	print('YES')
else:
	print('NO')


my_hand = input()
table = input().split()
for i in table:
	if my_hand[0] in i or my_hand[1] in i:
		print('YES')
		break
else:
	print('NO')


s = input()
l1 = list(input().split())
flag = 0
for item in l1:
	if item[0] == s[0]:
		flag = 1
		break
	elif item[1] == s[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
c = []
d = []
for i in b:
	c.append(i[0])
	d.append(i[1])
if a[0] in c or a[1] in d:
	print('YES')
else:
	print('NO')


target = input()
x = [x for x in input().split()]
t = []
found = False
for c in target:
	t.append(c)
for card in x:
	for c in card:
		if c == t[0] or c == t[1]:
			found = True
			break
if found:
	print('YES')
else:
	print('NO')


a = str(input())
b = str(input())
c = b.split()
d = 0
for i in c:
	if i[0] == a[0]:
		d = 1
for i in c:
	if i[1] == a[1]:
		d = 1
if d == 1:
	print('YES')
else:
	print('NO')


n = input()
m = input().split()
k = 0
for i in range(5):
	if n[0] == m[i][0]:
		k = 1
for i in range(5):
	if n[1] == m[i][1]:
		k = 1
if k == 1:
	print('YES')
else:
	print('NO')


c = input()
t = 1
lst = list(map(str, input().split(' ')))
for i in lst:
	if i[0] == c[0] or i[1] == c[1]:
		print('YES')
		t = 0
		break
if t == 1:
	print('NO')


card = list(input())
l = list(input().split())
for i in l:
	f = 0
	if card[0] in i or card[1] in i:
		print('YES')
		f = 1
		break
if f == 0:
	print('NO')


q = input()
card = input().split()
pre = []
aft = []
check = 0
for i in card:
	pre.append(i[0])
	aft.append(i[1])
if q[0] in pre:
	print('YES')
elif q[1] in aft:
	print('YES')
else:
	print('NO')


num = input()
arr = []
arr = [i for i in input().split()][:5]
k = 0
for i in range(0, len(arr)):
	if num[0] == arr[i][0] or num[1] == arr[i][1]:
		k = k + 1
if k > 0:
	print('YES')
else:
	print('NO')


k = input()
s = set()
l = list(input().split())
for i in l:
	s.add(i[0])
	s.add(i[1])
if k[0] in s or k[1] in s:
	print('YES')
else:
	print('NO')


import sys
tab = input()
card = input().split()
n = tab[0]
s = tab[1]
for i in card:
	if i[0] == n or i[1] == s:
		print('YES')
		sys.exit()
print('NO')


def solve():
	tablecard = input()
	hand = input().split()
	for card in hand:
		for (c, d) in zip(card, tablecard):
			if c == d:
				print('YES')
				return
	print('NO')
solve()


a = input()
d = [i for i in input().split()]
for i in d:
	if a[0] == i[0]:
		print('YES')
		exit(0)
	if a[1] == i[1]:
		print('YES')
		exit(0)
print('NO')


s1 = input()
s2 = list(map(str, input().split()))
l = len(s2)
i = 0
while i < l:
	if s2[i][0] == s1[0] or s2[i][1] == s1[1]:
		print('YES')
		break
	i += 1
else:
	print('NO')


def check(s, t):
	for i in s:
		if i in t:
			return True
tc = input()
pc = list(map(str, input().split()))
for j in range(5):
	if check(tc, pc[j]):
		print('YES')
		break
else:
	print('NO')


(t_rank, t_suit) = input()
find = False
for hand in input().split(' '):
	(h_rank, h_suit) = hand
	if h_rank == t_rank or h_suit == t_suit:
		print('YES')
		find = True
		break
if not find:
	print('NO')


s = input()
d = ''.join(input().split())
print('YES' if s[0] in d or s[1] in d else 'NO')


a = input().strip()
b = [x for x in input().split()]
s = 0
for i in b:
	if i[0] in a[0] or i[-1] in a[-1]:
		s += 1
		break
if s > 0:
	print('YES')
else:
	print('NO')


(n, s) = (input(), input())
print('YES' if n[0] in s or n[1] in s else 'NO')


a = input()
(b, c, d, e, f) = input().split()
karty = [b, c, d, e, f]
ahoj = 0
for i in range(len(karty)):
	for (x, y) in zip(a, karty[i]):
		if x == y:
			ahoj += 1
		else:
			pass
if ahoj > 0:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
if a[1] in [x[1] for x in b]:
	print('YES')
elif a[0] in [x[0] for x in b]:
	print('YES')
else:
	print('NO')


tab = input()
hand = input().split(' ')
f = 0
for i in range(0, 5):
	if hand[i][0] == tab[0] or hand[i][1] == tab[1]:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
hasil = 'NO'
for i in range(len(a)):
	for j in range(len(a[i])):
		if s[0] == a[i][0]:
			hasil = 'YES'
			break
		elif s[1] == a[i][1]:
			hasil = 'YES'
			break
print(hasil)


(c, d) = (input(), input())
print('YES' if c[0] in d or c[1] in d else 'NO')


i1 = input()
i2 = list(map(str, input().split()))
ans = 'NO'
for i in i2:
	if i[0] == i1[0] or i[1] == i1[1]:
		ans = 'YES'
		break
print(ans)


x = input()
h = input()
if x[0] in h or x[1] in h:
	print('YES')
else:
	print('NO')


n = input()
x1 = []
x2 = []
y = False
x = [str(i) for i in input().split()]
for i in range(5):
	x1.append(x[i][0])
	x2.append(x[i][1])
	if x1[i] == n[0] or x2[i] == n[1]:
		y = False
		break
	else:
		y = True
if y == True:
	print('NO')
else:
	print('YES')


(table_card, cards) = (input(), input().split())
print(['NO', 'YES'][any([c[0] == table_card[0] or c[1] == table_card[1] for c in cards])])


s = input()
a = list(map(str, input().split()))
flag = True
for i in range(5):
	if a[i][0] == s[0] or a[i][1] == s[1]:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


t = input()
s = [i for i in input().split()]
good = False
for i in s:
	if i[0] == t[0]:
		good = True
	if i[1] == t[1]:
		good = True
if good:
	print('YES')
else:
	print('NO')


card1 = input()
cards = input().split()
res = False
for c in cards:
	if c[0] == card1[0] or c[1] == card1[1]:
		res = True
if res == True:
	print('YES')
else:
	print('NO')


a = input()
b = input().split()
for i in range(len(b)):
	if a[1] == b[i][1] or a[0] == b[i][0]:
		print('YES')
		break
for x in range(len(b)):
	if not (a[1] == b[i][1] or a[0] == b[i][0]):
		print('NO')
		break


a = input()
b = input().split()
key = True
for i in b:
	if i[0] == a[0] or i[1] == a[1]:
		print('YES')
		key = False
		break
if key:
	print('NO')


x = input()
y = list(map(str, input().split()))
for i in range(5):
	if x[0] == y[i][0]:
		print('YES')
		break
	elif x[1] == y[i][1]:
		print('YES')
		break
	else:
		continue
else:
	print('NO')


meja = input()
tangan = input().split()
cek = -1
for i in range(len(tangan)):
	if meja[0] == tangan[i][0] or meja[1] == tangan[i][1]:
		cek = 1
		break
if cek == 1:
	print('YES')
else:
	print('NO')


card = input()
(q, m) = (card[0], card[1])
arr = [str(x) for x in input().split()]
for i in range(len(arr)):
	if q in arr[i] or m in arr[i]:
		print('YES')
		break
	if i == 4:
		print('NO')


(rank, suit) = input()
cards = input().split(' ')
ranks = set()
suits = set()
f = False
for (r, s) in cards:
	if r == rank or s == suit:
		f = True
		break
if f:
	print('YES')
else:
	print('NO')


a = input()
b = list((str(num) for num in input().strip().split()))[:5]
check = 0
for x in range(0, 5):
	for y in range(0, 2):
		if b[x][y] == a[y]:
			check = 1
			break
if check == 1:
	print('YES')
else:
	print('NO')


def cardGame(arr1, arr2):
	table = []
	hand = []
	for i in arr1:
		for j in i:
			table.append(j)
	for i in arr2:
		if i[0:1] == table[0] or i[1] == table[1]:
			return 'YES'
	return 'NO'
arr1 = [input().strip()]
arr2 = list(map(str, input().strip().split()))
print(cardGame(arr1, arr2))


t = input()
hand = list(input().split())
if any((h[0] == t[0] for h in hand)) or any((h[1] == t[1] for h in hand)):
	print('YES')
else:
	print('NO')


def main():
	card = input()
	hand = input()
	if card[0] in hand or card[1] in hand:
		print('YES')
	else:
		print('NO')
main()


cr = input()
crds = input()
if cr[0] in crds or cr[1] in crds:
	print('YES')
else:
	print('NO')


import math

def main():
	table = input()
	hand = input().split()
	for card in hand:
		if table[0] == card[0]:
			return print('YES')
		elif table[1] == card[1]:
			return print('YES')
	else:
		return print('NO')
main()


x = input()
y = list(input().split())
for yi in y:
	if yi[0] == x[0] or yi[1] == x[1]:
		print('YES')
		exit()
print('NO')


table = input()
hand = input()
if hand.__contains__(table[0]) or hand.__contains__(table[1]):
	print('YES')
else:
	print('NO')


n = input()
f = 0
for b in list(map(str, input().split())):
	if n[0] == b[0] or n[1] == b[1]:
		f = 1
if f == 1:
	print('YES')
else:
	print('NO')


t = input()
r = t[0]
s = t[1]
arr = input().split()
rank = [arr[i][0] for i in range(5)]
suit = [arr[i][1] for i in range(5)]
ans = 'NO'
if r in rank or s in suit:
	ans = 'YES'
print(ans)


a = input()
A = input().split()
t = 0
for i in range(5):
	if A[i][0] == a[0] or A[i][1] == a[1]:
		t = 1
		break
if t == 0:
	print('NO')
else:
	print('YES')


n1 = input()
n2 = list(map(str, input().split()))
l1 = list(n1)
l2 = []
for j in n2:
	for j1 in j:
		l2.append(j1)
if l1[0] in l2 or l1[1] in l2:
	print('YES')
else:
	print('NO')


card = input().strip()
cards = input().split()
can = 'NO'
for x in cards:
	if x[0] == card[0] or x[1] == card[1]:
		can = 'YES'
		break
print(can)


import sys
one = input()
hands = list(map(str, input().split()))
flag = 'NO'
for c in hands:
	if one[0] == c[0] or one[1] == c[1]:
		flag = 'YES'
		break
print(flag)
sys.stdout.flush()


x = input()
cards = input().split()

def can_play(x, cards):
	for c in cards:
		if x[0] in c or x[1] in c:
			return 'YES'
	return 'NO'
print(can_play(x, cards))


s1 = input()
s2 = input()
w = list(s1)
s = s2.split(' ')
a = 0
for y in w:
	for i in s:
		p = list(i)
		for r in p:
			if r == y:
				a = a + 1
if a == 0:
	print('NO')
else:
	print('YES')


def maumau(a, b, c, d, e, f):
	k = 'NO'
	lista = [b, c, d, e, f]
	for c in lista:
		if a[0] in c or a[1] in c:
			k = 'YES'
	return k
t = input()
q = list(map(str, input().split()))
print(maumau(t, q[0], q[1], q[2], q[3], q[4]))


card = input()
hand = input().split()
res = any(map(lambda x: x[0] is card[0] or x[-1] is card[-1], hand))
print('YES' if res else 'NO')


hand = input()
table = input()
answer = 'NO'
table_cards = table.split(' ')
for item in table_cards:
	if item[0] == hand[0] or item[1] == hand[1]:
		answer = 'YES'
print(answer)


a = str(input())
lst = input().split()
res = 'NO'
for i in range(5):
	if a[0] == lst[i][0]:
		res = 'YES'
	elif a[1] == lst[i][1]:
		res = 'YES'
print(res)


import sys
import functools
table = input().strip()
hand = input().strip().split()
found = False
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		print('YES')
		found = True
		break
if not found:
	print('NO')
sys.stdout.flush()


on_table = str(input())
in_hand = str(input()).split(' ')
can_play = any([on_table[0] in card or on_table[1] in card for card in in_hand])
print('YES' if can_play else 'NO')


c1 = input()
cards = input().split(' ')
for c in cards:
	if c[0] == c1[0] or c[1] == c1[1]:
		print('YES')
		return
print('NO')


card_down = input()
card_hand = list(input())
card_down = {card_down[0], card_down[1]}
card_hand = set((elem for elem in card_hand if elem != ' '))
flag = False
for elem in card_hand:
	if elem in card_down:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


first = str(input().strip())
hand = input().split()

def checkHand(first, hand):
	for h in hand:
		if h[0] == first[0] or h[1] == first[1]:
			return 'YES'
	return 'NO'
print(checkHand(first, hand))


table = input()
hand = input()
count = 0
for i in table:
	for j in hand:
		if i == j:
			count = count + 1
if count >= 1:
	print('YES')
else:
	print('NO')


n = input()
(f, g, h, i, j) = map(str, input().split())
if f[0] == n[0] or f[1] == n[1]:
	print('YES')
elif g[0] == n[0] or g[1] == n[1]:
	print('YES')
elif h[0] == n[0] or h[1] == n[1]:
	print('YES')
elif i[0] == n[0] or i[1] == n[1]:
	print('YES')
elif j[0] == n[0] or j[1] == n[1]:
	print('YES')
else:
	print('NO')


def split_input(card, lis):
	a = card[0]
	b = card[1]
	for i in lis:
		if i[0] == a or i[0] == b or i[1] == a or (i[1] == b):
			return 'YES'
	return 'NO'
try:
	while True:
		card = str(input())
		list_of_card = list(map(str, input().split()))
		print(split_input(card, list_of_card))
except:
	pass


def solve(card_on_table, cards_in_hand):
	for card in cards_in_hand:
		if card[0] == card_on_table[0] or card[1] == card_on_table[1]:
			return 'YES'
	return 'NO'

def main():
	card_on_table = input()
	cards_in_hand = input().split()
	print(solve(card_on_table, cards_in_hand))
main()


t = input()
me = list(input().split())
for card in me:
	if card[0] == t[0] or card[1] == t[1]:
		print('YES')
		exit()
print('NO')


s = tuple(input())
a = input()
d = a.split()
a = d[1] + d[2] + d[3] + d[4] + d[0]
a = tuple(a)
k = 0
for i in a:
	if i == s[1] or i == s[0]:
		k = k + 1
if k > 0:
	print('YES')
else:
	print('NO')


table = input()
tab = list(table)
hand = [x for x in input().split()]
handjoined = ''.join(hand)
flag = 0
for ele in tab:
	if ele in handjoined:
		flag = 1
		break
if flag == 0:
	print('NO')
else:
	print('YES')


s = input()
c = 0
sList = list(input().split())
for i in sList:
	if i[0] == s[0] or i[1] == s[1]:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


tablecard = input()
tableSet = tablecard[0]
tableRank = tablecard[1]
hand = input().split()
sets = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A']
ranks = ['D', 'C', 'S', 'H']
result = 'NO'
for card in hand:
	if card[0] == tableSet or card[1] == tableRank:
		result = 'YES'
		break
print(result)


card_table = input()
cards_hand = list(input().split(' '))
possible = False
for x in cards_hand:
	if x[0] == card_table[0] or x[1] == card_table[1]:
		possible = True
		break
if possible:
	print('YES')
else:
	print('NO')


s = input()
li = input().split()
st = str(li)
c = 0
for i in st:
	if i in s:
		c += 1
if c > 0:
	print('YES')
else:
	print('NO')


t = input()
l = list(map(str, input().split()))
flag = 0
for each in l:
	if each[0] == t[0] or each[1] == t[1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


(n, c) = input().strip()
for (n0, c0) in input().strip().split(' '):
	if n0 == n or c0 == c:
		print('YES')
		break
else:
	print('NO')


card = list(input())
ports = [list(i) for i in input().split()]
ans = False
for i in ports:
	if i[0] == card[0] or i[1] == card[1]:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


s = input()
x = 5
b = map(str, input().split())
res = 0
for i in b:
	if i[0] == s[0]:
		res = 'YES'
		break
	elif i[1] == s[1]:
		res = 'YES'
		break
	else:
		res = 'NO'
print(res)


x = input()
j = list(input().split())
c = 0
for i in range(len(j)):
	if x[0] == j[i][0]:
		c += 1
	elif x[1] == j[i][1]:
		c += 1
if c > 0:
	print('YES')
else:
	print('NO')


s = input()
ss = input().split()
flag = 0
for i in ss:
	if i[0] == s[0] or i[1] == s[1] or i[0] == s[1] or (i[1] == s[0]):
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


import sys
table_card = sys.stdin.readline().rstrip()
hand = sys.stdin.readline().rstrip().split()
rank = table_card[0]
suit = table_card[1]
output = 'NO'
for card in hand:
	if card[0] == rank or card[1] == suit:
		output = 'YES'
print(output + '\n')


c = input()
p = input()
cnt = 0
for i in range(0, 13, 3):
	if c[0] == p[i] or c[1] == p[i + 1]:
		print('YES')
		break
	else:
		cnt += 1
if cnt == 5:
	print('NO')


s = input()
a = list(map(str, input().split()))
for i in a:
	if s[:1] == i[:1] or s[1:] == i[1:]:
		print('YES')
		exit()
	else:
		continue
print('NO')


def solve(hand, table):
	for h in hand:
		if h[0] == table[0] or h[1] == table[1]:
			return 'YES'
	return 'NO'
table = input()
hand = input().split(' ')
print(solve(hand, table))


t = list(input())
m = list(input().split())
for i in range(len(m)):
	m[i] = list(m[i])
v = []
for i in range(len(m)):
	for j in range(2):
		v.append(m[i][j])
cnt = 0
for i in range(len(t)):
	for j in range(len(v)):
		if t[i] == v[j]:
			cnt += 1
if cnt > 0:
	print('YES')
else:
	print('NO')


s = input()
ar = input().split()
for x in ar:
	if x[0] == s[0] or s[1] == x[1]:
		print('YES')
		quit()
print('NO')


s = input()
s = list(s)
l = input()
l = l.split(' ')
flag = 0
for i in l:
	if i[0] == s[0]:
		flag = 1
		break
	if i[1] == s[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


s = input()
z = input()
c = 0
for i in z:
	if i in s:
		c = c + 1
		print('YES')
		break
if c == 0:
	print('NO')


a = input()
a = list(a)
on_hand = list(input())
for num in on_hand:
	try:
		on_hand.remove(' ')
	except:
		break
check = any((item in a for item in on_hand))
if check == True:
	print('YES')
else:
	print('NO')


c = input()
cards = [i for i in input().split()]
for card in cards:
	if c[0] == card[0] or c[1] == card[1]:
		print('YES')
		exit()
print('NO')


mesa = input()
hand = input().split()
result = 'NO'
for i in range(len(hand)):
	if mesa[0] == hand[i][0]:
		result = 'YES'
		break
	if mesa[1] == hand[i][1]:
		result = 'YES'
		break
print(result)


first = input()
(pf, mf) = (first[0], first[1])
general = input().split()
for (i, item) in enumerate(general):
	(p, m) = (item[0], item[1])
	if pf == p or mf == m:
		print('YES')
		break
	if i == len(general) - 1:
		print('NO')


table = input()
table = [char for char in table]
hand = input().split()
i = False
for n in hand:
	if n[1] == table[1] or n[0] == table[0]:
		i = True
		break
	else:
		i = False
if i == True:
	print('YES')
else:
	print('NO')


(s, s1, s2) = (input(), '', '')
l = list(map(str, input().split()))
for i in range(5):
	s1 += l[i][0]
	s2 += l[i][1]
if s[0] in s1 or s[1] in s2:
	print('YES')
else:
	print('NO')


c = input()
c = list(c)
h = input()
k = 0
h = h.split(' ')
for i in h:
	if i[0] == c[0] or i[1] == c[1]:
		k = 1
		break
if k == 0:
	print('NO')
else:
	print('YES')


def c(a, b):
	for i in a:
		if i in b:
			return 'YES'
	return 'NO'
a = input()
b = input()
print(c(a, b))


def find(s, li):
	for i in li:
		if s[0] == i[0]:
			return 1
		elif s[1] == 'D' and i[1] == 'D':
			return 1
		elif s[1] == 'C' and i[1] == 'C':
			return 1
		elif s[1] == 'H' and i[1] == 'H':
			return 1
		elif s[1] == 'S' and i[1] == 'S':
			return 1
	return 0
s = str(input())
li = list(map(str, input().split()))
if find(s, li):
	print('YES')
else:
	print('NO')


import re
import sys
exit = sys.exit
from bisect import bisect_left as bsl, bisect_right as bsr
from collections import Counter, defaultdict as ddict, deque
from functools import lru_cache
cache = lru_cache(None)
from heapq import *
from itertools import *
from math import inf
from pprint import pprint as pp
enum = enumerate
ri = lambda : int(rln())
ris = lambda : list(map(int, rfs()))
rln = sys.stdin.readline
rl = lambda : rln().rstrip('\n')
rfs = lambda : rln().split()
cat = ''.join
catn = '\n'.join
mod = 1000000007
d4 = [(0, -1), (1, 0), (0, 1), (-1, 0)]
d8 = [(-1, -1), (0, -1), (1, -1), (-1, 0), (1, 0), (-1, 1), (0, 1), (1, 1)]
x = rl()
a = rfs()
for y in a:
	if x[0] == y[0] or x[1] == y[1]:
		print('YES')
		exit()
print('NO')


import sys
a = input()
s = list(map(str, input().split()))
for i in s:
	if a[0] == i[0]:
		print('YES')
		sys.exit()
	elif a[1] == i[1]:
		print('YES')
		sys.exit()
print('NO')


print(('NO', 'YES')[len(set(input()) & set(input())) > 0])


awal = input()
daf = input().split()
for da in daf:
	if da[0] == awal[0] or da[1] == awal[1]:
		print('YES')
		break
else:
	print('NO')


import sys
table_card = input()
hand_card = list(input().split())
for i in hand_card:
	if i[0] == table_card[0] or i[1] == table_card[1]:
		print('YES')
		sys.exit()
print('NO')


n = input()
l = list(map(str, input().split()))
ok = 0
for x in l:
	if x[0] == n[0] or x[1] == n[1]:
		ok = 1
		break
if ok == 0:
	print('NO')
else:
	print('YES')


from math import *
from copy import *
from string import *
from sys import stdin
from itertools import *
from collections import Counter
tableCard = stdin.readline()
hand = list(map(str, input().split()))
ans = 'NO'
for i in range(len(hand)):
	if hand[i][0] == tableCard[0] or hand[i][1] == tableCard[1]:
		ans = 'YES'
		break
print(ans)


a = input()
ans = 'NO'
bs = input().split()
for b in bs:
	for i in range(2):
		if a[i] == b[i]:
			ans = 'YES'
print(ans)


first_card = input()
cards = input()
if first_card[0] in cards or first_card[1] in cards:
	print('YES')
else:
	print('NO')


n = input()
h = input().split()
count = 0
for item in h:
	if item[0] == n[0] or item[1] == n[1]:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


target = input()
cards = input()
if target[0] in cards or target[1] in cards:
	print('YES')
else:
	print('NO')


import pdb
x = input().upper()
(*y,) = map(str, input().split())
k = ''.join(y)
print('YES' if x[0] in k or x[1] in k else 'NO')


table = list(map(str, list(input())))
hand = list(map(str, list(input())))
if table[0] in hand or table[1] in hand:
	print('YES')
else:
	print('NO')


base = list((char for char in input()))
cards = list(map(str, input().split()))
flag = 0
for _ in cards:
	if base[0] in _ or base[1] in _:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


card_on_table = input('')
cards_in_hand = list(input('').split())
can_play = 'NO'
for index in range(0, 2):
	for card in cards_in_hand:
		if card[index] == card_on_table[index]:
			can_play = 'YES'
print(can_play)


(a, b) = (input(), input().split(' '))
print(['NO', 'YES'][bool(sum([a[__] in set((_[__] for _ in b)) for __ in {0, 1}]))])


def three_numbers():
	numbers = list(map(int, input().split(sep=' ')))
	m = max(numbers)
	for i in numbers:
		if i != m:
			print(m - i, end=' ')

def gen_and_card_game():
	card = input()
	my_cards = list(input().split(sep=' '))
	for i in my_cards:
		if i[0] == card[0] or i[1] == card[1]:
			print('YES')
			break
	else:
		print('NO')
gen_and_card_game()


card = input()
a = input()
print('YES' if card[0] in a or card[1] in a else 'NO')


s = input()
hand = input().split()
res = 'NO'
for k in hand:
	if k[0] in s or k[1] in s:
		res = 'YES'
		break
print(res)


a = input()
l = list(input().split())
rank = []
mast = []
for i in range(len(l)):
	rank.append(l[i][0])
	mast.append(l[i][1])
mast1 = a[1]
rank1 = a[0]
if mast1 in mast or rank1 in rank:
	print('YES')
else:
	print('NO')


n = input()
ontable = list(n)
a = list(input().split())
for i in range(5):
	our = list(a[i])
	if ontable[0] == our[0]:
		print('YES')
		break
	elif ontable[1] == our[1]:
		print('YES')
		break
else:
	print('NO')


flag = 0
n = input()
a = list(input().split())
for val in a:
	if val[0] == n[0] or val[1] == n[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


target = input()
cards = input().split()
output = 'NO'
for card in cards:
	if target[0] == card[0] or target[1] == card[1]:
		output = 'YES'
print(output)


from sys import stdin, stdout
table = stdin.readline()
cards = stdin.readline()
if table[0] in cards or table[1] in cards:
	stdout.write('YES\n')
else:
	stdout.write('NO\n')


a = input()
q = input()
s = 0
for i in (q[0], q[3], q[6], q[9], q[12]):
	if i == a[0]:
		s = 1
for i in (q[1], q[4], q[7], q[10], q[13]):
	if i == a[1]:
		s = 1
if s == 1:
	print('YES')
else:
	print('NO')


s = input()
s2 = input()
print('YES' if s[0] in s2 or s[1] in s2 else 'NO')


import sys
table_card = sys.stdin.readline()
cards_in_hand = sys.stdin.readline().split()
for card in cards_in_hand:
	if card[0] == table_card[0] or card[1] == table_card[1]:
		print('YES')
		exit()
print('NO')


table = input()
hand = list(input().split())
answer = 'NO'
for i in range(5):
	if hand[i][0] == table[0] or hand[i][1] == table[1]:
		answer = 'YES'
print(answer)


def playcard():
	table = input()
	hands = input().split()
	for hand in hands:
		if hand[0] == table[0] or hand[1] == table[1]:
			print('YES')
			return
	print('NO')
playcard()


s = input()
k = 0
(s1, s2, s3, s4, s5) = map(str, input().split())
if s1[0] == s[0] or s1[1] == s[1] or s2[0] == s[0] or (s2[1] == s[1]) or (s3[0] == s[0]) or (s3[1] == s[1]) or (s4[0] == s[0]) or (s4[1] == s[1]) or (s5[0] == s[0]) or (s5[1] == s[1]):
	k = 1
if k == 1:
	print('YES')
else:
	print('NO')


x = input()
y = input()
y = y.split()
flag = 0
first = x[0]
second = x[1]
for i in y:
	if first == i[0]:
		flag = 1
for i in y:
	if second == i[1]:
		flag = 1
if flag == 0:
	print('NO')
else:
	print('YES')


on_table = input()
on_table_rank = on_table[0]
on_table_suite = on_table[1]
hand_rank = []
hand_suite = []
hand = input()
tokens = hand.split(' ')
for token in tokens:
	hand_rank.append(token[0])
	hand_suite.append(token[1])
if on_table_rank in hand_rank or on_table_suite in hand_suite:
	print('YES')
else:
	print('NO')


print('YNEOS'[not set(input()) & set(input())::2])


t = input()
t0 = t[0]
t1 = t[1]
(a, b, c, d, e) = list(input().split())
(a0, b0, c0, d0, e0) = (a[0], b[0], c[0], d[0], e[0])
(a1, b1, c1, d1, e1) = (a[1], b[1], c[1], d[1], e[1])
if a0 == t0 or b0 == t0 or c0 == t0 or (d0 == t0) or (e0 == t0) or (a1 == t1) or (b1 == t1) or (c1 == t1) or (d1 == t1) or (e1 == t1):
	print('YES')
else:
	print('NO')


import collections, atexit, math, sys, bisect
sys.setrecursionlimit(1000000)

def getIntList():
	return list(map(int, input().split()))
try:
	import numpy

	def dprint(*args, **kwargs):
		print(*args, file=sys.stderr)
	dprint('debug mode')
except Exception:

	def dprint(*args, **kwargs):
		pass
inId = 0
outId = 0
if inId > 0:
	dprint('use input', inId)
	sys.stdin = open('input' + str(inId) + '.txt', 'r')
if outId > 0:
	dprint('use output', outId)
	sys.stdout = open('stdout' + str(outId) + '.txt', 'w')
	atexit.register(lambda : sys.stdout.close())
z = input()
z1 = input().split()
for x in z1:
	if x[0] == z[0] or x[1] == z[1]:
		print('YES')
		sys.exit()
print('NO')


ontable = list(input())
cards = input().split()
for card in cards:
	card = list(card)
	if card[0] == ontable[0] or card[1] == ontable[1]:
		print('YES')
		exit(0)
print('NO')


fl = input().rstrip().split()
a = fl[0]
hand = input().rstrip().split()
trigger = False
for i in range(5):
	if hand[i][0] == a[0] or hand[i][1] == a[1]:
		print('YES')
		trigger = True
		break
if trigger == False:
	print('NO')


l = []
s = input()
cards = input()
flag = 0
for a in cards.split():
	l.append(a)
for a in range(len(l)):
	if l[a].count(s[0]):
		flag = 1
	if l[a].count(s[1]):
		flag = 1
print('YES') if flag == True else print('NO')


card_table = input()
cards_hand = input().split()
ans = 'NO'
for card in cards_hand:
	if card[0] == card_table[0] or card[1] == card_table[1]:
		ans = 'YES'
		break
print(ans)


m = input()
a = list(input().split())
for i in range(0, 5):
	if m[0] == a[i][0] or m[1] == a[i][1]:
		print('YES')
		break
else:
	print('NO')


table = input('')
ls = [each for each in input('').split(' ')]
ranks = []
types = []
for each in ls:
	if each[0] not in ranks:
		ranks.append(each[0])
	if each[1] not in types:
		types.append(each[1])
if table[0] in ranks or table[1] in types:
	print('YES')
else:
	print('NO')


from sys import exit
n = input()
a = [str(i) for i in input().split()]
for i in range(len(a)):
	if a[i][0] == n[0] or a[i][1] == n[1]:
		print('YES')
		exit()
print('NO')


v = input()
(a, b, c, d, e) = input().split(' ')
if v[0] == a[0] or v[1] == a[1] or v[0] == b[0] or (v[1] == b[1]) or (v[0] == c[0]) or (v[1] == c[1]) or (v[0] == d[0]) or (v[1] == d[1]) or (v[0] == e[0]) or (v[1] == e[1]):
	print('YES')
else:
	print('NO')


t_card = input()
my_card = input().split(' ')
output = 'NO'
for card in my_card:
	if card[0] == t_card[0] or card[1] == t_card[1]:
		output = 'YES'
		break
print(output)


tc = input()
for i in input().split():
	if tc[0] in i or tc[1] in i:
		print('YES')
		break
else:
	print('NO')


s = input()
lst = input().split()
t = True
for i in lst:
	if i[0] == s[0] or i[1] == s[1]:
		t = False
		print('YES')
		break
if t:
	print('NO')


table_card = input()
my_cards = input()
my_cards_rank = set([x[0] for x in my_cards.split(' ')])
my_cards_suit = set([x[1] for x in my_cards.split(' ')])
if table_card[0] in my_cards_rank or table_card[1] in my_cards_suit:
	print('YES')
else:
	print('NO')


s1 = input()
l = list(input().split())
flag = True
for i in l:
	if i[0] == s1[0] or i[1] == s1[1]:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


first = input()
(k1, k2, k3, k4, k5) = list(map(str, input().split()))
if k1[0] == first[0] or k2[0] == first[0] or k3[0] == first[0] or (k4[0] == first[0]) or (k5[0] == first[0]) or (k1[1] == first[1]) or (k2[1] == first[1]) or (k3[1] == first[1]) or (k4[1] == first[1]) or (k5[1] == first[1]):
	print('YES')
else:
	print('NO')


def main():
	card = input()
	hand = input().split(' ')
	for i in range(5):
		if hand[i][0] == card[0] or hand[i][1] == card[1]:
			print('YES')
			return
	print('NO')
main()


a = str(input())
b = str(input())
a += b.replace(' ', '')
existe = 0
for i in range(2, 12, 1):
	if a[0] == a[i] or a[1] == a[i]:
		existe = 1
if existe:
	print('YES')
else:
	print('NO')


s = input()
flag = 0
strs = input().split()
for i in strs:
	if i[0] == s[0] or i[1] == s[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


ss = list(input())
lis = list(map(str, input().split()))
flag = 0
for i in range(5):
	if ss[0] == lis[i][0] or ss[1] == lis[i][1]:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
l = list(map(str, input().split()))
r = ''.join(l)
if s[0] in r or s[1] in r:
	print('YES')
else:
	print('NO')


def can_make_move(table_card, hand_cards):
	for card in hand_cards:
		if card[0] == table_card[0] or card[1] == table_card[1]:
			return True
	return False
table_card = input()
hand_cards = input().split()
if can_make_move(table_card, hand_cards):
	print('YES')
else:
	print('NO')


s = input()
c = input()
c = c.replace(' ', '', len(c.split()) - 1)
if s[0] in c or s[1] in c:
	print('YES')
else:
	print('NO')


c = input()
m = input()
if c[1] in m or c[0] in m:
	print('YES')
else:
	print('NO')


zhuo = input()
num = 0
alist = input().split()
for i in range(5):
	if zhuo[0] == alist[i][0]:
		num = 1
for k in range(5):
	if zhuo[1] == alist[k][1]:
		num = 1
if num == 1:
	print('YES')
else:
	print('NO')


import sys
suit = ['D', 'C', 'S', 'H']
rank = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
card_hand = []
card_table = input()
card_hand_input = input()
card_hand = card_hand_input.split()
for card in card_hand:
	if card[0] == card_table[0]:
		print('YES')
		sys.exit()
	if card[1] == card_table[1]:
		print('YES')
		sys.exit()
print('NO')


tableCard = list(input())
myCard = [x for x in input().split()]
suit = []
rank = []
for a0 in myCard:
	a0 = list(a0)
	suit.append(a0[1])
	rank.append(a0[0])
if tableCard[0] in rank or tableCard[1] in suit:
	print('YES')
else:
	print('NO')


table = input()
hand = input().split()
done = False
for h in hand:
	if h[0] == table[0] or h[1] == table[1]:
		print('YES')
		done = True
		break
if done == False:
	print('NO')


i = input()
(a, b, r, d, e) = map(str, input().split())
h = []
ca = []
cf = []
st = ''
for c in i:
	h.append(c)
for c in (a, b, r, d, e):
	ca.append(c)
for c in ca:
	for i in c:
		cf.append(i)
for x in h:
	if x in cf:
		st = 'YES'
		break
	else:
		st = 'NO'
print(st)


s = input()
s1 = input()
s1 = list(s1)
l = 0
for i in range(0, len(s1), 3):
	if s1[i] == s[0] or s1[i + 1] == s[1]:
		l += 1
if l == 0:
	print('NO')
else:
	print('YES')


s = input()
l = input().split()
flag = False
for x in l:
	if x[0] == s[0] or x[1] == s[1]:
		print('YES')
		flag = True
		break
if flag is False:
	print('NO')


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
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 [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 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 main():
	s = S()
	a = LS()
	for c in a:
		for i in range(2):
			if c[i] == s[i]:
				return 'YES'
	return 'NO'
print(main())


table = input()
hand = list(input().split())
for h in hand:
	if h[0] == table[0] or h[1] == table[1]:
		print('YES')
		quit()
print('NO')


key = str(input())
string = str(input())
if string.find(key[0]) >= 0 or string.find(key[1]) > 0:
	print('YES')
else:
	print('NO')


notFound = True
a = list(input())
b = input().split()
for x in b:
	c = list(x)
	if c[0] == a[0] or c[1] == a[1]:
		print('YES')
		notFound = False
		break
if notFound:
	print('NO')


table = input()
arr = list(map(str, input().split()))
rank = []
deck = []
for i in arr:
	rank.append(i[0])
	deck.append(i[1])
if table[0] in rank:
	print('YES')
elif table[1] in deck:
	print('YES')
else:
	print('NO')


C = input()
aaaa = input()
if C[0] in aaaa or C[1] in aaaa:
	print('YES')
else:
	print('NO')


n = input()
m = input()
if n[0] in m or n[1] in m:
	print('YES')
else:
	print('NO')


(table_number, table_suit) = input()
player = input()
print(('NO', 'YES')[table_number in player or table_suit in player])


card = input()
table = map(str, input().split(' '))
f = 0
for i in table:
	if card[0] in i or card[1] in i:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


def main():
	flag = False
	card = input()
	list = input()
	lists = list.split(' ')
	for line in lists:
		if line[0] == card[0]:
			flag = True
			break
		elif line[1] == card[1]:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')
main()


stol = input()
ruca = input().split()
for el in ruca:
	if stol[0] in el or stol[1] in el:
		print('YES')
		break
else:
	print('NO')


tableCard = input()
myCards = input()

def canPlay(mycards, rank, suit):
	if rank in myCards or suit in myCards:
		return 'YES'
	return 'NO'
(rank, suit) = (tableCard[0], tableCard[-1])
print(canPlay(myCards, rank, suit))


tab = list(input())
m = input().split()
c = 0
for i in m:
	if i[1] == tab[1] or i[0] == tab[0]:
		c += 1
if c >= 1:
	print('YES')
else:
	print('NO')


a = input()
x = [s for s in input().split()]
d = False
for i in x:
	if a[0] == i[0]:
		print('YES')
		d = True
		break
	elif a[1] == i[1]:
		print('YES')
		d = True
		break
if not d:
	print('NO')


card_on_ground = input()
hand = input()
if card_on_ground[0] in hand or card_on_ground[1] in hand:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
ans = False
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		ans = True
		break
if ans:
	print('YES')
else:
	print('NO')


a = input()
(c1, c2, c3, c4, c5) = input().split()
i = 5
if a[0] == c1[0] or a[0] == c2[0] or a[0] == c3[0] or (a[0] == c4[0]) or (a[0] == c5[0]) or (a[1] == c1[1]) or (a[1] == c2[1]) or (a[1] == c3[1]) or (a[1] == c4[1]) or (a[1] == c5[1]):
	val = True
else:
	val = False
if val:
	print('YES')
else:
	print('NO')


a = input()
b = input()
j = a[1]
q = a[0]
l = 0
if q == b[0] or q == b[3] or q == b[6] or (q == b[9]) or (q == b[12]):
	l += 1
if j == b[1] or j == b[4] or j == b[7] or (j == b[10]) or (j == b[13]):
	l += 1
if l < 1:
	print('NO')
if l >= 1:
	print('YES')


def main():
	l = input()
	h = input().split(' ')
	h = list(zip(*h))
	for i in range(len(l)):
		if l[i] in h[i]:
			print('YES')
			return
	print('NO')
main()


a = input()
x = list(input().split())
f = False
for i in range(0, 5):
	s = x[i]
	if s[0] == a[0] or s[1] == a[1]:
		f = True
		break
if f:
	print('YES')
else:
	print('NO')


table = input()
hand = list(input().split())
yes = 0
for i in hand:
	if i[0] == table[0] or i[1] == table[1]:
		print('YES')
		yes = 1
		break
if yes == 0:
	print('NO')


import math
(a, b) = map(str, input())
s = []
n = []
y = list(map(str, input().split()))
for i in range(0, 5):
	s.append(y[i][0])
	n.append(y[i][1])
	if s[i] == a or n[i] == b:
		print('YES')
		break
	elif i == 4:
		print('NO')


def isOkay(card, cards):
	for c in cards:
		if c[0] == card[0] or c[1] == card[1]:
			return 'YES'
	return 'NO'
cardOne = input()
fiveCards = list(input().split())
print(isOkay(cardOne, fiveCards))


s = str(input())
a = [str(i) for i in input().split()]
flag = 0
for i in range(0, len(a)):
	if a[i][0] == s[0] or a[i][1] == s[1]:
		flag = 1
		break
if flag == 1:
	print('YES')
else:
	print('NO')


import sys, os.path
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
	sys.stdout = open('out.txt', 'w')
a = input()
b = input()
if a[0] in b:
	print('YES')
elif a[1] in b:
	print('YES')
else:
	print('NO')


n = input()
l = []
la = []
lb = []
lc = []
ld = []
le = []
for i in range(len(n)):
	l.append(n[i])
s = input().split()
a = s[0]
b = s[1]
c = s[2]
d = s[3]
e = s[4]
for i in range(len(a)):
	la.append(a[i])
for i in range(len(b)):
	lb.append(b[i])
for i in range(len(c)):
	lc.append(c[i])
for i in range(len(d)):
	ld.append(d[i])
for i in range(len(e)):
	le.append(e[i])
if l[0] == la[0] or l[1] == la[1] or l[0] == lb[0] or (l[1] == lb[1]) or (l[0] == lc[0]) or (l[1] == lc[1]) or (l[0] == ld[0]) or (l[1] == ld[1]) or (l[0] == le[0]) or (l[1] == le[1]):
	print('YES')
else:
	print('NO')


t = input()
str = input()
if t[0] in str or t[1] in str:
	print('YES')
else:
	print('NO')


cardtable = input()
cardhand = input().split()
count = 0
for i in cardhand:
	if i[1] == cardtable[1]:
		print('YES')
		count = 1
		break
	if i[0] == cardtable[0]:
		print('YES')
		count = 1
		break
if count == 0:
	print('NO')


(a, s) = input()
d = input()
print(('NO', 'YES')[a in d or s in d])


on_table = input()
on_hand = input().split()
for card in on_hand:
	if card[0] == on_table[0] or card[1] == on_table[1]:
		print('YES')
		exit(0)
print('NO')


(s1, s2) = input()
s = input().split()
for i in s:
	if i[0] == s1 or i[1] == s2:
		print('YES')
		exit()
print('NO')


ct = input()
(c1, c2, c3, c4, c5) = input().split()
s = c1 + ' ' + c2 + ' ' + c3 + ' ' + c4 + ' ' + c5
ans = 0
for i in s.split():
	if ct[0] == i[0] or ct[1] == i[1]:
		ans += 1
if ans > 0:
	print('YES')
else:
	print('NO')


(x, y) = [c for c in input()]
c = [w for w in input().split()]
for cc in c:
	[x1, y1] = [i for i in cc]
	if x1 == x or y1 == y:
		print('YES')
		exit()
print('NO')


card = list(input())
myCards = list(input().split(' '))
l = len(myCards)
for i in range(l):
	if myCards[i][0] == card[0]:
		print('YES')
		exit()
	if myCards[i][1] == card[1]:
		print('YES')
		exit()
print('NO')


text = input()
lst = input().split()
one = text[0]
two = text[1]
for i in lst:
	if one == i[0] or two == i[1]:
		print('YES')
		break
else:
	print('NO')


a = input()
b = input().split()
fin = False
for i in range(5):
	if b[i][0] == a[0] or b[i][1] == a[1]:
		print('YES')
		fin = True
		break
if not fin:
	print('NO')


(a, b) = tuple(input())
l = input().split(' ')
for x in l:
	(c, d) = tuple(x)
	if a == c or b == d:
		print('YES')
		exit(0)
print('NO')


s = input()
f = 0
l = input().split(' ')
for i in l:
	if s[0] in i[0]:
		f = 1
		break
	elif s[1] in i[1]:
		f = 1
		break
if f == 1:
	print('YES')
else:
	print('NO')


n = list(input())
lis = list(map(str, list(input().split())))
flag = False
for i in lis:
	if i[0] in n or i[1] in n:
		print('YES')
		flag = True
		break
if not flag:
	print('NO')


from sys import stdin, setrecursionlimit
setrecursionlimit(10 ** 6)
input = stdin.readline
s = input().rstrip()
a = list(input().split())
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		break
else:
	print('NO')


def cards():
	card = input()
	cih = input()
	for l in card:
		if l in cih:
			print('YES')
			return
	print('NO')
cards()


s = input()
a = list(map(str, input().split()))
suit = s[1]
num = s[0]
for i in a:
	if i[0] == num:
		print('YES')
		exit()
	if i[1] == suit:
		print('YES')
		exit()
print('NO')


cMesa = input()
(c1, c2, c3, c4, c5) = list(map(str, input().split()))
if c1[1] == cMesa[1] or c1[0] == cMesa[0]:
	resul = 'YES'
elif c2[1] == cMesa[1] or c2[0] == cMesa[0]:
	resul = 'YES'
elif c3[1] == cMesa[1] or c3[0] == cMesa[0]:
	resul = 'YES'
elif c4[1] == cMesa[1] or c4[0] == cMesa[0]:
	resul = 'YES'
elif c5[1] == cMesa[1] or c5[0] == cMesa[0]:
	resul = 'YES'
else:
	resul = 'NO'
print(resul)


table_card = input()
my_cards = input()
if table_card[0] in my_cards or table_card[1] in my_cards:
	print('YES')
else:
	print('NO')


s = input()
d = set()
d.add(s[0])
d.add(s[1])
a = input().split()
for c in a:
	if c[0] in d or c[1] in d:
		print('YES')
		exit(0)
print('NO')


card = list(input())
your_card = list(input())
f = card[0]
z = card[1]
for i in your_card:
	if f in your_card:
		print('YES')
	elif z in your_card:
		print('YES')
	else:
		print('NO')
	break


s = input()
s1 = [i for i in input().split()]
ss = ''.join(s1)
k = 'NO'
if s[0] in ss or s[1] in ss:
	k = 'YES'
print(k)


table = str(input())
n = list(map(str, input().split()))
if table[0] in [a[0] for a in n]:
	print('YES')
elif table[1] in [a[1] for a in n]:
	print('YES')
else:
	print('NO')


t = input()
your = input().split()
print(['NO', 'YES'][sum((1 for i in your if t[0] == i[0] or t[1] == i[1])) > 0])


s = input()
h = input()
if s[0] in h or s[1] in h:
	print('YES')
else:
	print('NO')


card = input()
cards = [i for i in input().split()]
flag = 0
for i in cards:
	if i[0] == card[0]:
		flag = 1
		break
	elif i[1] == card[1]:
		flag = 1
		break
if flag:
	print('YES')
else:
	print('NO')


s = input()
a = input().split()
m = set()
for x in a:
	m.add(x[0])
	m.add(x[1])
if s[0] in m or s[1] in m:
	print('YES')
else:
	print('NO')


s = input()
l = input().split()
for i in range(len(l)):
	if s[0] == l[i][0] or s[0] == l[i][1] or s[1] == l[i][0] or (s[1] == l[i][1]):
		print('YES')
		exit()
print('NO')


card = input()
cards = list(map(str, input().split(' ')))
found = False
for plays in cards:
	if plays[0] == card[0] or plays[1] == card[1]:
		found = True
if found:
	print('YES')
else:
	print('NO')


def match(L, s):
	for i in range(0, 5):
		if s[0] == L[i][0] or s[1] == L[i][1]:
			return 'YES'
	return 'NO'
s = str(input())
L = input().split()
print(match(L, s))


table = input()
hand = []
possible = 0
hand = [i for i in input().split()]
for card in hand:
	if card[0] == table[0] or card[1] == table[1]:
		possible = 1
if possible == 1:
	print('YES')
else:
	print('NO')


def is_gamePossible(cardOnTable, yourCards):
	for i in yourCards:
		if i[0] == cardOnTable[0] or i[1] == cardOnTable[1]:
			return 'YES'
	return 'NO'
cardOnTable = input()
yourCards = list(input().split())
print(is_gamePossible(cardOnTable, yourCards))


x = input()
y = input()
a = y.split(' ')
n = 0
for i in range(5):
	if a[i][0] == x[0] or a[i][1] == x[1]:
		print('YES')
		break
	else:
		n = n + 1
if n == 5:
	print('NO')


from sys import stdin, stdout

def main():
	table_card = stdin.readline()
	hand_cards = stdin.readline().split()
	for hand_card in hand_cards:
		if hand_card[0] == table_card[0] or hand_card[1] == table_card[1]:
			stdout.write('YES\n')
			return
	stdout.write('NO\n')
main()


n = input()
b = list(input().split())
for a in range(len(b)):
	if b[a][0:1] == n[0:1] or b[a][1:2] == n[1:2]:
		s = 'YES'
		break
	else:
		s = 'NO'
print(s)


table = list(map(str, input()))
hand = list(map(str, input()))
temp_list = []
for i in hand:
	if i == ' ':
		hand.remove(i)
	else:
		pass
for i in table:
	for j in hand:
		if i == j:
			temp_list.append(i)
		else:
			pass
if len(temp_list) == 0:
	print('NO')
else:
	print('YES')


TN = 1

def solution():
	(a, b) = list(input())
	l = list(input().split())
	ans = 'NO'
	for i in range(5):
		if l[i][0] == a or l[i][1] == b:
			ans = 'YES'
	print(ans)
while TN != 0:
	solution()
	TN -= 1


cartaMesa = input()
cartasMano = input()
cartasManoLista = cartasMano.split()
z = 0
for i in range(5):
	x = cartasManoLista[i][0]
	y = cartasManoLista[i][1]
	if cartaMesa[0] == x or cartaMesa[1] == y:
		z = 1
if z == 1:
	print('YES')
else:
	print('NO')


s = input()
l = list(input().split())
flag = False
for i in range(5):
	if l[i][0] == s[0] or l[i][1] == s[1]:
		flag = True
		break
if flag == True:
	print('YES')
else:
	print('NO')


import sys
c = sys.stdin.readline().split('\n')[0]
h = sys.stdin.readline().split()
a = True
for i in range(5):
	if h[i][1] == c[1] or h[i][0] == c[0]:
		print('YES')
		a = False
		break
if a:
	print('NO')


tbl = input()
first = tbl[0].lower()
second = tbl[1].lower()
hand = input()
a_1 = hand[0].lower()
a_2 = hand[1].lower()
b_1 = hand[3].lower()
b_2 = hand[4].lower()
c_1 = hand[6].lower()
c_2 = hand[7].lower()
d_1 = hand[9].lower()
d_2 = hand[10].lower()
e_1 = hand[12].lower()
e_2 = hand[13].lower()
if first == a_1 or first == b_1 or first == c_1 or (first == d_1) or (first == e_1):
	print('YES')
elif second == a_2 or second == b_2 or second == c_2 or (second == d_2) or (second == e_2):
	print('YES')
else:
	print('NO')


m = input()
l = list(input().split())
y = len(l)
c = 0
for i in range(y):
	if m[0] == l[i][0] or m[1] == l[i][1]:
		c = 1
		break
if c == 1:
	print('YES')
else:
	print('NO')


desk = tuple(input())
hand = map(tuple, input().split())
for card in hand:
	if card[0] == desk[0] or card[1] == desk[1]:
		print('YES')
		break
else:
	print('NO')


table_card = input()
hand = input()
hand_ls = hand.split()
for card in hand_ls:
	if table_card[0] == card[0] or table_card[1] == card[1]:
		flag = 1
		break
	else:
		flag = 0
if flag == 1:
	print('YES')
else:
	print('NO')


def sol(t, h):
	for i in h:
		for j in t:
			if j in i:
				return True
t = [c for c in input()]
h = [[i for i in c] for c in input().split()]
print('YES' if sol(t, h) else 'NO')


d = input()
t = input().split()
if d[0] in [card[0] for card in t] or d[1] in [card[1] for card in t]:
	print('YES')
else:
	print('NO')


def match(card_target, hand):
	for c in hand:
		if c[0] == card_target[0] or c[1] == card_target[1]:
			print('YES')
			return
	print('NO')
card_target = input().strip()
hand = [c for c in input().strip().split()]
match(card_target, hand)


carta_mesa = input()
cartas_mano = input().split(' ')
(valor_carta, palo_carta) = (carta_mesa[0], carta_mesa[1])
booleano = False
for carta in cartas_mano:
	if valor_carta in carta or palo_carta in carta:
		booleano = True
if booleano:
	print('YES')
else:
	print('NO')


a = input()
l = list(input().split())
if a[0] in l[0] or a[1] in l[0]:
	print('YES')
elif a[0] in l[1] or a[1] in l[1]:
	print('YES')
elif a[0] in l[2] or a[1] in l[2]:
	print('YES')
elif a[0] in l[3] or a[1] in l[3]:
	print('YES')
elif a[0] in l[4] or a[1] in l[4]:
	print('YES')
else:
	print('NO')


a = set(input())
b = set(input())
if a.intersection(b):
	print('YES')
else:
	print('NO')


jackppot = set(input())
cards = list(input().split())
l = set()
for i in range(5):
	for j in set(cards[i]):
		l.add(j)
if len(jackppot.intersection(l)) == 0:
	print('NO')
else:
	print('YES')


s = str(input())
a = list(input().split())
ans = 0
for i in a:
	if i[0] == s[0] or i[1] == s[1]:
		ans = ans + 1
if ans > 0:
	print('YES')
else:
	print('NO')


s = input()
cs = input().split()
print('YES' if len([1 for c in cs if c[0] == s[0] or c[1] == s[1]]) else 'NO')


t = input()
h = list(map(str, input().split()))
z = False
for y in range(5):
	if h[y][0] == t[0] or h[y][1] == t[1]:
		z = True
if z:
	print('YES')
else:
	print('NO')


s = input()
x = list(input().split())
for i in range(5):
	if s[0] == x[i][0] or s[1] == x[i][1]:
		print('YES')
		break
	if i == 4:
		print('NO')


string = input()
cards = list(map(str, input().split()))
can_play = False
for i in range(len(cards)):
	if string[0] in cards[i] or string[1] in cards[i]:
		can_play = True
if can_play == True:
	print('YES')
else:
	print('NO')


card_table = input()
cards_hand = list(input().split(' '))
num_cards = 5
flag = 0
for i in range(num_cards):
	if card_table[0] == cards_hand[i][0] or card_table[1] == cards_hand[i][1]:
		flag = 1
		break
if flag > 0:
	print('YES')
else:
	print('NO')


x = input()
a = input().split()
if x[0] == a[0][0] or x[1] == a[0][1]:
	print('YES')
elif x[0] == a[1][0] or x[1] == a[1][1]:
	print('YES')
elif x[0] == a[2][0] or x[1] == a[2][1]:
	print('YES')
elif x[0] == a[3][0] or x[1] == a[3][1]:
	print('YES')
elif x[0] == a[4][0] or x[1] == a[4][1]:
	print('YES')
else:
	print('NO')


import sys
input_lines = sys.stdin.readlines()
goal = input_lines[0].strip()
hand = input_lines[1].strip()
found = False
for char in goal:
	if char in hand:
		found = True
if found:
	print('YES')
else:
	print('NO')


d = input()
h = input().split()
for i in h:
	if i[0] == d[0]:
		print('YES')
		break
	if i[1] == d[1]:
		print('YES')
		break
else:
	print('NO')


st = list(input())
count = 0
sh = [x for x in input().split()]
for i in range(0, len(sh)):
	if st[0] == sh[i][0]:
		count += 1
	elif st[1] == sh[i][1]:
		count += 1
if count > 0:
	print('YES')
else:
	print('NO')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
rank = [2, 3, 4, 5, 6, 7, 8, 9, 'T', 'J', 'Q', 'K', 'A']
suit = ['D', 'C', 'S', 'H']

def function(card, table):
	output = 'NO'
	for value in table:
		value.replace('\n', '')
		if card[0] == value[0]:
			output = 'YES'
		elif card[1] == value[1]:
			output = 'YES'
	if output != 'YES':
		output = 'NO'
	print(output)
card = insr()
table = list(input().split(' '))
function(card, table)


tableCard = list(input())
handCards = list(input().replace(' ', ''))
if tableCard[0] in handCards or tableCard[1] in handCards:
	print('YES')
else:
	print('NO')


rs = str(input())
hand = list(map(str, input().rstrip().split()))
flag = 0
for i in hand:
	if i[0] == rs[0] or i[1] == rs[1]:
		flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


x = input()
line = input()
if x[0] in line or x[1] in line:
	print('YES')
else:
	print('NO')


s = input()
lst = input()
print('YES' if s[0] in lst or s[1] in lst else 'NO')


yo = input()
tmp = input().split()
f = 1
for i in tmp:
	if i[1] == yo[1] or i[0] == yo[0]:
		print('YES')
		f = 0
		break
if f:
	print('NO')


test_in = input()
test_hand = input()
results = [1 if test_in[i] in test_hand else 0 for i in range(2)]
if sum(results) > 0:
	print('YES')
else:
	print('NO')


t = list(input())
lst = list(map(str, input().split()))
for i in lst:
	s = i
	if s[0] == t[0] or s[1] == t[1]:
		print('YES')
		exit(0)
print('NO')


n = input()
ss = input().split(' ')
k = 0
for i in range(5):
	if ss[i][0] == n[0] or ss[i][1] == n[1]:
		k += 1
		break
	else:
		continue
if k > 0:
	print('YES')
else:
	print('NO')


board = str(input())
hand = list(map(str, input().split()))
accept = 0
for i in range(len(hand)):
	if board[0] == hand[i][0] or board[1] == hand[i][1]:
		accept = 1
if accept == 1:
	print('YES')
else:
	print('NO')


s = input()
e = input()
if s[0] in e or s[1] in e:
	print('YES')
else:
	print('NO')


s = input()
(a, b, c, d, e) = input().split()
c1 = ord(s[0])
c2 = ord(a[0])
c3 = ord(b[0])
c4 = ord(c[0])
c5 = ord(d[0])
c6 = ord(e[0])
c7 = ord(s[1])
c8 = ord(a[1])
c9 = ord(b[1])
c10 = ord(c[1])
c11 = ord(d[1])
c12 = ord(e[1])
if c1 == c2 or c1 == c3 or c1 == c4 or (c1 == c5) or (c1 == c6) or (c7 == c8) or (c7 == c12) or (c7 == c9) or (c7 == c10) or (c7 == c11):
	print('YES')
else:
	print('NO')


def main():
	table_card = input()
	my_cards = input().split(' ')
	first = table_card[0]
	second = table_card[1]
	for card in my_cards:
		if first in card or second in card:
			print('YES')
			return
	print('NO')
main()


s = input()
l = list(input().split())
a = s[0]
b = s[1]
count = 0
for i in l:
	if i[0] == a or i[1] == b:
		print('YES')
		break
	else:
		count += 1
if count == 5:
	print('NO')


x = input()
j = 1
y = list(input().split())
for i in y:
	if i[0] == x[0] or i[1] == x[1]:
		print('YES')
		j = 0
		break
if j:
	print('NO')


x = input()
y = list(map(str, input().split()))
n = []
c = []
for i in y:
	n = n + [i[0]]
	c = c + [i[1]]
if x[0] in n or x[1] in c:
	print('YES')
else:
	print('NO')


n = input()
m = input().split()
finded = False
for i in range(len(m)):
	if n[0] == m[i][0] or n[1] == m[i][1]:
		finded = True
		break
if finded:
	print('YES')
else:
	print('NO')


import sys

def solve():
	table = input()
	hand = input()
	if table[0] in hand or table[1] in hand:
		return 'YES'
	else:
		return 'NO'
ans = solve()
print(ans)


n = list(input())
cards = input().split(' ')
cards
yes = 0
for card in cards:
	c = list(card)
	if c[0] == n[0]:
		print('YES')
		yes = 1
		break
	if c[1] == n[1]:
		print('YES')
		yes = 1
		break
if yes == 0:
	print('NO')


t = str(input()).strip()
v = str(input()).strip().split(' ')
if t[-1] in {v_[-1] for v_ in v} or t[0] in {v_[0] for v_ in v}:
	print('YES')
else:
	print('NO')


table = input()
cards = input().split(' ')
rank = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
suit = ['D', 'C', 'S', 'H']
true = 0
for i in range(len(cards)):
	if cards[i][0] == table[0]:
		true += 1
		break
for i in range(len(cards)):
	if cards[i][1] == table[1]:
		true += 1
		break
if true == 1 or true == 2:
	print('YES')
else:
	print('NO')


n = list(input())
card = list(map(str, input().split()))
f = 0
for each in card:
	if n[1] in each or n[0] in each:
		f = 1
		break
if f:
	print('YES')
else:
	print('NO')


c = input()
my = input().split()
print('YES' if any((mc[0] == c[0] or mc[1] == c[1] for mc in my)) else 'NO')


entry_1 = list(set(input()))
entry_2 = input().split(' ')
sol = []
for i in range(len(entry_2)):
	if entry_1[0] in entry_2[i] or entry_1[1] in entry_2[i]:
		sol.append('YES')
	else:
		continue
if sol.count('YES') > 0:
	print('YES')
else:
	print('NO')


A = input()
B = input().split()
print('YES' if any((s[0] == A[0] for s in B)) or any((s[1] == A[1] for s in B)) else 'NO')


a = str(input())
b = str(input())
if b.find(a[0]) > -1:
	print('YES')
elif b.find(a[1]) > -1:
	print('YES')
else:
	print('NO')


n = input()
l = list(input().split())
ans = 'NO'
for x in l:
	if x[0] == n[0] or x[1] == n[1]:
		ans = 'YES'
print(ans)


class Card:

	def __init__(self, look):
		self.rank = look[0]
		self.suit = look[1]

	def similar(self, c):
		if self.rank == c.rank or self.suit == c.suit:
			return True
		else:
			return False

def any_similar():
	for x in mycards:
		if x.similar(firstcard):
			return True
	return False
ip = input()
firstcard = Card(ip)
ipcards = input().split()
mycards = []
for x in ipcards:
	mycards.append(Card(x))
if any_similar():
	print('YES')
else:
	print('NO')


c = input()
s = input()
if c[0] in s:
	print('YES')
elif c[1] in s:
	print('YES')
else:
	print('NO')


d = input()
s = ''.join(input().split())
print('YNEOS'[d[0] not in s and d[1] not in s::2])


(card_rank, card_suit) = list(input())
hand = input().split()
result = 'NO'
for card in hand:
	if card_rank in card or card_suit in card:
		result = 'YES'
		break
print(result)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
x = insr()
flag = 0
y = insr()
if x[0] in y or x[1] in y:
	flag = 1
if flag == 1:
	print('YES')
else:
	print('NO')


a = [str(x) for x in input()]
b = [str(x) for x in input().split()]
list = []
for i in range(len(a)):
	for j in b:
		if a[i] == j[i]:
			list.append('YES')
			break
		else:
			list.append('NO')
if list.count('YES'):
	print('YES')
else:
	print('NO')


table = input()
cards = input().split()
can_play = False
for i in range(5):
	if cards[i][0] == table[0] or cards[i][1] == table[1]:
		can_play = True
		break
if can_play:
	print('YES')
else:
	print('NO')


k = input()
(a1, a2, a3, a4, a5) = map(set, input().split())
a = a1 | a2 | a3 | a4 | a5
if k[0] in a or k[1] in a:
	print('YES')
else:
	print('NO')


k = input()
cards = list(input().split())
flag = True
for c in cards:
	if k[0] == c[0] or k[1] == c[1]:
		print('YES')
		flag = False
		break
if flag:
	print('NO')


def solve(given, hand):
	for char in given:
		for card in hand:
			if char in card:
				return 'YES'
	return 'NO'
given = input()
hand = input().split()
print(solve(given, hand))


C = input()
cards = input().split()
rank = ['2', '3', '4', '5', '6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A']
yes = 0
for elem in cards:
	if C[0] in elem:
		yes += 1
		print('YES')
		break
	if C[1] in elem:
		yes += 1
		print('YES')
		break
if yes == 0:
	print('NO')


start = input()
q = 0
cards = input().split()
for i in range(5):
	if cards[i][0] == start[0] or cards[i][1] == start[1]:
		print('YES')
		q = 1
		break
if q == 0:
	print('NO')


s1 = input()
s2 = input().split()
flag = 1
for i in range(len(s2)):
	if s2[i][0] in s1 or s2[i][1] in s1:
		print('YES')
		flag = 0
		break
if flag == 1:
	print('NO')


table = input()
hand = input().split()
hand1 = ''.join(hand)
tab = []
for h in range(len(hand1)):
	for t in range(len(table)):
		if table[t] == hand1[h]:
			tab.append(1)
			break
if sum(tab):
	print('YES')
else:
	print('NO')


rang = input()
mast = rang[1]
rang = rang[0]
rang1 = list(input())
check = 0
for i in range(14):
	if rang1[i] == rang:
		check = 1
		break
	elif rang1[i] == mast:
		check = 1
		break
if check == 1:
	print('YES')
else:
	print('NO')


s = input()
li = list(map(str, input().split()))
for i in range(len(li)):
	if li[i][0] == s[0]:
		print('YES')
		break
	elif li[i][1] == s[1]:
		print('YES')
		break
else:
	print('NO')


x = input()
v = list(input().split())
c = [q[0] for q in v if q[0] == x[0]]
c.extend([q[1] for q in v if q[1] == x[1]])
print('YES' if len(c) > 0 else 'NO')


n = input()
x = input()
for i in n:
	if i in x:
		print('YES')
		exit()
print('NO')


(card, my_hand) = (list(input()), list(input()))
for c in card:
	if c in my_hand:
		print('YES')
		exit()
print('NO')


s = input()
t = list(input().split())
for i in t:
	if i[0] == s[0] or i[1] == s[1]:
		print('YES')
		break
else:
	print('NO')


s = str(input())
f = list(map(str, input().split()))
for i in range(5):
	k = f[i]
	if s.count(k[0]) != 0 or s.count(k[1]) != 0:
		print('YES')
		break
else:
	print('NO')


card1 = list(input())
cards = input().split()
filtered_cards = filter(lambda x: card1[0] in x or card1[1] in x, cards)
filtered_cards_list = list(filtered_cards)
print('YES' if len(filtered_cards_list) > 0 else 'NO')


a = input()
b = input().split()
flag = 0
for (i, j) in b:
	if i == a[0] or j == a[1]:
		print('YES')
		flag = 1
		break
if flag == 0:
	print('NO')


l = list(input())
l1 = [list(i) for i in input().split()]
c = 0
for i in l1:
	if l[1] == i[1]:
		c = 1
	if l[0] == i[0]:
		c = 1
if c == 1:
	print('YES')
else:
	print('NO')


s = input()
t = input()
for i in s:
	if i in t:
		print('YES')
		exit()
print('NO')


from sys import stdin
card = stdin.readline()
hand = list(stdin.readline().split())
flag = False
for i in range(5):
	if hand[i][0] == card[0] or hand[i][1] == card[1]:
		flag = True
		break
if flag:
	print('YES')
else:
	print('NO')


a = input()
l = list(map(str, input().split()))
x = []
y = []
for i in range(5):
	x.append(l[i][0])
	y.append(l[i][1])
if a[0] in x or a[1] in y:
	print('YES')
else:
	print('NO')


H = list(input())
T = [list(s) for s in input().split()]
answer = 'NO'
for i in range(5):
	if H[0] == T[i][0] or H[1] == T[i][1]:
		answer = 'YES'
		break
print(answer)


tablecard = input()
handcard = list(input().split())
flag = 0
for i in range(5):
	if handcard[i][0] == tablecard[0] or handcard[i][1] == tablecard[1]:
		flag = 1
if flag == 0:
	print('NO')
else:
	print('YES')


card = input()
card_set = input()
print('YES' if card[0] in card_set or card[1] in card_set else 'NO')


ok = 0
a = list(input())
b = input().split()
for i in range(5):
	if a[0] in b[i]:
		ok = 1
	if a[1] in b[i]:
		ok = 1
print('YES') if ok else print('NO')


card_in_table = input()
cards_in_hand = input().split()
yes = False
for card in cards_in_hand:
	if card[0] == card_in_table[0] or card[1] == card_in_table[1]:
		yes = not yes
		break
print('YES' if yes else 'NO')


tablecard = list(input())
cards = [i for i in input().split()]
table = []
dont = True
for i in cards:
	for j in i:
		table.append(j)
for i in table:
	if i == tablecard[0] or i == tablecard[1]:
		print('YES')
		dont = False
		break
	else:
		continue
if dont:
	print('NO')


s = input()
t = ''
t = input()
h = 0
for i in range(2):
	if s[i] in t:
		h += 1
if h >= 1:
	print('YES')
else:
	print('NO')


a = set(input())
b = set(input())
if len(a.intersection(b)) == 0:
	print('NO')
else:
	print('YES')


class Main:
	table = input()
	hand = input().split(' ')
	for card in hand:
		if card[0] == table[0]:
			print('YES')
			break
		else:
			continue
	else:
		for card in hand:
			if card[1] == table[1]:
				print('YES')
				break
			else:
				continue
		else:
			print('NO')
Main()


s = input()
i = s[:1]
j = s[1:]
strr = [str(i) for i in input().split()]

def foo(strr):
	for e in strr:
		if e[:1] == i or e[1:] == j:
			print('YES')
			return
	print('NO')
	return
foo(strr)


def canPlay(deck, hand):
	for c in hand:
		if c[0] == deck[0] or c[1] == deck[1]:
			return 'YES'
	return 'NO'
deck = str(input())
hand = list(map(str, input().split(' ')))
print(canPlay(deck, hand))