def intersection(lst1, lst2): 
    lst3 = [value for value in lst1 if value in lst2] 
    return lst3 

for t in range(int(input())):
    n,m=map(int,input().split())
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    res=intersection(a,b)
    k=1
    if(len(res)>=1):
        print('YES')
        print(k,res[0])
    else:
        print('NO')
    
