n=int(input())
for _ in range(n):
    x,y=input().split()
    x=int(x)
    y=int(y)
    L1=list(map(int,input().rstrip().split()))[:x]
    L2=list(map(int,input().rstrip().split()))[:y]
    count=0
    x=0
    for i in L1:
        if i in L2:
           count+=1
           x=i
    if count>0:
        print("YES")
        print(1,x)
    else:
        print("NO")