for _  in range(int(input())):
    n1,n2=map(int,input().split())
    l1=list(map(int,input().split()))
    l2=list(map(int,input().split()))
    s1=set(l1)
    s2=set(l2)
    s=s1 & s2
    if(len(s)==0):
        print("NO")
    else:
        l=list(s)
        print("YES")
        print(1,l[0])