for cas in xrange(input()):print"Yes"if set(raw_input().strip())&set(raw_input().strip())else"No"