t=int(input())
for i in range(0,t):
    c=0
    d="No"
    a,b=map(int,input().split())
    l=list(map(int,input().split()))
    l1=list(map(int,input().split()))
    for j in range(0,len(l)):
        for k in range(0,len(l1)):
            if l[j]==l1[k]:
                p=l[j]
                c=1
                d="Yes"
    if d=="Yes":
        print(d)                
        print(str(c)+" "+str(p))     
    else:
        print("No")
