for _ in range(int(input())):
  a,b=map(int, input().split())
  x=list(map(int, input().split()))
  y=list(map(int, input().split()))
  for i in x:
    if i in y:
      print("YES")
      print(1,i)
      a=0
      break
  if a!=0: print("NO")
  


