t=int(input())

for _ in range(t):
    a,b=map(int,input().split())
    m=set(map(str,input().split()))
    n=set(map(str,input().split()))
    inter=m.intersection(n)
    if len(inter)==0:
        print("NO")
    else:
        print("YES")
        print(1,inter.pop())
    
    
