1
2 2
1 1
1 2
 1
1 3
3
1 2 3
 1
1 1
1000
1000
 1
2 2
2 2
2 2
 5
4 5
10 8 6 4
1 2 3 4 5
1 1
3
3
1 1
3
2
5 3
1000 2 2 2 3
3 1 5
5 5
1 2 3 4 5
1 2 3 4 5
 1
4 4
1 1 1 1
1 2 3 4
 1
2 3
1 1
1 2 3

YES
1 1
 YES
1 3
 YES
1 1000
 YES
1 2
 YES
1 4
YES
1 3
NO
YES
1 3
YES
1 1
 YES
1 1
 YES
1 1

# Python 3 code to generate all 
# possible subsequences. 

# Uses python3
from sys import stdin, stdout 
import sys
import math
import itertools
sys.setrecursionlimit(10**6)

def printSubsequences(arr, index, subarr,sequence): 
	# Print the subsequence when reach 
	# the leaf of recursion tree 
	if index == len(arr): 
		
		# Condition to avoid printing 
		# empty subsequence 
		if len(subarr) != 0: 
			sequence.append(subarr) 
	
	else: 
		# Subsequence without including 
		# the element at current index 
		printSubsequences(arr, index + 1, subarr,sequence) 
		
		# Subsequence including the element 
		# at current index 
		printSubsequences(arr, index + 1, subarr+[arr[index]],sequence) 
	
	return sequence

# def printSubsequences(arr, n) : 

# 	# Number of subsequences is (2**n -1) 
# 	opsize = math.pow(2, n) 

# 	# Run from counter 000..1 to 111..1 
# 	sequence = list()
# 	for counter in range( 1, (int)(opsize)) : 
# 		sequence.append(list())
# 		for j in range(0, n) : 
			
# 			# Check if jth bit in the counter 
# 			# is set If set then print jth 
# 			# element from arr[] 
# 			if (counter & (1<<j)) : 
# 				sequence[counter-1].append(arr[j])
# 	return sequence

# This code is contributed by Nikita Tiwari. 


def main(): 
	t = int(stdin.readline().strip())
	for i in range (1,t+1):
		k=0
		l = [int(x) for x in stdin.readline().split()]
		
		a = [int(x) for x in stdin.readline().split()] 
		b = [int(x) for x in stdin.readline().split()]

		for i in a:
			if i in b:
				stdout.write("YES"+'\n')
				stdout.write("1 "+str(i)+'\n')
				k = 1
				break
		if k==1:
			continue
		stdout.write("NO"+'\n')

# call the main method 
if __name__ == "__main__": 
	main()	 