n = int(input())
for i1 in range(n):
    a, b = [int(x) for x in input().split()]
    lst1 = set([int(x) for x in input().split()])
    lst2 = set([int(x) for x in input().split()])
    lst3 = lst1.intersection(lst1, lst2)
    if len(lst3) >= 1:
        print("YES")
        for x in lst3:
            print(1, x, sep = " ")
            break
    else:
        print("NO")
