t=int(input())
for t in range(t):
    x,y=map(int,input().split())
    l1=list(map(int,input().split()))
    l2=list(map(int,input().split()))
    c=0
    l=[]
    for i in l1:
        if i in l2:
            c+=1
            l.append(i)
            break
    if c!=0:
        print("YES")
        print(len(l),end=" ")
        for j in l:
            print(j,end=" ")
        print()
    else:
        print("NO")
    