for _ in range(int(input())):
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    k=[]
    for i in a:
        for j in b:
            if(i==j):
                k.append(i)
                break
    if(len(k)>0):
        print("Yes")
        print("1",k[0])
    else:
        print("No")