n=int(input())
for i in range(n):

  a,b=map(int,input().split())
  l=list(map(int,input().split()))
  l1=list(map(int,input().split()))
  c=list(set(l) & set(l1))
  if len(c)==0:
    print("NO")
  else:
    print("YES")
    print(1,c[0])

