T=int(raw_input())
for t in range (0,T):
    s1=raw_input()
    s2=raw_input()
    l1=len(s1)
    l2=len(s2)
    o=0;
    p=[]
    for i in range(0,l1):
        if s1[i] not in p:
        	p.append(s1[i])
    p_len=len(p)
    for i in range (0,p_len):
    	for j in range (0,l2):
    		if p[i]==s2[j]:
    			o=1
    			break
    if o==1:
        print "Yes"
    else:
        print "No"