import sys

t = int(sys.stdin.readline().strip())

inp = []
for i in range(t):
    quantity  = sys.stdin.readline().strip()
    lineOne = sys.stdin.readline().strip().split(' ')
    lineTwo = sys.stdin.readline().strip().split(' ')
    inter = set(lineOne) & set(lineTwo)
    if inter:
        print ("YES")
        print (str(1) + ' ' +str((inter.pop())))
    else:
        print ("NO")