t = int(input())
while t:
  a, b = map(int, input().split(' '))
  l1 = []
  l2 = []
  l1 = input().split(' ')
  l2 = input().split(' ')
  intersect = list(set(l1) & set(l2))
  if len(intersect) == 0:
    print('NO')
  else:
    print('YES')
    print(1, end=' ')
    print(intersect[0])
  t -= 1