from collections import *
for _ in range(int(input())):
    n,k=map(int,input().split())
    l=list(map(int,input().split()))
    l1=list(map(int,input().split()))
    x,y=Counter(l),Counter(l1)
    f=1
    for i,j in x.items():
        if i in y:
            print("YES")
            print(1,i)
            f=0
            break
    if(f==1):
        print("NO")
        
    
