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();
}
}
aW1wb3J0IGphdmEudXRpbC5IYXNoU2V0OwppbXBvcnQgamF2YS51dGlsLlNjYW5uZXI7CmltcG9ydCBqYXZhLnV0aWwuU2V0OwoKLyoqCiAqIENyZWF0ZWQgYnkgc3R1ZHlhbGdvcml0aG1zLmNvbQogKi8KCmNsYXNzIFR3b1N0cmluZ3MgewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpIHsKICAgICAgICBTY2FubmVyIHNjYW4gPSBuZXcgU2Nhbm5lcihTeXN0ZW0uaW4pOwogICAgICAgIGludCBuID0gc2Nhbi5uZXh0SW50KCk7CgogICAgICAgIFNldDxDaGFyYWN0ZXI+IGE7CiAgICAgICAgU2V0PENoYXJhY3Rlcj4gYjsKCiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKCiAgICAgICAgICAgIGEgPSBuZXcgSGFzaFNldDw+KCk7CiAgICAgICAgICAgIGIgPSBuZXcgSGFzaFNldDw+KCk7CgogICAgICAgICAgICBmb3IgKGNoYXIgYyA6IHNjYW4ubmV4dCgpLnRvQ2hhckFycmF5KCkpIHsKICAgICAgICAgICAgICAgIGEuYWRkKGMpOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoY2hhciBjIDogc2Nhbi5uZXh0KCkudG9DaGFyQXJyYXkoKSkgewogICAgICAgICAgICAgICAgYi5hZGQoYyk7CiAgICAgICAgICAgIH0KCiAgICAgICAgICAgIC8vIHN0b3JlIHRoZSBzZXQgaW50ZXJzZWN0aW9uIGluIHNldCAnYScKICAgICAgICAgICAgYS5yZXRhaW5BbGwoYik7CgogICAgICAgICAgICBTeXN0ZW0ub3V0LnByaW50bG4oKGEuaXNFbXB0eSgpKSA/ICJOTyIgOiAiWUVTIik7CiAgICAgICAgfQogICAgICAgIHNjYW4uY2xvc2UoKTsKICAgIH0KfQ==