t=int(input())
for i in range(t):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    d=list(map(int,input().split()))
    c=set(c)
    d=set(d)
    c=c.intersection(d)
    if len(c)>=1:
        print("Yes")
        c=list(c)
        print(1,end=" ")
        print(c[0])
    else:
        print("No")