t = int(input())  

while t:
  t -= 1
  input()
  a = set(map(int, input().split()))
  b = list(map(int, input().split()))

  flag = True

  for num in a:
    if num in b:
      print("YES")
      print(1, num)
      flag = False
      break

  if flag:
    print("NO")