import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * Created by studyalgorithms.com
 */

class TwoStrings {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();

        Set<Character> a;
        Set<Character> b;

        for (int i = 0; i < n; i++) {

            a = new HashSet<>();
            b = new HashSet<>();

            for (char c : scan.next().toCharArray()) {
                a.add(c);
            }
            for (char c : scan.next().toCharArray()) {
                b.add(c);
            }

            // store the set intersection in set 'a'
            a.retainAll(b);

            System.out.println((a.isEmpty()) ? "NO" : "YES");
        }
        scan.close();
    }
}