for t in range(int(input())):
    n1,n2=map(int,input().split())
    l1=list(map(int,input().split()))
    l2=list(map(int,input().split()))
    flag=a=0
    for i in l1:
        for j in l2:
            if i==j:
                flag=1
                a=i
                break
    if flag==1:
        print("YES")
        print(1,a)
    else:
        print("NO")