import array as arr
test=int(input())
q=0
while q<test:
    q += 1

    k,l=map(int,input().split())
    m=list(map(int,input().split()[:k]))
    n=list(map(int,input().split()[:l]))
    ans=0
    for i in m:
        if i in n:
            ans=i
            break
    if ans:
        print("YES")
        print(1,ans)
    else:
        print("NO")

q+=1


























































