for i in range(int(input())):
	a,b=map(int,input().split())
	l=set(input().split())
	k=set(input().split())
	j=l.intersection(k)
	if len(j)==0:
		print("NO")
	else:
		print("YES")
		print(1,int(list(j)[0]))