# -*- coding: utf-8 -*-
"""Untitled98.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1MIHBQVDp2TAw0xh4Wt0ELrX3hFUyTepQ
"""

for _ in range(int(input())):
  llll=input()
  l=[int(x) for x in input().split()]
  l2=[int(x) for x in input().split()]
  l=set(l)
  l2=set(l2)
  x=l.intersection(l2)
  x=list(x)
  if len(x)==0:
    print('NO')
  else:
    print('YES')
    print(1,x[0])

