n=int(input())
def f(a,b):
    c=0
    l=[]
    for j in range (0,len(a)):
        for z in range(0,len(b)):
            if a[j]==b[z]:
                c=c+1
                l.append(a[j])
    if c>0:
        return(l[0])
    


for i in range(0,n):
    l=list(map(int,input().split()))
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    d=f(a,b)
    if d==None:
        print("NO")
    else:
        print("YES")
        print(1,d)
    