def f(a,b):
    l = []
    for i in a:
        if i in b:
            l.append(i)
    if l == []:
        print("NO")
        return
    print("YES")
    print("1 "+str(min(l)))

for _ in range(int(input())):
    input()
    f([int(x) for x in input().split()],[int(x) for x in input().split()])