
for u in range(int(raw_input())):
	n,m = map(int ,raw_input().split())
	ais = set(map(int, raw_input().split()))
	bis = map(int, raw_input().split())
	
	flag =  False
	for b in bis:
		if b in ais:
			flag = True
			break
	print 'YES' if flag else 'NO'
	if flag:
		print '1 {}'.format(str(b))
