t = int(input())
for i in range(t):
	n, m = [int(i) for i in input().split()]
	a = set([int(i) for i in input().split()])
	b = set([int(i) for i in input().split()])
	s = a.intersection(b)
	if len(s) == 0:
		print("NO")
	else:
		print("YES")
		print(1, next(iter(s)))