
inp_test=int(input())

def intersection(lst1, lst2): 
    lst3 = [value for value in lst1 if value in lst2] 
    return lst3 
    
for i in range(inp_test):
    n,m=map(int,input().split(" "))
    list_n=list(map(int,input().split(" ")))
    list_m=list(map(int,input().split(" ")))
    list1=intersection(list_n,list_m)
    if(len(list1)!=0):
        print("YES")
        print(1,min(list1))
    else:
        print("NO")
    