
t=int(input())
while t:
    t-=1
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    a_set = set(a) 
    b_set = set(b) 
  
    if (a_set & b_set): 
        l=(a_set & b_set)
        k1=list(l)
        print("YES")
        print(1,k1[0])
        
    else:
        print("NO")
   