
# Dedicated to Mhamuda


tc=int(input())
while tc!=0:
    a,b=map(int,input().split())
    i=0
    j=0
    arr=list(map(int,input().split()))
    arr2=list(map(int,input().split()))
    tc-=1
    c=0
    for i in range(0,a):
        for j in range(0,b):
            if arr[i]==arr2[j]:
                print("yes")
                c=1
                print(1,arr[i])
                break
        if c==1:
            break
    if c==0:
        print("NO")
