a=int(input(''))
for i in range(0,a):
	b,c=map(int,input().split())
	d=list(map(int,input().split()))
	e=list(map(int,input().split()))
	k=[]
	h=0
	for j in d:
		if j in e:
			k.append(j)
	for m in k:
		if m>=0:
			h+=1
	if h!=0:
		o=min(k)
		print('YES')
		print(f'1 {o}')
	else:
		print('NO')