n = int(input())
for i in range(n):
    input()
    s1 = input().split()
    s2 = input().split()
    list1_as_set = set(s1)
    intersection = list(list1_as_set.intersection(s2))
    if intersection == []:
        print("NO")
    else:
        print("YES")
        print(1, intersection[0])