for i in range(int(input())):
	n,m=map(int,input().split())
	An=list(map(int,input().split()))
	Bm=list(map(int,input().split()))
	An_set=set(An)
	Bm_set=set(Bm)
	inter=An_set.intersection(Bm_set)
	if(len(inter)==0):
		print("NO")
	else:
		print("YES")
		print(1,list(inter)[0])
		
