for _ in range(int(input())):
	_ = input()
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a.intersection(b)
	if c:
		print('YES')
		print('1 ' + str(list(c)[0]))
	else:
		print('NO')
