t=int(input())
for i in range(t):
	n,m=map(int,input().split())
	a=list(map(int,input().split()))
	b=list(map(int,input().split()))
	a1=set(a)
	b1=set(b)
	k=list((a1.intersection(b1)))
	if(len(k)==0):
		print('NO')
	else:
		print('YES')
		print(1,k[0])