''' author: Priyank Koul, PES University, Bengaluru'''
for _ in range(int(input())):
	n= list(map(int, input().strip().split()))
	lena,lenb= n[0],n[1]
	a=list(map(int, input().strip().split()))
	b=list(map(int, input().strip().split()))
	flag=0
	x=list(set(a).intersection(set(b)))
	if(len(x)==0):
		print("NO")
	else:
		print("YES")
		print(1,x[0])
	