You are given two arrays of integers $a_1,\ldots,a_n$ and $b_1,\ldots,b_m$.

Your task is to find a non-empty array $c_1,\ldots,c_k$ that is a subsequence of $a_1,\ldots,a_n$, and also a subsequence of $b_1,\ldots,b_m$. If there are multiple answers, find one of the smallest possible length. If there are still multiple of the smallest possible length, find any. If there are no such arrays, you should report about it.

A sequence $a$ is a subsequence of a sequence $b$ if $a$ can be obtained from $b$ by deletion of several (possibly, zero) elements. For example, $[3,1]$ is a subsequence of $[3,2,1]$ and $[4,3,1]$, but not a subsequence of $[1,3,3,7]$ and $[3,10,4]$.


-----Input-----

The first line contains a single integer $t$ ($1\le t\le 1000$)  — the number of test cases. Next $3t$ lines contain descriptions of test cases.

The first line of each test case contains two integers $n$ and $m$ ($1\le n,m\le 1000$)  — the lengths of the two arrays.

The second line of each test case contains $n$ integers $a_1,\ldots,a_n$ ($1\le a_i\le 1000$)  — the elements of the first array.

The third line of each test case contains $m$ integers $b_1,\ldots,b_m$ ($1\le b_i\le 1000$)  — the elements of the second array.

It is guaranteed that the sum of $n$ and the sum of $m$ across all test cases does not exceed $1000$ ($\sum\limits_{i=1}^t n_i, \sum\limits_{i=1}^t m_i\le 1000$).


-----Output-----

For each test case, output "YES" if a solution exists, or "NO" otherwise.

If the answer is "YES", on the next line output an integer $k$ ($1\le k\le 1000$)  — the length of the array, followed by $k$ integers $c_1,\ldots,c_k$ ($1\le c_i\le 1000$)  — the elements of the array.

If there are multiple solutions with the smallest possible $k$, output any.


-----Example-----
Input
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

Output
YES
1 4
YES
1 3
NO
YES
1 3
YES
1 2



-----Note-----

In the first test case, $[4]$ is a subsequence of $[10, 8, 6, 4]$ and $[1, 2, 3, 4, 5]$. This array has length $1$, it is the smallest possible length of a subsequence of both $a$ and $b$.

In the third test case, no non-empty subsequences of both $[3]$ and $[2]$ exist, so the answer is "NO".

Source: codeforces | Difficulty: EASY
Tags: Complete search


Solutions:
t = int(input())
for i in range(t):
	x = input().split()
	n = int(x[0])
	m = int(x[1])
	(p1, p2) = ([], [])
	e = input()
	for j in e.split():
		v = int(j)
		p1.append(v)
	e = input()
	for j in e.split():
		v = int(j)
		p2.append(v)
	flag = 0
	for j in p1:
		if j in p2:
			print('YES')
			print(1, j)
			flag = 1
			break
	if flag == 0:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	c = list(set(l) & set(l1))
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = {i: True for i in map(int, input().split())}
	ans = 'NO'
	for i in a:
		if i in b:
			ans = 'YES'
			print(ans)
			print('1', i)
			break
	if ans == 'NO':
		print(ans)


for _ in ' ' * int(input()):
	(a, b) = map(int, input().split())
	z = list(map(int, input().split()))
	z1 = list(map(int, input().split()))
	r = 0
	for i in z:
		if i in z1:
			r = i
			break
	if r:
		print('YES')
		print(1, r)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	num1 = set([int(x) for x in input().split()])
	num2 = set([int(x) for x in input().split()])
	if num1 & num2:
		print('YES')
		print('1 ' + str(list(num1 & num2)[0]))
	else:
		print('NO')


for t in range(int(input())):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	if m < n:
		for i in b:
			if i in a:
				c.append(i)
				break
	else:
		for i in a:
			if i in b:
				c.append(i)
				break
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(len(c), end=' ')
		for i in c:
			print(i, end=' ')
		print()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 1
	for i in a:
		if i in b:
			flag = 0
			print('YES')
			print(1, i)
			break
	if flag:
		print('NO')


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ri = lambda : int(sys.stdin.readline().strip())
rs = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
from math import *
t = ri()
for _ in range(t):
	(n, m) = RI()
	a = RI()
	b = RI()
	c = df(int)
	d = df(int)
	for i in a:
		c[i] = 1
	for i in b:
		d[i] = 1
	flag = 0
	for i in range(1, 1001):
		if d[i] == 1 and c[i] == 1:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
for case in range(itg()):
	(n, m) = mpint()
	s1 = set(mpint())
	s2 = set(mpint())
	s3 = s1 & s2
	if s3:
		print('YES')
		print(1, s3.pop())
	else:
		print('NO')


def func(t):
	for i in range(t):
		a = list(map(int, input().split()))
		n = list(map(int, input().split()))
		m = list(map(int, input().split()))
		flag = True
		for i in range(len(n)):
			if n[i] in m:
				print('YES')
				print(1, n[i])
				flag = False
				break
		if flag:
			print('NO')
t = int(input())
func(t)


q = int(input())
for t in range(q):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = set(A)
	D = set(B)
	jjj = C & D
	if len(jjj) == 0:
		print('NO')
	else:
		print('YES')
		print(1, list(jjj)[0])


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

def printSubsequences(arr, index, subarr, sequence):
	if index == len(arr):
		if len(subarr) != 0:
			sequence.append(subarr)
	else:
		printSubsequences(arr, index + 1, subarr, sequence)
		printSubsequences(arr, index + 1, subarr + [arr[index]], sequence)
	return sequence

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')
main()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp = 0
	x = set(a)
	y = set(b)
	c = list(x)
	d = list(y)
	c.sort()
	d.sort()
	for i in range(0, len(c)):
		if c[i] in d:
			temp = 1
			p = c[i]
			break
	if temp == 1:
		print('YES')
		print(temp, p)
	else:
		print('NO')


for x in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	c = list()
	count = 0
	for j in a:
		if j in b:
			count = count + 1
			c.append(j)
	if count >= 1:
		print('YES')
		print('1', end=' ')
		print(c[0])
	else:
		print('NO')


q = int(input())
for i in range(q):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	t = 0
	for k in a:
		if k in b:
			print('YES')
			print('1', k)
			t = 1
			break
	if t == 0:
		print('NO')


a = int(input())
i = 0
while i < a:
	b = input().split(' ')
	c = input().split(' ')
	d = input().split(' ')

	def common_elements(c, d):
		c.sort()
		d.sort()
		(i, j) = (0, 0)
		common = []
		while i < len(c) and j < len(d):
			if c[i] == d[j]:
				common.append(c[i])
				break
				i += 1
				j += 1
			elif c[i] < d[j]:
				i += 1
			else:
				j += 1
		return common
	if common_elements(c, d) == []:
		print('NO')
	else:
		print('YES')
		print(1, ', '.join(map(str, common_elements(c, d))))
	i = i + 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = set(map(int, input().split()))
	l2 = set(map(int, input().split()))
	l3 = list(l1.intersection(l2))
	if len(l3) > 0:
		print('YES')
		print(1, l3[0])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	lst = []
	for i in a:
		for q in b:
			if q == i and a != b:
				lst.append(q)
				break
	if a == b:
		lst.append(min(a))
	if len(lst) == 0:
		print('NO')
	else:
		print('YES')
		print(f'1 {lst[0]}')


for _ in range(int(input())):
	(n1, n2) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	s1 = set(l1)
	s2 = set(l2)
	s = s1 & s2
	if len(s) == 0:
		print('NO')
	else:
		l = list(s)
		print('YES')
		print(1, l[0])


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, m) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		dic = {}
		for ele in a:
			dic[ele] = True
		found = False
		for ele in b:
			if dic.get(ele, False):
				yield 'YES'
				yield '1 {}'.format(ele)
				found = True
				break
		if not found:
			yield 'NO'
t = int(input())
ans = gift()
print(*ans, sep='\n')


def solve(n, m, a, b):
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				print('YES')
				print('1 ' + str(a[i]))
				return
	print('NO')
	return
for t in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	solve(n, m, a, b)


n = int(input())
for i in range(n):
	a = []
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	r = list(map(int, input().split()))
	for j in q:
		if j in r:
			a.append(j)
	a = sorted(a)
	if len(a) > 0:
		print('YES')
		print('1', end=' ')
		print(a[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	x = list(set(a) & set(b))
	if len(x) > 0:
		print('YES')
		print(1, x[0])
	else:
		print('NO')


def common_elements(list1, list2):
	return [element for element in list1 if element in list2]
t = int(input())
while t > 0:
	(al, bl) = [int(x) for x in input().split()]
	a = [str(int(x)) for x in input().split()]
	b = [str(int(x)) for x in input().split()]
	found = False
	for x in a:
		if x in b:
			found = True
			print('YES')
			print(f'1 {x}')
			break
	if not found:
		print('NO')
	t -= 1


import sys
import collections

def input():
	return sys.stdin.readline().rstrip()

def split_input():
	return [int(i) for i in input().split()]
tests = int(input())
for _ in range(tests):
	(n, m) = split_input()
	a = split_input()
	b = split_input()
	sa = set()
	for i in a:
		sa.add(i)
	done = False
	ans = None
	for i in b:
		if i in sa:
			done = True
			ans = i
			break
	if done:
		print('YES')
		print('1 %d' % ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	d = {}
	for i in range(n):
		d[a[i]] = 1
	l = 0
	ans = 0
	for i in range(m):
		if b[i] in d.keys():
			l = 1
			ans = b[i]
	if l == 0:
		print('NO')
	else:
		print('YES')
		print(l, ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = -1
	for x in a:
		for y in b:
			if x == y:
				ans = x
	if ans != -1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = list()
	if len(a) <= len(b):
		for i in a:
			if i in b:
				res.append(i)
				break
	else:
		for i in b:
			if i in a:
				res.append(i)
				break
	if res:
		print('YES')
		print(len(res), *res)
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	A.intersection_update(B)
	if len(A) >= 1:
		x = A.pop()
		print('YES')
		print(1, x)
	else:
		print('NO')


for _ in range(int(input())):
	nm = list(map(int, input().rstrip().split()))[:2]
	a = list(map(int, input().rstrip().split()))[:nm[0]]
	b = list(map(int, input().rstrip().split()))[:nm[1]]
	a.sort()
	b.sort()
	c = []
	for i in b:
		if i in a:
			c.append(i)
	if len(c) > 0:
		print('YES')
		print(1, c[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			f = 1
			break
	if f:
		continue
	else:
		print('NO')


n = int(input())
for i in range(n):
	s = input().split(' ')
	n = int(s[0])
	m = int(s[1])
	s1 = input().split(' ')
	s2 = input().split(' ')
	a = -1
	for j in range(n):
		for k in range(m):
			if s1[j] == s2[k]:
				a = int(s1[j])
				break
	if a != -1:
		print('YES')
		print('1 ' + str(a))
	else:
		print('NO')


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		ar = inpt()
		br = inpt()
		d = {}
		for i in ar:
			d[i] = True
		ok = False
		ans = 0
		for i in br:
			if i in d:
				ok = True
				ans = i
				break
		if ok:
			print('YES')
			print(1, ans)
			continue
		print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def commonseq(n, a, b):
	for i in range(len(a)):
		if a[i] in b:
			return a[i]
	return -1
test = int(input())
for i in range(test):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = commonseq(n, a, b)
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for (i, x) in enumerate(l1):
		if x in l2:
			print('YES')
			print(1, x)
			break
	else:
		print('NO')


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


import sys, bisect
input = sys.stdin.readline
T = int(input())
for testcase in range(T):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(map(int, input().split()))
	flag = True
	for e in a:
		if e in b:
			flag = False
			print('YES')
			print(1, e)
			break
	if flag:
		print('NO')


def get_first_common_element(x, y):
	for i in x:
		if i in y:
			return i
	return None
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = get_first_common_element(a, b)
	if ans == None:
		print('NO')
	else:
		print('YES')
		print(1, ans)


def solve(a, b):
	c = set(b)
	for i in a:
		if i in c:
			print('YES')
			print(1, i)
			return
	print('NO')
for t in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(a, b)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:m]
	d = 0
	temp = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				d = 1
				temp = a[i]
				break
	if d == 1:
		print('YES')
		print(d, temp)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	b = set(b)
	d = dict()
	ans = -1
	for i in a:
		if i not in d.keys():
			d[i] = 1
	for j in b:
		if j not in d.keys():
			d[j] = 1
		else:
			ans = j
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
for i in range(t):
	nm = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp = {}
	for i in a:
		temp[i] = 0
	flag = False
	for j in b:
		if temp.get(j) == 0:
			print('YES')
			print(f'1 {j}')
			flag = True
			break
	if flag == False:
		print('NO')


from collections import defaultdict
t = int(input())
while t:
	t -= 1
	(n, m) = [int(i) for i in input().split()]
	l1 = [int(i) for i in input().split()]
	l2 = [int(i) for i in input().split()]
	flag = 0
	num = 0
	for i in l2:
		if i in l1:
			num = i
			flag = 1
			break
	if flag == 1:
		print('YES')
		print('{} {}'.format(1, i))
	else:
		print('NO')


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


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def bit(xx):
	return [format(x, 'b') for x in xx]
popcnt = lambda x: bin(x).count('1')
for _ in range(II()):
	SI()
	exs = [False] * 1005
	for a in MI():
		exs[a] = True
	ans = []
	for b in MI():
		if exs[b]:
			print('YES')
			print(1, b)
			break
	else:
		print('NO')


import sys, os.path
from collections import deque
from fractions import Fraction as f

def IO():
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
		print = sys.stdout.write

def nextInt():
	return int(input())

def nextTuple():
	return [int(a) for a in input().split()]

def nextArray():
	return list(map(int, input().split()))

def nextLine():
	return input()

def nextStringArray():
	return list(input().split())
IO()
sb = ''
t = nextInt()
for _ in range(t):
	(n, m) = nextTuple()
	a = nextArray()
	b = nextArray()
	dict = {}
	for i in range(n):
		dict[a[i]] = 1
	ans = 0
	for i in range(m):
		if dict.get(b[i]) is not None:
			ans = b[i]
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


import sys

def input():
	return sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ele = -1
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ele = a[i]
				break
		if ele > 0:
			break
	if ele > 0:
		print('YES')
		print(1, ele)
	else:
		print('NO')


for _ in range(int(input())):
	input()
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	flag = 0
	for x in l1:
		if x in l2:
			print('YES')
			print(1, x)
			flag = 1
			break
	if flag == 0:
		print('NO')


for t in range(int(input())):
	(n1, n2) = map(int, input().split())
	l1 = set(map(int, input().split()))
	l2 = set(map(int, input().split()))
	if l1.intersection(l2):
		print('YES')
		print('1 ' + str(list(l1.intersection(l2))[0]))
	else:
		print('NO')


for T in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = 0
	ans = 0
	for x in a:
		for y in b:
			if x == y:
				ok = 1
				ans = x
	if ok:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())

def get():
	return list(map(int, input().split()))
for i in range(t):
	(ns, ms) = get()
	n = get()
	m = get()
	k = None
	for i in range(ns):
		if n[i] in m:
			k = i
			break
	if k != None:
		print('YES')
		print(1, n[k])
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	f = 0
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			f = 1
			break
	if f == 0:
		print('NO')
	t = t - 1


def readints():
	return map(int, input().split())

def main():
	_ = readints()
	a = set(readints())
	for e in readints():
		if e in a:
			print('YES\n1 {}'.format(e))
			return
	print('NO')
tests = int(input())
for _ in range(tests):
	main()


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	narr = set(map(int, input().split()))
	marr = list(map(int, input().split()))
	found = False
	res = -1
	for i in marr:
		if i in narr:
			found = True
			res = i
			break
	if found:
		print('YES')
		print(1, res)
	else:
		print('NO')


def f(a, b):
	se = set(a)
	for i in b:
		if i in se:
			print('YES')
			print(1, i)
			return
	print('NO')

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		f(a, b)
main()


T = int(input())
for i in range(T):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	ans = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				flag = 1
				ans = a[i]
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	L = list(map(int, input().split()))
	M = list(map(int, input().split()))
	flag = 0
	if n > m:
		for i in range(m):
			if M[i] in L:
				flag = 1
				val = M[i]
				break
	else:
		for i in range(n):
			if L[i] in M:
				flag = 1
				val = L[i]
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, val)


from sys import stdin
import math
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	b = [int(x) for x in inp().split() if int(x) in a]
	if b:
		print('YES')
		print(1, end=' ')
		print(b[0])
	else:
		print('NO')


def solve(a, b):
	ans = []
	for i in range(len(a) - 1):
		if a[i] != a[i + 1]:
			ans.append(i + 1)
	curr = a[-1]
	for i in range(len(a) - 1, -1, -1):
		if curr != b[i]:
			ans.append(i + 1)
			curr = not curr
	print(len(ans), ' '.join(map(str, ans)))

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		x = sorted(set(a).intersection(set(b)))
		if x == []:
			print('NO')
		else:
			print('YES')
			print(1, x[0])
main()


import sys
input = sys.stdin.readline
for f in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(y) for y in input().split()]
	k = set(a).intersection(set(b))
	if len(k):
		print('YES')
		k = list(k)
		print(1, k[0])
	else:
		print('NO')


n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	ar = sorted(map(int, input().split()))
	ar1 = sorted(map(int, input().split()))
	t = min(len(ar), len(ar1))
	ans = 0
	count = 0
	for i in range(t):
		if len(ar) <= len(ar1):
			if ar[i] in ar1:
				ans = ar[i]
				count = 1
				break
		elif ar1[i] in ar:
			ans = ar1[i]
			count = 1
			break
	if count == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	input()
	a = set(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = True
	for num in a:
		if num in b:
			print('YES')
			print(1, num)
			flag = False
			break
	if flag:
		print('NO')


def solve(n, m):
	target = 0
	for i in n:
		if i in m:
			return i
	if target == 0:
		return 'NO'
t = int(input())
for i in range(t):
	(n, m) = input().split()
	n = list(map(int, input().split()))
	m = list(map(int, input().split()))
	z = solve(n, m)
	if z == 'NO':
		print('NO')
	else:
		print('YES')
		print(f'1 {z}')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	arr1 = [int(x) for x in input().split()]
	arr = set(arr)
	arr1 = set(arr1)
	for each in arr:
		if each in arr1:
			print('YES')
			print('1', each)
			break
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	arr1 = input().split()
	arr2 = input().split()
	flag = 0
	for i in arr1:
		if i in arr2:
			print('YES')
			print('1 ' + i)
			flag = 1
			break
	if flag == 0:
		print('NO')
	t -= 1


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def myCode():
	(n, m) = In()
	a = L()
	b = L()
	if n <= m:
		for i in range(n):
			if a[i] in b:
				print('YES')
				print(1, a[i])
				return
	else:
		for i in range(m):
			if b[i] in a:
				print('YES')
				print(1, b[i])
				return
	print('NO')

def main():
	for t in range(I()):
		myCode()
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	k = min(len(a), len(b))
	c = 0
	j = 0
	while c < n:
		if a[c] in b:
			print('Yes')
			print('1', a[c])
			j = 1
			break
		c += 1
	if j != 1:
		print('NO')


import sys
input = sys.stdin.readline
for T in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[a[i]] = 1
	ans = -1
	for i in range(m):
		if d.get(b[i], 0):
			ans = b[i]
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
while t:
	line = input().split()
	(n, m) = (int(line[0]), int(line[1]))
	a = input().split()
	a = list(map(int, a))
	b = input().split()
	b = set(list(map(int, b)))
	ans = -1
	for x in a:
		if x in b:
			ans = x
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)
	t -= 1


t = int(input())

def subseq(a, b):
	for j in a:
		if j in b:
			return 'YES\n1 ' + str(j)
	return 'NO'
for i in range(t):
	(a_len, b_len) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	b = set([int(x) for x in input().split()])
	print(subseq(a, b))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	a.sort()
	b = list(map(int, input().split()))
	b.sort()
	k = 0
	x = 0
	for i in range(len(a)):
		for j in range(len(b)):
			if a[i] == b[j]:
				x = a[i]
				k = 1
				break
	if k == 0:
		print('NO')
	else:
		print('YES')
		print(1, x)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	i = 0
	j = 0
	lst = []
	while i < n and j < m:
		if a[i] == b[j]:
			lst.append(str(a[i]))
			break
			i += 1
			j += 1
		elif a[i] > b[j]:
			j += 1
		else:
			i += 1
	if len(lst) > 0:
		print('YES')
		print(1, end=' ')
		print(' '.join(lst))
	else:
		print('NO')


for _ in range(int(input())):
	(la, lb) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	flag = 0
	for i in a:
		if flag == 1:
			break
		for j in b:
			if i == j:
				print('YES')
				print(1, i)
				flag = 1
				break
			else:
				continue
	if flag == 0:
		print('NO')


n = int(input())
for _ in range(n):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	k = 0
	for i in range(n):
		if l[i] in l1:
			print('YES')
			print(1, l[i])
			k = 1
			break
	if k == 0:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	ch = True
	for i in range(n):
		for j in range(m):
			if s1[i] == s2[j] and ch:
				print('YES')
				print(1, s2[j])
				ch = False
	if ch:
		print('NO')


import math
import bisect
import copy
import time
from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	x = set(a).intersection(set(b))
	if len(x) == 0:
		print('NO')
	else:
		x = list(x)
		print('YES')
		print(1, x[0])


def solve():
	(n, m) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	if n >= m:
		for i in a1:
			if i in a2:
				return print(f'YES\n1 {i}')
		return print('NO')
	else:
		for i in a2:
			if i in a1:
				return print(f'YES\n1 {i}')
		return print('NO')
for _ in range(int(input())):
	solve()


t = int(input())

def solve(A, B):
	B = set(B)
	for a in A:
		if a in B:
			print('YES')
			print(1, a)
			return
	print('NO')
	return
for _ in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	solve(A, B)


t = int(input())

def solve(a, b):
	found = False
	ans = -1
	for i in range(len(a)):
		for j in range(len(b)):
			if a[i] == b[j]:
				found = True
				ans = a[i]
				break
		if found:
			break
	return ans
while t > 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = solve(a, b)
	if ans != -1:
		print('YES')
		print(1, ans)
	else:
		print('NO')
	t -= 1


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi
import heapq

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		(a, b) = In()
		l1 = list(In())
		l2 = list(In())
		d1 = dict(l1)
		d2 = dict(l2)
		ans = -1
		for x in d1:
			if d2.get(x, -1) != -1:
				ans = x
				break
		if ans == -1:
			no()
		else:
			yes()
			print(1, ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


t = int(input().split()[0])
for case in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for i in range(m):
		if b[i] in a:
			print('YES')
			print('1 ' + str(b[i]))
			flag = True
			break
	if flag == False:
		print('NO')


for tt in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	present = {}
	for i in a:
		present[i] = 1
	flag = True
	ans = -1
	for i in b:
		try:
			ans = present[i]
			ans = i
			flag = False
			break
		except:
			continue
	if flag:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	setA = set(a)
	flag = 0
	for i in b:
		if i in setA:
			flag = 1
			print('YES')
			print(1, i)
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a & b
	if c:
		print('YES')
		print(1, c.pop())
	else:
		print('NO')


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()))
	d = dict()
	for j in range(n):
		d[a[j]] = 1
	c = []
	for j in range(m):
		if b[j] in d.keys():
			c.append(b[j])
			break
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	f = False
	for i in x:
		if i in y:
			print('YES')
			print(1, i)
			f = True
			break
	if not f:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = {int(i) for i in input().split()}
	b = {int(i) for i in input().split()}
	c = a & b
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c.pop())


def help():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	b = set(b)
	for A in a:
		if A in b:
			print('YES')
			print(1, A)
			return
	print('NO')
t = int(input())
for T in range(t):
	help()


def Array(String):
	List = String.split(' ')
	for i in range(len(List)):
		List[i] = int(List[i])
	return List

def Shortest_sub(Array1, Array2):
	Found = False
	for i in range(len(Array1)):
		for j in range(len(Array2)):
			if Array1[i] == Array2[j]:
				Found = True
				Term = Array1[i]
				break
		if Array1[i] == Array2[j]:
			break
	if Found == True:
		print('YES')
		print('1 ' + str(Term))
	else:
		print('NO')
trials = int(input(''))
for i in range(trials):
	input('')
	List1 = Array(input(''))
	List2 = Array(input(''))
	Shortest_sub(List1, List2)


n = int(input())
for i in range(n):
	input()
	s1 = input().split()
	s2 = input().split()
	list1_as_set = set(s1)
	intersection = list(list1_as_set.intersection(s2))
	if intersection == []:
		print('NO')
	else:
		print('YES')
		print(1, intersection[0])


t = int(input())
R = lambda : map(int, input().split())
for i in range(t):
	(n, m) = R()
	a = list(set(R()))
	b = list(set(R()))
	flag = 0
	for j in range(len(a)):
		if a[j] in b:
			print('YES')
			print(1, a[j])
			flag = 1
			break
	if flag == 0:
		print('NO')


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	(n, m) = mInt()
	a = lInt()
	b = lInt()
	ans = 0
	if a > b:
		(a, b) = (b, a)
	for i in a:
		if i in b:
			ans = i
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr3 = [i for i in arr1 for j in arr2 if i == j]
	if len(arr3) == 0:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(arr3[0]))


def solve(n, m, a, b):
	a_logs = set()
	b_logs = set()
	for i in a:
		a_logs.add(i)
	arr = []
	for i in b:
		if i in a_logs:
			arr.append(i)
			break
	if len(arr):
		print('YES')
		print(len(arr), *arr)
	else:
		print('NO')
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	solve(n, m, a, b)


def solve():
	(n, m) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	n = int(n)
	m = int(m)
	dic = set()
	ans = ''
	for i in a:
		if i not in dic:
			dic.add(i)
	for i in b:
		if i in dic:
			print('YES')
			print(1, i)
			return
	print('NO')
	return
t = int(input())
for i in range(t):
	solve()


def scs(X, Y, m, n):
	if m == 0 or n == 0:
		return -1
	else:
		for x in X:
			if x in Y:
				return x
t = int(input())
for _ in range(t):
	(a_len, b_len) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	result = scs(a, b, a_len, b_len)
	if result == -1 or result == None:
		print('NO')
	else:
		print('YES')
		print('1 {}'.format(result))


numberOfTc = int(input())
for ctr in range(1, numberOfTc + 1):
	(m, n) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	for i in a:
		if i in b:
			print('YES', 1, i)
			break
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	x = a.intersection(b)
	if len(x) != 0:
		print('YES')
		z = x.pop()
		print(1, z)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(s) for s in input().split(' ')]
	a = [int(s) for s in input().split(' ')]
	b = [int(s) for s in input().split(' ')]
	values = []
	for el in a:
		if el in b:
			values.append(el)
			break
	if len(values) != 0:
		print('YES')
		print(len(values), values[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [*map(int, input().split())]
	b = [*map(int, input().split())]
	occ1 = [0] * 1001
	occ2 = [0] * 1001
	for i in range(n):
		occ1[a[i]] = 1
	for i in range(m):
		occ2[b[i]] = 1
	ok = False
	for i in range(1001):
		if occ1[i] and occ2[i]:
			print('YES')
			print(1, i)
			ok = True
			break
	if not ok:
		print('No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	t = min(n, m)
	count = 0
	if t == m:
		for i in range(t):
			if b[i] in a:
				count += 1
				print('YES')
				print(1, b[i])
				break
		if count == 0:
			print('NO')
	else:
		for i in range(t):
			if a[i] in b:
				count += 1
				print('YES')
				print(1, a[i])
				break
		if count == 0:
			print('NO')


x = int(input())
for i in range(x):
	d = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	dict1 = {}
	store = []
	for op in range(d[0]):
		dict1[arr1[op]] = 1
	for op in range(d[1]):
		if dict1.get(arr2[op]) != None:
			store.append(arr2[op])
			break
	if len(store) == 0:
		print('NO')
	else:
		print('YES')
		print(1, *store)


import sys
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = set(a)
	ans = -1
	for i in range(m):
		if b[i] in sa:
			ans = b[i]
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	f = False
	if n > m:
		for i in l:
			if i in l1:
				f = True
				print('YES')
				print(1, i)
				break
		if f:
			continue
		else:
			print('NO')
	else:
		for i in l1:
			if i in l:
				f = True
				print('YES')
				print(1, i)
				break
		if f:
			continue
		else:
			print('NO')


tc = int(input())
for i in range(tc):
	n = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	dir1 = {}
	flag = False
	for elem in arr1:
		dir1[elem] = True
	for elem in arr2:
		if elem in dir1:
			flag = True
			print('YES')
			print('1 ', elem)
			break
	if not flag:
		print('NO')


import sys
sys.setrecursionlimit(10000)
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_dict = {}
	for i in a:
		a_dict[i] = 1
	yes = 0
	for i in b:
		if i in a_dict:
			yes = 1
			break
	if yes == 1:
		print('YES')
		print('1', i)
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 5)
t = int(input())
while t:
	(m, n) = map(int, input().split())
	X = list(map(int, input().split()))
	Y = list(map(int, input().split()))
	s = set(X) & set(Y)
	if s:
		print('YES')
		print(1, s.pop())
	else:
		print('NO')
	t -= 1


from collections import defaultdict, Counter
from math import ceil
alph = 'abcdefghijklmnopqrstuvwxyz'
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	i = a.intersection(b)
	if not i:
		print('NO')
	else:
		print('YES')
		print(1, list(i)[0])


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q = -1
	for i in a:
		if i in b:
			q = i
			break
	if q == -1:
		print('NO')
	else:
		print('YES')
		print(1, q, end=' ')
	t = t - 1


for t in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = []
	a = list(map(int, input().split()))
	b = []
	b = list(map(int, input().split()))
	flag = 0
	for each in a:
		if each in b:
			print('YES')
			print('1', each)
			flag = 1
			break
	if flag == 0:
		print('NO')


from __future__ import division, print_function
import os, sys
import math
import collections
from itertools import permutations
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

class my_dictionary(dict):

	def __init__(self):
		self = dict()

	def add(self, key, value):
		self[key] = value

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(n - r))

def binary_search(arr, low, high, x):
	if high >= low:
		mid = (high + low) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binary_search(arr, low, mid - 1, x)
		else:
			return binary_search(arr, mid + 1, high, x)
	else:
		return -1

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def padded_bin_with_complement(x):
	if x < 0:
		return bin(2 ** 16 - abs(x))[2:].zfill(16)
	else:
		return bin(x)[2:].zfill(16)

def binaryToDecimal(binary):
	binary1 = binary
	(decimal, i, n) = (0, 0, 0)
	while binary != 0:
		dec = binary % 10
		decimal = decimal + dec * pow(2, i)
		binary = binary // 10
		i += 1
	print(decimal)

def CountFrequency(my_list):
	freq = {}
	for item in my_list:
		if item in freq:
			freq[item] += 1
		else:
			freq[item] = 1
	return freq

def pos(a):
	b = [0] * len(a)
	c = sorted(a)
	for i in range(len(a)):
		for j in range(len(a)):
			if c[j] == a[i]:
				b[i] = j
				break
	return b

def smallestDivisor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i * i <= n:
		if n % i == 0:
			return i
		i += 2
	return n

def commonn(a, b, n):
	c = []
	for i in range(n):
		if a[i] == b[i]:
			c.append('-1')
		else:
			c.append(b[i])
	return c

def primeFactors(n):
	j = []
	while n % 2 == 0:
		j.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			j.append(int(n))
			n = n / i
	if n > 2:
		j.append(int(n))
	return j

def sumdigit(n):
	n = str(n)
	k = 0
	for i in range(len(n)):
		k += int(n[i])
	return k

def largeseq1(a, cost, ini, des):
	ind = -1
	mx = -1000000007
	j = 0
	for i in range(des - 1, ini):
		if a[i] > mx:
			mx = a[i]
			j += cost[i]
			ind = i
	if ind != ini - 1:
		return -1
	else:
		return j

def largeseq2(a, cost, ini, des):
	ind = -1
	mx = -1000000007
	j = 0
	for i in range(des - 1, ini - 2, -1):
		if a[i] > mx:
			mx = a[i]
			j += cost[i]
			ind = i
	if ind != ini - 1:
		return -1
	else:
		return j

def main():
	for _ in range(ii()):
		(n, m) = mi()
		a = li()
		b = li()
		f = -1
		for i in a:
			if i in b:
				f = i
		if f != -1:
			print('YES')
			print(1, f)
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for tt in range(t):
	c = 0
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(0, len(a)):
		for j in range(0, len(b)):
			if a[i] == b[j]:
				c = 1
				p = a[i]
				break
		if c == 1:
			break
	if c == 1:
		print('YES')
		print(1, p)
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	d = str(input())
	s = d.split()
	n = int(s[0])
	m = int(s[1])
	da = str(input())
	a = da.split()
	db = str(input())
	b = db.split()
	z = 0
	ans = ''
	for i in a:
		if i in b:
			ans = i
			z = 1
			break
	if z != 0:
		print('YES')
		print(1, ans)
	else:
		print('NO')


import sys
input = sys.stdin.readline
from collections import *
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = set(a)
	sb = set(b)
	if len(sa & sb) >= 1:
		print('YES')
		print(1, list(sa & sb)[0])
	else:
		print('NO')


def sol():
	(n, m) = input().split()
	l1 = input().split()
	l2 = input().split()
	ok = -1
	for i in range(int(n)):
		for j in range(int(m)):
			if int(l1[i]) == int(l2[j]):
				ok = int(l1[i])
				break
		if ok != -1:
			break
	if ok == -1:
		print('NO')
	else:
		print('YES\n1', ok)
for test in range(int(input())):
	sol()


for i in range(int(input())):
	n = [int(i) for i in input().split()]
	arr1 = set([int(i) for i in input().split()])
	arr2 = set([int(i) for i in input().split()])
	if arr1 & arr2:
		print('YES')
		print(1, list(arr1 & arr2)[0])
	else:
		print('NO')


from sys import stdin, stdout
import math
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d = {}
	for x in a:
		d[x] = True
	found = False
	for x in b:
		if x in d:
			found = True
			print('YES')
			print('1 ' + str(x))
			break
	if not found:
		print('NO')


t = int(input())
for i in range(t):
	(size_a, size_b) = [int(s) for s in input().split(' ')]
	a = [int(s) for s in input().split(' ')]
	b = [int(s) for s in input().split(' ')]
	set_a = set(a)
	set_b = set(b)
	has_common = False
	for j in range(1, 1001):
		if j in set_a and j in set_b:
			has_common = True
			print('YES')
			print('1 {}'.format(j))
			break
	if not has_common:
		print('NO')


import os
import sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = set(list(map(int, input().split())))
		for i in range(n):
			if a[i] in b:
				print('YES')
				print(1, a[i])
				break
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	input()
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	ans = 'NO'
	for x in a:
		if x in b:
			ans = 'YES'
			break
	print(ans)
	if ans == 'YES':
		print(1, x)


t = int(input())
while t != 0:
	(n, m) = map(int, input().split())
	list1 = set(list(map(int, input().split())))
	list2 = set(list(map(int, input().split())))
	p = list(list1.intersection(list2))
	if len(p) == 0:
		print('NO')
	else:
		print('YES')
		print(1, p[0])
	t -= 1


def solve():
	(x, y) = map(int, input().split())
	dc = {}
	s = list(map(int, input().split()))
	z = list(map(int, input().split()))
	for n in z:
		dc[n] = 1
	for n in s:
		if n in dc:
			print('YES')
			print(1, n)
			return
	print('NO')
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	input()
	ans = set(map(int, input().split())) & set(map(int, input().split()))
	print('YES\n1 ' + str(ans.pop()) if ans else 'NO')


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, m) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	d1 = {}
	d2 = {}
	for i in a:
		d1[i] = True
	b.sort()
	chk = False
	for j in b:
		if j in d1:
			ans = j
			chk = True
			break
	if chk:
		print('YES')
		print(1, ans)
	else:
		print('NO')


def sol(lis1, lis2):
	s1 = set(lis1)
	s2 = set(lis2)
	p = s1.intersection(s2)
	if len(p) == 0:
		print('NO')
		return
	print('YES')
	print(1, end=' ')
	for i in p:
		print(i)
		break
k = int(input())
for i in range(k):
	(n, m) = list(map(int, input().split(' ')))
	lis1 = list(map(int, input().split(' ')))
	lis2 = list(map(int, input().split(' ')))
	sol(lis1, lis2)


for _ in range(int(input())):
	n = list(map(int, input().strip().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	z = list(set(a) & set(b))
	if len(z) >= 1:
		print('YES')
		print('1', z[0])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(ele) for ele in input().split()]
	set1 = set(map(int, input().split()))
	set2 = set(map(int, input().split()))
	com = set1 & set2
	if com:
		print('YES')
		print(1, list(com)[0])
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	for i in a:
		j = b.count(i)
		if j >= 1:
			flag = 1
			print('YES')
			print(1, i)
			break
	if flag == 0:
		print('NO')
	t = t - 1


def package_turple(*a_turple):
	print(type(a_turple))
	print(a_turple)
	print(a_turple[-2])

def package_dictionary(**a_dictionary):
	print(type(a_dictionary))
	print(a_dictionary)
	print(a_dictionary['a'])

def unpackage(a, b, c):
	print(a, b, c)
a = {'a': 1, 'b': 7, 'c': 3}
T = int(input())
for o in range(T):
	x = input()
	x = x.split(sep=' ')
	n = x[0]
	m = x[1]
	a = list()
	b = list()
	aa = input()
	a = aa.split(sep=' ')
	bb = input()
	b = bb.split(sep=' ')
	ok = -1
	for i in a:
		for j in b:
			if i == j:
				ok = i
	if ok == -1:
		print('NO')
	else:
		print('YES')
		print('1 ', end='')
		print(ok)


t = int(input())
for test in range(t):
	(n, m) = input().split()
	a = set(input().split())
	b = set(input().split())
	flag = False
	value = 0
	for i in a:
		if i in b:
			flag = True
			value = i
			break
		if flag:
			break
	if flag:
		print('YES')
		print(1, value)
	else:
		print('NO')


t = int(input())
for i in range(t):
	x = input().split()
	n = int(x[0])
	m = int(x[1])
	a = [0 for i in range(1, 1002)]
	b = input().split()
	b = list(map(int, b))
	for j in b:
		a[j] = 1
	b = input().split()
	b = list(map(int, b))
	k = 0
	for j in b:
		if a[j] == 1:
			k = 1
			print('YES')
			print('1', j)
			break
	if k == 0:
		print('NO')


t = int(input())
while t > 0:
	(n1, n2) = input().split()
	n1 = int(n1)
	n2 = int(n2)
	lis1 = [int(a) for a in input().split()]
	lis2 = [int(a) for a in input().split()]
	lis1.sort()
	lis2.sort()
	ins = []
	i = 0
	j = 0
	while i < n1 and j < n2:
		if lis1[i] == lis2[j]:
			ins.append(lis1[i])
			i += 1
			j += 1
		elif lis1[i] < lis2[j]:
			i += 1
		else:
			j += 1
	if len(ins) == 0:
		print('NO')
	else:
		print('YES')
		print(1, ins[0])
	t -= 1


t = int(input())
o = []
for each in range(t):
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				c = a[i]
				break
		if c > 0:
			break
	if c > 0:
		o.append(['YES', [1, c]])
	else:
		o.append(['NO'])
for i in o:
	if len(i) == 2:
		print(i[0])
		print(*i[1])
	else:
		print(i[0])


import sys
input = sys.stdin.buffer.readline

def solution():
	d = {}
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(n):
		d[a[i]] = 1
	for i in range(m):
		if d.get(b[i]) == 1:
			print('YES')
			print(1, b[i])
			return
	print('NO')
for _ in range(int(input())):
	solution()


for i in range(int(input())):
	(m, n) = map(int, input().split())
	a1 = set(input().split())
	a2 = set(input().split())
	j = a1.intersection(a2)
	li = list(j)
	if len(li) > 0:
		print('YES')
		print(1, li[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [val for val in a if val in b]
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


t = int(input())
for _ in range(t):
	flag1 = 0
	(n, m) = map(int, input().split())
	z = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(len(z)):
		if z[i] in b:
			flag1 = 1
			print('YES')
			print(1, z[i])
			break
	if flag1 == 0:
		print('NO')


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()))
	f = 0
	for j in a:
		if j in b:
			print('YES')
			print('1' + ' ' + str(j))
			f = 1
			break
	if f == 0:
		print('NO')


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


from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *
for __ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	ans = False
	rslt = -1
	for i in range(n):
		d[a[i]] = 1
	for i in range(m):
		if d.get(b[i]) != None:
			ans = True
			rslt = b[i]
			break
	if ans:
		print('YES')
		print(1, rslt)
	else:
		print('NO')


from collections import defaultdict
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d1 = defaultdict(int)
	d2 = defaultdict(int)
	for i in l1:
		d1[i] += 1
	for i in l2:
		d2[i] += 1
	f = 0
	for i in d1:
		if i in d2:
			f = 1
			print('YES')
			print(1, i)
			break
	if f == 0:
		print('NO')


n = int(input())
for i in range(n):
	(al, bl) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s1 = []
	for j in a:
		if j in b:
			s1.append(j)
	k = len(s1)
	if k == 0:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(s1[0])


for _ in range(int(input())):
	(a, b) = list(map(int, input().split()))
	arr = set(map(int, input().split()))
	brr = set(map(int, input().split()))
	d = arr & brr
	if len(d) == 0:
		print('NO')
	else:
		d = list(d)
		print('YES')
		print(' '.join(['1', str(d[0])]))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	nlis = [int(i) for i in input().split()]
	mlis = [int(i) for i in input().split()]
	intersect = list(set(nlis).intersection(set(mlis)))
	if len(intersect) > 0:
		print('YES')
		print(1, intersect[0])
	else:
		print('NO')


T = int(input())
while T > 0:
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	dic = set()
	for i in range(n):
		dic.add(arr1[i])
	find = False
	ele = ''
	for i in range(m):
		if arr2[i] in dic:
			find = True
			ele = str(arr2[i])
			break
	if find is False:
		print('NO')
	else:
		print('YES')
		print('1 ' + ele)
	T -= 1


num_cases = int(input())
for case in range(num_cases):
	arr_lengths = [int(num) for num in input().split()]
	arr_a = [int(num) for num in input().split()]
	arr_b = [int(num) for num in input().split()]
	sub = False
	num1 = -1
	for num in arr_a:
		if num in arr_b:
			sub = True
			num1 = num
			break
	if sub:
		print('YES')
		print(1, num1)
	else:
		print('NO')


a = int(input())
for i in range(a):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	s = a & b
	a = list(a)
	b = list(b)
	if len(s) != 0:
		print('YES')
		for j in s:
			print('1', j)
			break
	else:
		print('NO')


total_size = int(input())
for i in range(total_size):
	(row, col) = input().split(' ')
	ls1 = list(map(int, input().split()))
	ls2 = list(map(int, input().split()))
	ls1.sort()
	ls2.sort()
	cou = False
	vl = 0
	for i in range(len(ls1)):
		for j in range(len(ls2)):
			if ls1[i] == ls2[j]:
				vl = ls1[i]
				cou = True
				break
	if cou:
		print('YES')
		print(1, vl)
	else:
		print('NO')


t = int(input())
for var in range(0, t):
	nm = []
	nm = input().split()
	for k in range(2):
		n = int(nm[0])
		m = int(nm[1])
	a = []
	a = input().split()
	for i in range(0, n):
		a[i] = int(a[i])
	b = []
	b = input().split()
	for j in range(m):
		b[j] = int(b[j])
	if n >= m:
		flag1 = 0
		for i in range(len(a)):
			if a[i] in b:
				print('YES')
				print(1, end=' ')
				print(a[i])
				flag1 = 1
				break
		if flag1 == 0:
			print('NO')
	elif m >= n:
		flag2 = 0
		for i in range(len(b)):
			if b[i] in a:
				print('YES')
				print(1, end=' ')
				print(b[i])
				flag2 = 1
				break
		if flag2 == 0:
			print('NO')


n = int(input())
for _ in range(0, n):
	(m, o) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = set(a)
	d = set(b)
	s = c & d
	t = list(s)
	if s:
		print('YES')
		print(f'{1} {t[0]}')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

def getVars():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	(n, m) = getVars()
	a = getList()
	b = getList()
	a.sort()
	b.sort()
	aKey = 0
	bKey = 0
	res = False
	res1 = 0
	while aKey < n and bKey < m:
		if a[aKey] == b[bKey]:
			res = True
			res1 = a[aKey]
			break
		if a[aKey] < b[bKey]:
			aKey += 1
		else:
			bKey += 1
	if res:
		print('YES')
		print(1, res1)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	if n < m:
		for i in a:
			if i in b:
				c = 1
				print('YES')
				print('1 {}'.format(i))
				break
	else:
		for i in b:
			if i in a:
				c = 1
				print('YES')
				print('1 {}'.format(i))
				break
	if c == 0:
		print('NO')


iteration = int(input())
ans = []
for i in range(iteration):
	s = input().split(' ')
	l1 = int(s[0])
	l2 = int(s[1])
	a1 = input().split(' ')
	a2 = input().split(' ')
	arr = []
	done = False
	for x in a1:
		for y in a2:
			if x == y:
				arr.append(x)
				break
				done = True
		if done == True:
			breakp
	if len(arr) == 0:
		ans.append('NO')
	else:
		ans.append('YES')
		ans.append('1 ' + arr[0])
for x in ans:
	print(x)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'NO'
	if len(a) > len(b):
		(a, b) = (set(b), a)
	else:
		(a, b) = (set(a), b)
	for i in range(len(b)):
		if b[i] in a:
			ans = 'YES'
			print(ans)
			print(1, b[i])
			break
	else:
		print(ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	s1 = set(a)
	s2 = set(b)
	x = s1.intersection(s2)
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		p = x.pop()
		print('1', p)


from collections import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = Counter(a)
	d = Counter(b)
	if c & d:
		print('YES')
		for i in c & d:
			break
		print(1, i)
	else:
		print('NO')


import sys
inf = int(10000000000.0)
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	g = 0
	(n, m) = map(int, input().split())
	lis = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	for i in lis:
		for j in lis2:
			if i == j:
				g = 1
				print('YES')
				print(1, i)
				break
		if g:
			break
	if not g:
		print('NO')


import math
import os
import random
import re
import sys
import copy
from collections import Counter

def bs(arr, x, l, r):
	if l <= r:
		mid = (r + l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			return bs(arr, x, mid + 1, r)
		else:
			return bs(arr, x, l, mid - 1)
	else:
		return -1

def solve():
	for _ in range(int(input())):
		(n, m) = map(int, input().strip().split())
		l1 = list(map(int, input().strip().split()))
		l2 = list(map(int, input().strip().split()))
		s1 = set(l1)
		s2 = set(l2)
		s = s1.intersection(s2)
		s = list(s)
		if len(s) > 0:
			print('YES')
			print(1, s[0])
		else:
			print('NO')
solve()


n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	ai = [int(i) for i in input().split()]
	bi = [int(i) for i in input().split()]
	flag = 0
	for x in ai:
		if x in bi:
			flag = 1
			print('YES')
			print(1, x)
			break
	if flag:
		continue
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	if n > m:
		x = l1
		y = l2
	elif n < m:
		x = l2
		y = l1
	else:
		x = l1
		y = l2
	c = 0
	for i in x:
		if c == 1:
			break
		elif i in y:
			r = i
			c += 1
	if c == 1:
		print('YES')
		print(1, r)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split(' ')]
	an = [int(i) for i in input().split(' ')]
	am = [int(i) for i in input().split(' ')]
	x = 0
	for j in range(n):
		for k in range(m):
			if an[j] == am[k]:
				x = 1
				print('Yes')
				print('1' + ' ' + str(an[j]))
				break
		if x == 1:
			break
	if x == 0:
		print('No')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	B = list(map(int, input().split(' ')))
	l = n
	flag = 0
	for i in range(n):
		if A[i] in B:
			flag = 1
			print('YES')
			print('{} {}'.format('1', str(A[i])))
			break
		else:
			pass
	if flag == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	s1 = set(map(int, input().split()))
	s2 = set(map(int, input().split()))
	l = list(s1.intersection(s2))
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(l[0]))


T = int(input())
for i in range(T):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(count, m, j) = (0, [], 0)
	while j < len(a):
		for k in range(len(b)):
			if a[j] == b[k]:
				count += 1
				m.append(b[k])
		j += 1
	if count == 0:
		print('No')
	else:
		print('Yes')
		for h in m:
			pass
		print(1, h)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	aa = [int(s) for s in input().split()]
	bb = [int(s) for s in input().split()]
	tet = []
	for k in aa:
		if bb.count(k):
			tet.append(k)
			break
	if len(tet) > 0:
		print('YES')
		print(len(tet), *tet)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(p, q) = (set(map(int, input().split())), set(map(int, input().split())))
	s = list(p & q)
	if len(s) != 0:
		print('YES')
		print(1, s[0])
	else:
		print('NO')


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


for _ in range(int(input())):
	(n, m) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(yes, ele) = (False, None)
	for i in a:
		if i in b:
			yes = True
			ele = i
			break
	if yes:
		print('YES')
		print(1, ele)
	else:
		print('NO')


num = int(input())
for i in range(num):
	t = input()
	l = list(input().split(' '))
	s = set(l)
	res = 'NO'
	temp = ''
	for c in input().split(' '):
		if c in s:
			res = 'YES'
			temp = c
			break
	if res != 'NO':
		print(res)
		print('1 ' + temp)
	else:
		print(res)


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = 0
	i = 0
	j = 0
	while i < n and j < m:
		if a[i] == b[j]:
			ans = a[i]
			break
		elif a[i] < b[j]:
			i = i + 1
		elif a[i] > b[j]:
			j = j + 1
	if ans:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(s) for s in input().split()]
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	ans = False
	for k in a:
		if k in b:
			print('YES')
			print(1, k)
			ans = True
			break
	if ans == False:
		print('NO')


try:
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		l = list(map(int, input().split()))
		l1 = list(map(int, input().split()))
		c = 0
		u = 0
		p = len(l)
		p1 = len(l1)
		p2 = p * p1
		for i in l:
			for j in l1:
				if i == j:
					u = -1
					print('YES')
					print('1', end=' ')
					print(i)
					break
				else:
					c += 1
			if u == -1:
				break
		if c == p2:
			print('NO')
except:
	pass


t = int(input())
for caseNr in range(1, t + 1):
	nm = list(map(int, input().split()))
	a_s = list(map(int, input().split()))
	b_s = list(map(int, input().split()))
	lst = [value for value in a_s if value in b_s]
	if not lst:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(lst[0]))


for i in range(int(input())):
	(n, m) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for j in range(len(a)):
		if a[j] in b:
			flag = True
			k = a[j]
			break
	if flag == False:
		for j in range(len(b)):
			if b[j] in a:
				flag = True
				k = b[j]
				break
	if flag == True:
		print('YES')
		print('1', k)
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = input().split(' ')
	l1 = [int(x) for x in input().split(' ')]
	l2 = [int(x) for x in input().split(' ')]
	l1 = set(l1) & set(l2)
	l1 = list(l1)
	if len(l1):
		print('YES')
		print(1, l1[0])
	else:
		print('NO')


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = []
	for i in a:
		if i in b:
			ans.append(i)
			break
		if len(ans) == 1:
			break
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans[0])


CASES = int(input())
for case in range(CASES):
	(l1, l2) = [int(x) for x in input().split(' ')]
	seq1 = [int(x) for x in input().split(' ')]
	seq2 = [int(x) for x in input().split(' ')]
	shared_subsequence = []
	for e in seq1:
		if e in seq2:
			shared_subsequence.append(e)
			break
	if len(shared_subsequence):
		print('YES')
		print(len(shared_subsequence), *shared_subsequence, sep=' ')
	else:
		print('NO')


t = int(input())
for k in range(t):
	s = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = 0
	for i in range(s[0]):
		for j in range(s[1]):
			if a[i] == b[j]:
				c = 1
				print('YES')
				print(1, a[i])
				break
		if c == 1:
			break
	if c == 0:
		print('NO')


tests = int(input())
for t in range(tests):
	(n, m) = list(map(int, input().split()))
	ls_1 = list(map(int, input().split()))
	ls_1 = set(ls_1)
	ls_2 = list(map(int, input().split()))
	ls_2 = set(ls_2)
	res = [1]
	if len(ls_1.intersection(ls_2)) == 0:
		print('NO')
	else:
		print('YES')
		res.append(ls_1.intersection(ls_2).pop())
		print(' '.join(list(map(str, res))))


import sys
import math
from sys import stdin, stdout

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def main():
	for t in range(int(input())):
		(a, b) = get_ints()
		x = get_list()
		y = get_list()
		x1 = set(x)
		y1 = set(y)
		d = {}
		for i in x:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		for i in y:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		f = 0
		for i in d:
			if d[i] >= 2 and i in x1 and (i in y1):
				f = 1
				z = i
				break
		if f == 0:
			print('NO')
		else:
			print('YES')
			print(1, z)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


l = int(input())
for o in range(l):
	(n, m) = map(int, input().split())
	a = set(input().split())
	b = set(input().split())
	for k in a:
		if k in b:
			print('YES')
			print('1 ', k)
			break
	else:
		print('NO')


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	c = map(int, input().split())
	x = list(c)
	d = map(int, input().split())
	y = list(d)
	lis = []
	if a <= b:
		for i in range(a):
			for j in range(b):
				if x[i] == y[j]:
					lis.append(x[i])
				else:
					pass
		if len(lis) > 0:
			print('YES')
			print('1', lis[0])
		else:
			print('NO')
	elif b < a:
		for i in range(b):
			for j in range(a):
				if y[i] == x[j]:
					lis.append(y[i])
				else:
					pass
		if len(lis) > 0:
			print('YES')
			print('1', lis[0])
		else:
			print('NO')


for never_used in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	if len(a.intersection(b)):
		print('YES')
		print(1, a.intersection(b).pop())
	else:
		print('NO')


test = int(input())
k = 1
while k <= test:
	k += 1
	[n, m] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	count = [0 for i in range(1001)]
	flag = 0
	for i in a:
		count[i] += 1
	for i in b:
		if count[i] >= 1:
			flag = 1
			print('YES')
			print(1, end=' ')
			print(i)
			break
	if flag == 0:
		print('NO')


tc = int(input())
while tc:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = -1
	for v in a:
		if v in b:
			ans = v
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, '', ans)
	tc -= 1


import sys
q = int(input())
for i in range(q):
	(n, m) = [int(j) for j in sys.stdin.readline().split()]
	a = [int(j) for j in sys.stdin.readline().split()]
	b = [int(j) for j in sys.stdin.readline().split()]
	for i in range(n):
		flag = 0
		for j in range(m):
			if a[i] == b[j]:
				print('YES')
				print(1, a[i])
				flag = 1
				break
		if flag == 1:
			break
	else:
		print('NO')


from collections import defaultdict as dd
from sys import stdin, stdout
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a).intersection(set(b))
	if len(a) == 0:
		print('NO')
		continue
	print('YES\n1 ', a.pop())


import math as mt
import sys, string
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
from collections import defaultdict
t = I()
for _ in range(t):
	(n, m) = M()
	a = set(L())
	b = set(L())
	x = a.intersection(b)
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		print(1, list(x)[0])


def isCommon(a, b):
	s = set(a).intersection(b)
	if len(s) == 0:
		return 0
	return s
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if isCommon(a, b) == 0:
		print('NO')
	else:
		print('YES')
		k = 1
		common = list(isCommon(a, b))
		print(k, common[0])


def Solve(a, b):
	a_set = set(a)
	b_set = set(b)
	c = a_set.intersection(b_set)
	c = list(c)
	if c:
		print('YES')
		print(1, c[0])
	else:
		print('NO')
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	Solve(a, b)


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = True
	for i in range(len(a)):
		for j in range(len(b)):
			if a[i] == b[j]:
				print('YES')
				print(1, '', a[i])
				f = False
				break
		if f == False:
			break
	if f:
		print('NO')


n = int(input())
for _ in range(n):
	(x, y) = input().split()
	x = int(x)
	y = int(y)
	L1 = list(map(int, input().rstrip().split()))[:x]
	L2 = list(map(int, input().rstrip().split()))[:y]
	count = 0
	x = 0
	for i in L1:
		if i in L2:
			count += 1
			x = i
	if count > 0:
		print('YES')
		print(1, x)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = list(map(int, input().split(' ')))
	X = list(map(int, input().split(' ')))
	Y = list(map(int, input().split(' ')))
	ans = 10000
	for i in range(m):
		for j in range(n):
			if X[i] == Y[j]:
				ans = min(ans, X[i])
	if ans != -1 and ans <= 1000:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for ii in range(int(input())):
	(x, y) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = list(a & b)
	if c:
		print('YES')
		print(1, c[0])
	else:
		print('NO')


for i in range(int(input())):
	(a, b) = input().split()
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l.sort()
	l1.sort()
	l2 = []
	for i in range(len(l)):
		for j in range(len(l1)):
			if l[i] == l1[j]:
				l2.append(l[i])
				break
		if l[i] == l1[j]:
			break
	if len(l2) > 0:
		print('YES')
		print('1', *l2)
	else:
		print('NO')


import math
from collections import defaultdict, deque
from bisect import bisect_left, bisect_right
from sys import stdin

def mp():
	return map(int, stdin.readline().split())

def ml():
	return list(map(int, stdin.readline().split()))
for _ in range(int(input())):
	(n, m) = mp()
	a = ml()
	b = ml()
	flag = False
	ans = -1
	for x in a:
		if x in b:
			flag = True
			ans = x
			break
	if flag:
		print('YES')
		print(1, x)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	cnt = [0 for i in range(1001)]
	for i in B:
		cnt[i] += 1
	ans = -1
	for i in A:
		if cnt[i] >= 1:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


n = int(input())
for _ in range(n):
	line = input()
	(n, m) = [int(x) for x in line.split()]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	n = 0
	for i in a:
		if i in b:
			ans += 1
			n = i
			break
	if ans > 0:
		print('YES')
		print(ans, i)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = input().split()
	a_seq = input().split()
	b_seq = set(input().split())
	for a in a_seq:
		if a in b_seq:
			print('YES')
			print(1, a)
			break
	else:
		print('NO')


t = int(input())
for l in range(t):
	(n, k) = input().split(' ')
	a1 = input().strip().split(' ')
	a2 = input().strip().split(' ')
	dic = {}
	for i in a1:
		dic[i] = 1
	check = True
	for i in a2:
		if i in dic:
			print('YES')
			print(1, i)
			check = False
			break
	if check:
		print('NO')


t = int(input())
for i in range(t):
	(m, n) = list(map(int, input().split()))
	ml = list(map(int, input().split()))
	nl = list(map(int, input().split()))
	v = 0
	for j in ml:
		if v != 1:
			for k in nl:
				if j == k:
					print('YES')
					print('1 ' + str(j))
					v = 1
					break
	if v == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	ina = [0] * 1001
	inb = [0] * 1001
	ans = -1
	for i in a:
		ina[i] = 1
	for i in b:
		if ina[i] == 1:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


def main():
	for _ in range(int(input())):
		input()
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		x = -1
		for i in a:
			for j in b:
				if i == j:
					x = i
		if x == -1:
			print('NO')
		else:
			print('YES')
			print(1, x)
main()


n = int(input())
for i in range(n):
	m = input()
	a = input()
	a = a.split()
	a = list(map(int, a))
	b = input()
	b = b.split()
	b = list(map(int, b))
	flag = False
	for e in a:
		if flag is True:
			break
		if e in b:
			print('YES')
			print(1, e)
			flag = True
	if flag is False:
		print('NO')


from random import choice

def main():
	n = int(input())
	res = None
	for i in range(n):
		(n, m) = map(int, input().split())
		a = set([int(x) for x in input().split()])
		b = set([int(x) for x in input().split()])
		temp = a.intersection(b)
		if temp != set():
			res = choice(list(temp))
			print('YES')
			print(1, res)
		else:
			print('NO')
	return 1
main()


n1 = int(input())
for x in range(n1):
	n2 = input().split(' ')
	size1 = int(n2[0])
	size2 = int(n2[1])
	n3 = input().split(' ')
	n4 = input().split(' ')
	a1 = set()
	a2 = set()
	for y in range(size1):
		a1.add(int(n3[y]))
	for y in range(size2):
		a2.add(int(n4[y]))
	c = a1 & a2
	if len(c) >= 1:
		print('YES')
		print(1, c.pop(), end=' ')
		print('')
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	m = max([max(arr1), max(arr2)])
	arr = [0 for i in range(m + 1)]
	for ele in arr1:
		arr[ele] = 1
	for ele in arr2:
		arr[ele] = 2 if arr[ele] == 1 else arr[ele]
	ans = 'NO'
	ans1 = 0
	for i in range(len(arr)):
		if arr[i] > 1:
			ans = 'YES'
			ans1 = i
			break
	if ans == 'YES':
		print(ans)
		print(1, ans1)
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	br = list(map(int, input().split()))
	sr = set(arr)
	tr = set(br)
	kr = sr.intersection(tr)
	if len(kr) == 0:
		print('NO')
	else:
		print('YES')
		print(1, kr.pop())


def smallest_k(a, b):
	distinct_b = set(b)
	for num in a:
		if num in distinct_b:
			return num
	return None
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result = smallest_k(a, b)
	if not result:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(result))


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	done = 0
	for ai in a:
		if ai in b:
			print('YES')
			print(1, ai)
			done = 1
			break
	if done == 0:
		print('NO')


CaseNo = int(input())
for x in range(CaseNo):
	Length = input().split()
	LenA = int(Length[0])
	LenB = int(Length[1])
	StringA = [int(a) for a in input().split()]
	StringB = [int(b) for b in input().split()]
	StringNew = list()
	for y in range(LenA):
		if StringA[y] in StringB:
			StringNew.append(StringA[y])
			break
	LenNew = len(StringNew)
	if LenNew > 0:
		LenValue = StringNew[0]
		print('YES')
		print(1, LenValue)
	else:
		print('NO')


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def cnt(s, sub):
	c = 0
	for i in range(len(s) - len(sub) + 1):
		for j in range(i, i + len(sub)):
			if s[j] != sub[j - i]:
				break
		else:
			c += 1
	return c

def main():
	(n, m) = vars()
	a = array()
	b = array()
	ans = None
	ma = Counter(a)
	for i in b:
		if i in ma:
			ans = i
			break
	if ans != None:
		print('YES')
		print(1, ans)
	else:
		print('NO')
t = int(input())
for _ in range(t):
	main()


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


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ndata = list(map(int, input().split()))
	mdata = list(map(int, input().split()))
	flag = 0
	for i in ndata:
		if i in mdata:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [value for value in a if value in b]
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(c[0])


test = int(input())

def solve():
	arr = [int(i) for i in input().split()]
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	for i in range(len(arr1)):
		for j in range(len(arr2)):
			if arr1[i] == arr2[j]:
				print('YES')
				print('1', arr1[i])
				return
	print('NO')
while test:
	solve()
	test -= 1


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	arr_1 = list(map(int, input().split()))
	arr_2 = list(map(int, input().split()))
	hast_table = [0 for i in range(1000)]
	for num in arr_1:
		hast_table[num - 1] += 1
	found = False
	for no in arr_2:
		if hast_table[no - 1]:
			found = True
			print('YES')
			print(1, no)
			break
	if not found:
		print('NO')


t = int(input())
for s in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	visited = [0 for i in range(1001)]
	visit = [0 for i in range(1001)]
	for i in range(n):
		visited[a[i]] += 1
	for i in range(m):
		visit[b[i]] += 1
	flag = 0
	for i in range(1001):
		if visited[i] != 0 and visit[i] != 0:
			flag = 1
			break
	if flag == 1:
		print('YES')
		print(1, i)
	else:
		print('NO')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('../output.txt', 'w')
except:
	pass
t = int(input())
for term in range(t):
	(n, m) = L()
	A = L()
	B = L()
	ans = 'NO'
	for ele in A:
		if ele in B:
			ans = 'YES'
			x = ele
			break
	if ans == 'NO':
		print(ans)
	else:
		print(ans)
		print(1, x)


tests = int(input())
for test in range(tests):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = set(a) & set(b)
	if len(c) == 0:
		print('No')
	else:
		print('Yes')
		print(1, list(c)[0])


t = int(input())
while t:
	t = t - 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	b = set(b)
	out = a.intersection(b)
	if len(out) == 0:
		print('NO')
	else:
		print('YES')
		l = list(out)
		print(1, l[0])


t = int(input())
for i in range(0, t):
	c = []
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n >= m:
		for j in range(0, m):
			if b[j] in a:
				a = a[a.index(b[j]):]
				c.append(b[j])
				break
	elif n <= m:
		for j in range(0, n):
			if a[j] in b:
				c.append(a[j])
				b = b[b.index(a[j]):]
				break
	if len(c) != 0:
		print('YES')
		print(len(c), *c)
	elif len(c) == 0:
		print('NO')


for _ in range(int(input())):
	n = list(map(int, input().strip().split()))
	(lena, lenb) = (n[0], n[1])
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	flag = 0
	x = list(set(a).intersection(set(b)))
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		print(1, x[0])


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	b = set(b)
	check = True
	for (i, v) in enumerate(a):
		if v in b:
			check = True
			r = v
			break
		else:
			check = False
	if check:
		print('YES')
		print(1, r)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	x = [int(x) for x in input().split()]
	y = [int(x) for x in input().split()]
	x = set(x)
	y = set(y)
	z = x.intersection(y)
	if len(z) > 0:
		print('YES')
		z = list(z)
		print(1, z[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	k = []
	flag = 0
	for i in l:
		if i in l2:
			flag = 1
			k.append(i)
			break
	if k == [] and flag == 0:
		print('NO')
	else:
		print('YES')
		print(len(k), *k)


from sys import stdin, stdout

def input():
	return stdin.readline().strip()

def ans(A, B):
	intersect = set(A) & set(B)
	if len(intersect) == 0:
		print('NO')
		return
	i = list(intersect)[0]
	print('YES')
	print(1, i)
T = int(input())
for _ in range(T):
	input()
	A = input().split(' ')
	A = list(map(int, A))
	B = input().split(' ')
	B = list(map(int, B))
	ans(A, B)


x = int(input())
for i in range(x):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	check = 0
	for ii in range(n):
		for iii in range(m):
			if a[ii] == b[iii]:
				print('YES')
				print(1, a[ii])
				check = 1
				break
		if check == 1:
			break
	if check == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	count = 0
	for i in l1:
		if i in l2:
			count = 1
			break
	if count == 1:
		print('YES')
		print(1, i)
	else:
		print('NO')


def sol(a, b):
	nlst = []
	if sorted(a) == sorted(b):
		print('YES')
		print(1, a[-1])
		return
	for i in a:
		if i in b:
			nlst.append(i)
	if len(nlst) == 0:
		print('NO')
		return
	else:
		print('YES')
		print(1, nlst[0])
		return
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sol(a, b)


t = int(input())
ans = []
for i in range(t):
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	for i in b:
		if i in a:
			ans.append('YES')
			ans.append('1' + ' ' + str(i))
			flag = 1
			break
	if flag == 0:
		ans.append('NO')
for i in ans:
	print(i)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	nList = list(map(int, input().split()))
	mList = list(map(int, input().split()))
	flag = False
	for i in nList:
		if i in mList:
			print('YES')
			print(1, i)
			flag = True
			break
	if flag == False:
		print('NO')


T = int(input())
for _ in range(T):
	(m, n) = input().split(' ')
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	A = {}
	for i in a:
		if i not in A:
			A[i] = 0
		A[i] += 1
	found = False
	for i in b:
		if i in A:
			found = True
			print('YES')
			print(1, i)
			break
	if not found:
		print('NO')


T = int(input())
for t in range(T):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	ret = None
	if n < m:
		for key in a:
			if key in b:
				ret = key
				break
	else:
		for key in b:
			if key in a:
				ret = key
				break
	if ret != None:
		print(f'YES\n{1} {ret}')
	else:
		print('NO')


testcases = int(input())
for i in range(testcases):
	n = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result = list(set(a) & set(b))
	if len(result) == 0:
		print('NO')
	else:
		print('YES')
		print(1, result[0])


def function(arrayA, setB):
	for i in arrayA:
		if i in setB:
			return i
	return -1
for i in range(int(input())):
	(A, B) = [int(x) for x in input().split()]
	arrayA = [int(x) for x in input().split()]
	setB = set([int(x) for x in input().split()])
	if function(arrayA, setB) != -1:
		print('YES')
		print('1 ' + str(function(arrayA, setB)))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = set(map(int, input().split()))
	brr = set(map(int, input().split()))
	if len(arr.intersection(brr)) >= 1:
		print('YES')
		print(1, list(arr.intersection(brr))[0])
	else:
		print('NO')


from sys import stdin
for case in range(int(stdin.readline())):
	(n, m) = [int(x) for x in stdin.readline().split()]
	n = set([int(x) for x in stdin.readline().split()])
	m = set([int(x) for x in stdin.readline().split()])
	bruh = n.intersection(m)
	if bruh:
		for x in bruh:
			print('YES')
			print(1, x)
			break
	else:
		print('NO')


def sid():
	f = 1
t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	sid()
	f = 0
	for j in range(m):
		if l1[j] in l2:
			print('YES')
			print(1, l1[j])
			f = 1
			break
	if f == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if m < n:
		(a, b) = (b, a)
	out = False
	for i in a:
		if i in b:
			out = True
			break
	if out:
		print('YES')
		print(1, i)
	else:
		print('NO')


from collections import defaultdict

def inp():
	return map(int, input().split(' '))
for _ in range(int(input())):
	(n, m) = inp()
	a = [*inp()]
	b = [*inp()]
	d = {}
	d = defaultdict(lambda : 0, d)
	for i in a:
		d[i] = 1
	ans = 0
	for i in b:
		if d[i] == 1:
			print('YES')
			print(*[1, i])
			ans = 1
			break
	if ans == 0:
		print('NO')


t = int(input())
for test in range(t):
	(n, m) = [int(x) for x in input().split()]
	a1 = [int(x) for x in input().split()]
	a2 = [int(x) for x in input().split()]
	dict = {}
	for i in a1:
		dict[i] = 0
	found = 0
	for j in a2:
		if j in dict:
			print('YES')
			print(1, j)
			found = 1
			break
	if found == 0:
		print('NO')


for i in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	found = False
	for num in a:
		if num in b:
			print('YES')
			print(f'1 {num}')
			found = True
			break
	if not found:
		print('NO')


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	for _ in range(ii()):
		(n, m) = mi()
		a = li()
		b = li()
		f = 0
		for i in a:
			if i in b:
				f = 1
				print('YES')
				print(1, i)
				break
		if f == 0:
			print('NO')
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


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


def func():
	gg = [int(i) for i in input().split()]
	n = gg[0]
	m = gg[1]
	a1 = [int(i) for i in input().split()]
	a2 = [int(i) for i in input().split()]
	m1 = [0] * 1005
	m2 = [0] * 1005
	for i in a1:
		m1[i] += 1
	for i in a2:
		m2[i] += 1
	flag = 0
	for i in range(1005):
		if m1[i] > 0 and m2[i] > 0:
			print('YES')
			print('1 ' + str(i))
			flag = 1
			break
	if flag == 0:
		print('NO')
t = int(input())
for i in range(t):
	func()


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().strip().split()))
	array1 = list(map(int, input().strip().split()))
	array2 = list(map(int, input().strip().split()))
	set1 = set(array1)
	set2 = set(array2)
	common = list(set1.intersection(set2))
	if len(common) == 0:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(common[0])


t = int(input())
while t > 0:
	(n, m) = list(map(int, input().split()))
	s1 = set(map(int, input().split()))
	s2 = set(map(int, input().split()))
	if len(s1.intersection(s2)) == 0:
		print('NO')
	else:
		print('YES')
		print(1, *list(s1.intersection(s2))[:1])
	t -= 1


def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		for i in a:
			if i in b:
				print('YES')
				print(1, i)
				break
		else:
			print('NO')
main()


def solve(a_list, b_list):
	(a, b) = ({}, {})
	for n in a_list:
		a[n] = True
	for n in b_list:
		b[n] = True
	for i in range(1, 1001):
		if a.get(i) and b.get(i):
			print('YES')
			print(1, i)
			return
	print('NO')
t = int(input())
for t in range(t):
	input()
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	solve(a, b)


for _ in range(int(input())):
	(i, j) = map(int, input().split())
	fst = list(map(int, input().split()))
	snd = list(map(int, input().split()))
	list1_as_set = set(fst)
	intersection = list1_as_set.intersection(snd)
	intersection_as_list = list(intersection)
	if len(intersection_as_list) != 0:
		print('YES')
		print(1, intersection_as_list[0])
	else:
		print('NO')


def flag(lst1, lst2, m, n):
	if m == 0 or n == 0:
		return -1
	else:
		for elem in lst1:
			if elem in lst2:
				return elem
for _ in range(int(input())):
	(a1, b1) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	result = flag(a, b, a1, b1)
	if result == -1 or result is None:
		print('NO')
	else:
		print('YES')
		print('1 {}'.format(result))


def main():
	t = int(input())
	for i in range(t):
		(n, m) = map(int, input().split())
		line = input()
		ln = list(map(int, line.split()))
		line = input()
		lm = list(map(int, line.split()))
		flag = 0
		for j in range(n):
			if ln[j] in lm:
				print('YES')
				print(1, ln[j])
				flag = 1
				break
		if flag == 0:
			print('NO')
main()


def solve(ls1, ls2):
	ls = set(ls1).intersection(set(ls2))
	return list(ls)[0] if len(ls) > 0 else None

def main(istr, ostr):
	t = int(istr.readline())
	for _ in range(t):
		(n, m) = list(map(int, istr.readline().split()))
		ls1 = list(map(int, istr.readline().split()))
		ls2 = list(map(int, istr.readline().split()))
		result = solve(ls1, ls2)
		if result:
			print('YES', file=ostr)
			print(1, result, file=ostr)
		else:
			print('NO')
import sys
main(sys.stdin, sys.stdout)


def task():
	s = input()
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	res = a & b
	if len(res) == 0:
		print('NO')
	else:
		print('YES')
		print(1, min(res))
n = int(input())
for _ in range(n):
	task()


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
import math

def sp():
	return map(int, input().split())

def fun(x):
	return sum((int(i) for i in str(x)))
t = int(input())
for _ in range(t):
	(n, m) = sp()
	a = list(sp())
	b = list(sp())
	for x in range(n):
		if a[x] in b:
			print('YES')
			print(1, a[x])
			break
		if x == n - 1:
			print('NO')


for i in range(int(input())):
	(X, Y) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	z = x + y
	counter = 0
	for i in z:
		if x.count(i) >= 1 and y.count(i) >= 1:
			print('YES')
			print(1, i, sep=' ')
			counter = 1
			break
	if counter == 0:
		print('NO')


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	(n, m) = mi()
	a = li()
	b = li()
	c = set(a) & set(b)
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c.pop())


from sys import maxsize, stdin
from math import log, pow, sqrt, floor, ceil, pi
from collections import Counter, defaultdict
from collections import deque as deq
from functools import lru_cache
from itertools import permutations as perm
from itertools import combinations as comb
from itertools import combinations_with_replacement as combr
INT_MAX = maxsize
INT_MIN = -INT_MAX
PI = pi
MOD = 1000000007
input = stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
while t:
	n = inlt()
	a = inlt()
	b = inlt()
	c = set(b)
	found = False
	ans = 0
	for i in a:
		if i in c:
			found = True
			ans = i
			break
	if found:
		print('YES')
		print(1, ans)
	else:
		print('NO')
	t -= 1


tests = int(input())
for test in range(tests):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	was = [0] * 1001
	for x in a:
		was[x] = 1
	answer = 0
	for x in b:
		if was[x]:
			answer = x
	if answer > 0:
		print('YES')
		print(1, answer)
	else:
		print('NO')


def incon():
	A = input()
	A = [int(x) for x in A.split()]
	return A
T = int(input())
while T > 0:
	T -= 1
	(N, M) = [int(a) for a in input().split()]
	A = incon()
	B = incon()
	ans = 'NO'
	for i in A:
		if i in B:
			ans = 'YES'
			break
	print(ans)
	if ans == 'YES':
		print(1, i)


from sys import stdin
input = stdin.readline
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	seta = set(a)
	setb = set(b)
	done = False
	if len(seta) > len(setb):
		temp = seta
		seta = setb
		setb = temp
	for n in seta:
		if n in setb:
			print('YES\n1 ' + str(n))
			done = True
			break
	if not done:
		print('NO')


n = int(input())

def f(a, b):
	c = 0
	l = []
	for j in range(0, len(a)):
		for z in range(0, len(b)):
			if a[j] == b[z]:
				c = c + 1
				l.append(a[j])
	if c > 0:
		return l[0]
for i in range(0, n):
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = f(a, b)
	if d == None:
		print('NO')
	else:
		print('YES')
		print(1, d)


for k in range(int(input())):
	(n, m) = map(int, input().split())
	l = [int(p) for p in input().split()]
	d = [int(p) for p in input().split()]
	a = set(l)
	b = set(d)
	x = list(a & b)
	if len(x) > 0:
		print('YES')
		print(1, x[0])
	else:
		print('NO')


import math
import sys
from sys import stdin
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = [int(j) for j in input().split()]
	arr = [int(j) for j in input().split()]
	brr = [int(j) for j in input().split()]
	dic1 = dict()
	dic2 = dict()
	flag = 0
	for i in range(n):
		if arr[i] in brr:
			print('YES')
			print(1, arr[i])
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for q in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	hasha = [0] * 1001
	hashb = [0] * 1001
	flag = 0
	for i in range(n):
		hasha[arr[i]] += 1
	for i in range(m):
		hashb[brr[i]] += 1
	for i in range(1001):
		if hasha[i] > 0 and hashb[i] > 0:
			flag = 1
			break
	if flag == 1:
		print('YES')
		print(1, i)
	else:
		print('NO')


t = int(input())
while t > 0:
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = 0
	for ele in a:
		if ele in b:
			ans = 1
			print('YES')
			print(1, ele)
			break
	if ans == 0:
		print('NO')
	t -= 1


from collections import defaultdict
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	d = defaultdict(int)
	arrn = list(map(int, input().split()))
	arrm = list(map(int, input().split()))
	for i in arrn:
		d[i] = 1
	flag = 0
	for i in arrm:
		if d[i] == 1:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	find = False
	for a_v in a:
		if a_v in b:
			print(f'YES\n1 {a_v}')
			find = True
			break
	if not find:
		print('No')


import sys
import math
from math import factorial, inf, gcd
from heapq import *
from functools import *
from itertools import *
from collections import *
from typing import *
sys.setrecursionlimit(10 ** 5)
t = int(input())
for ii in range(t):
	(n, m) = (int(i) for i in input().split())
	a = set([int(i) for i in input().split()])
	b = set([int(i) for i in input().split()])
	f = False
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			f = True
			break
	if not f:
		print('NO')


from queue import Queue
import sys

def get_ints():
	return list(map(int, sys.stdin.readline().strip().split()))
t = int(input())
for i in range(t):
	(n, m) = get_ints()
	n_nums = [0] * 1001
	a = get_ints()
	for i in range(n):
		n_nums[a[i]] += 1
	b = get_ints()
	condn = False
	for j in b:
		if n_nums[j] > 0:
			condn = True
			print('YES')
			print(1, j)
			break
	if condn == False:
		print('NO')


import sys

def find_smallest_sub_sequence(lst1, lst2):
	common_elements = []
	for item in lst1:
		if item in lst2:
			common_elements.append(item)
	if common_elements == []:
		print('NO')
	elif len(common_elements) >= 1:
		print('YES')
		print(1, end=' ')
		print(common_elements[0])
n = int(sys.stdin.readline())
for i in range(int(n)):
	arr = [int(x) for x in sys.stdin.readline().split()]
	if len(arr) == 2:
		lst1 = [int(x) for x in sys.stdin.readline().split()]
		lst2 = [int(x) for x in sys.stdin.readline().split()]
		if len(lst1) == arr[0] and len(lst2) == arr[1]:
			find_smallest_sub_sequence(lst1, lst2)
	else:
		print('')


from sys import stdin, stdout
from math import gcd
from collections import defaultdict
input = stdin.readline
print = stdout.write
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in a:
		if i in b:
			print('YES' + '\n1 ' + str(i) + '\n')
			break
	else:
		print('NO\n')


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	(n, m) = value()
	a = set(array())
	b = set(array())
	ele = -1
	for i in a:
		if i in b:
			ele = i
			break
	if ele != -1:
		print('YES')
		print(1, ele)
	else:
		print('NO')


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(a, b):
	console('----- solving ------')
	interset = set(a) & set(b)
	if not interset:
		print('NO')
		return
	if interset:
		print('YES')
		print('1 {}'.format(list(interset)[0]))
	return None

def console(*args):
	print('\x1b[36m', *args, '\x1b[0m', file=sys.stderr)
	return
for case_num in range(int(input())):
	_ = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	_ = solve(arr, brr)


for _ in [0] * int(input()):
	(a, b) = map(int, input().split())
	x = [int(c) for c in input().split()]
	y = [int(d) for d in input().split()]
	flag = False
	for e in x:
		if e in y:
			print('YES')
			print(1, e)
			flag = True
			break
	if flag == False:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a & b
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c.pop())


t = int(input())
for _ in range(t):
	input()
	x = set(map(int, input().split()))
	y = set(map(int, input().split()))
	z = x.intersection(y)
	if z:
		print('YES')
		print(1, z.pop())
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	s = input().split()
	n = int(s[0])
	m = int(s[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	for i in b:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	count = 0
	for i in a:
		if i in d:
			count += 1
			print('YES')
			print('1', end=' ')
			print(i)
			break
	if count == 0:
		print('NO')


from collections import deque, defaultdict
ans = ''
for _ in range(int(input())):
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	flag = 0
	for i in b:
		if d[i] != 0:
			flag = i
			break
	if flag == 0:
		ans += 'NO\n'
	else:
		ans += 'YES\n'
		ans += f'{1} {flag}\n'
print(ans)


a = int(input())
for i in range(a):
	(p, q) = map(int, input().split())
	from collections import *
	al = defaultdict(int)
	z = list(map(int, input().split()))
	m = list(map(int, input().split()))
	flag = 0
	for i in range(len(z)):
		if al[z[i]] == 0:
			al[z[i]] = 1
	for i in range(len(m)):
		if al[m[i]] == 1:
			print('YES')
			print(1, m[i])
			flag = 1
			break
	if flag:
		continue
	else:
		print('NO')


import os
import math

def solution():
	t = int(input())
	while t > 0:
		(n, m) = map(int, input().split())
		a = set(map(int, input().split()))
		b = set(map(int, input().split()))
		for x in a:
			if x in b:
				print('YES')
				print('1', x)
				break
		else:
			print('NO')
		t -= 1
solution()


for i in range(int(input())):
	(n, m) = list(map(int, input().split()))
	array1 = list(map(int, input().split()))
	array2 = list(map(int, input().split()))
	result = None
	for i in array1:
		if i in array2:
			result = i
	if result != None:
		print('YES')
		print(1, result)
	else:
		print('NO')


from collections import defaultdict

def solve(n, m, nums1, nums2):
	if nums1 is None or n == 0 or nums2 is None or (m == 0):
		print('NO')
		return
	memo = defaultdict(lambda : 0)
	for num in nums1:
		memo[num] += 1
	for num in nums2:
		if num in memo:
			print('YES')
			print(1, num)
			return
	print('NO')
	return
testCases = int(input())
for case in range(testCases):
	(n, m) = map(int, input().split())
	nums1 = list(map(int, input().split()))
	nums2 = list(map(int, input().split()))
	solve(n, m, nums1, nums2)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = sorted(map(int, input().split()))
	b = sorted(map(int, input().split()))
	result = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				result = a[i]
	print('YES\n' + '1 ' + str(result)) if result != 0 else print('NO')


def solution(la, lb, a, b):
	if la > lb:
		(a, b) = (b, a)
	a = set(a)
	for el in b:
		if el in a:
			return 'YES\n' + '1 ' + str(el)
	return 'NO'
for test_i in range(int(input())):
	(la, lb) = map(int, input().split())
	(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
	print(solution(la, lb, a, b))


import math
from collections import defaultdict

def solve():
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	common = [x for x in a if x in b]
	if len(common) == 0:
		print('NO')
	else:
		print('YES')
		print(1, common[0])
t = int(input())
for _ in range(t):
	solve()


for I in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dic = {}
	flag = 'NO'
	for num in a:
		dic[num] = 1
	for num in b:
		if num in dic:
			flag = num
			break
	if flag == 'NO':
		print(flag)
	else:
		print('YES')
		print(1, flag)


t = int(input())
for t in range(t):
	(x, y) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	c = 0
	l = []
	for i in l1:
		if i in l2:
			c += 1
			l.append(i)
			break
	if c != 0:
		print('YES')
		print(len(l), end=' ')
		for j in l:
			print(j, end=' ')
		print()
	else:
		print('NO')


t = int(input())
ans = []
for _ in range(t):
	x = input().split()
	n = int(x[0])
	m = int(x[1])
	s = set()
	arr1 = input().split()
	for i in range(n):
		s.add(int(arr1[i]))
	a = True
	arr2 = input().split()
	for i in range(m):
		if int(arr2[i]) in s:
			print('Yes')
			print('1 ' + str(arr2[i]))
			a = False
			break
	if a:
		print('No')


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = False
	ans = -1
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ans = a[i]
				ok = True
				break
		if ok:
			break
	if ok:
		print('YES')
		print(1, ans)
	else:
		print('NO')


from sys import stdin
t = int(input())
result = []
for i in range(t):
	y_or_n = True
	(n, m) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	for i in a:
		if i in b:
			print('YES')
			print('1 ' + str(i))
			y_or_n = False
			break
	if y_or_n == True:
		print('NO')
for i in result:
	print(i)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = []
	for i in a:
		for j in b:
			if i == j:
				c.append(i)
	if len(c) > 0:
		print('YES')
		print(1, c[0])
	else:
		print('NO')


def solve(a, b):
	for i in a:
		if i in b:
			return i
	return -1
t = int(input())
for _ in range(t):
	input()
	arr1 = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	sol = solve(arr1, arr2)
	if sol == -1:
		print('NO')
	else:
		print('YES')
		print(1, sol)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	feq = [0 for i in range(1005)]
	c = 0
	for i in range(n):
		feq[a[i]] = 1
	for i in range(m):
		x = b[i]
		if feq[x] > 0:
			print('YES')
			print(1, x)
			c = 1
			break
	if c == 0:
		print('NO')


t = int(input())
zero = [int(0) for x in range(10)]
for x in range(t):
	cont = 0
	(n, m) = map(int, input().split())
	sub = [int(y) for y in input().split()]
	bb = [int(x) for x in input().split()]
	novalista = []
	if n > m:
		lista1 = sub
		lista2 = bb
	else:
		lista1 = bb
		lista2 = sub
	for i in range(len(lista1)):
		if lista1[i] in lista2:
			cont = 1
			novalista.append(lista1[i])
	if cont >= 1:
		print('YES')
		print(cont, novalista[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			break
		else:
			continue
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(c) for c in input().split()]
	A = [int(c) for c in input().split()]
	B = [int(c) for c in input().split()]
	c = set(A) & set(B)
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		for i in c:
			print('1 ' + str(i))
			break


import bisect
import os
import gc
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import heapq
import math
import statistics

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for i in range(iin()):
		(n, m) = ain()
		a = set(ain())
		b = set(ain())
		flag = 0
		x = -1
		for i in a:
			if i in b:
				flag = 1
				x = i
				break
		if flag == 1:
			print('YES')
			print(1, x)
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for i in range(int(input())):
	(m, n) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = list(a.intersection(b))
	if c == []:
		print('NO')
	else:
		ans = []
		ans.append(1)
		ans.append(c[0])
		print('YES')
		print(*ans)


x = lambda : set(input().split())
for _ in range(int(input())):
	input()
	a = list(x() & x())
	if len(a) > 0:
		print('YES')
		print(1, a[0])
	else:
		print('NO')


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, m) = sp()
	a = l()
	b = l()
	s = set(a)
	answer = -1
	for i in b:
		if i in a:
			answer = i
			break
	if answer == -1:
		out('NO')
		continue
	out('YES')
	out('1 {}'.format(answer))


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


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	(n, m) = get_tuple()
	a = get_list()
	b = get_list()
	freq_dic = Counter(b)
	for val in a:
		if val in freq_dic:
			print('YES')
			print(1, val)
			return
	print('NO')

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = set(list(map(int, input().split())))
	b = set(list(map(int, input().split())))
	c = a & b
	if len(c) != 0:
		print('YES')
		for elem in c:
			print(1, elem)
			break
	else:
		print('NO')


T = int(input())
for rounds in range(T):
	n = list(map(int, input().split()))
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	cnt_arr1 = [0 for i in range(1001)]
	cnt_arr2 = [0 for i in range(1001)]
	cnt_arr = [0 for i in range(1001)]
	for i in range(n[0]):
		cnt_arr1[a1[i]] = 1
	for i in range(n[1]):
		cnt_arr2[a2[i]] = 1
	cnt_arr = [cnt_arr1[i] + cnt_arr2[i] for i in range(1001)]
	k = 9999
	idx = -1
	for i in range(1001):
		if cnt_arr[i] <= k and cnt_arr[i] > 1:
			k = cnt_arr[i]
			idx = i
	if idx != -1:
		print('YES')
		print(k - 1, idx)
	else:
		print('NO')


def main():
	n = int(input())
	for _ in range(n):
		input()
		x = list(map(int, input().split()))
		y = list(map(int, input().split()))
		done = False
		for char in x:
			if char in y:
				print('YES')
				print('1 ' + str(char))
				done = True
				break
		if not done:
			print('NO')
main()


for i in range(int(input())):
	(n, m) = map(int, input().split())
	(l1, l2) = (list(map(int, input().split())), list(map(int, input().split())))
	f = 1
	for i in range(n):
		if l1[i] in l2:
			print('YES')
			print('1', l1[i])
			f = 0
			break
	if f:
		print('NO')


T = int(input())
for z in range(T):
	(m, n) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = []
	for e in a[:]:
		if e in b:
			c.append(e)
			break
	if len(c) == 1:
		print('YES')
		print(1, ' ', c[0])
	else:
		print('NO')


t = int(input())

def main():
	(n, m) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(len(a)):
		try:
			result = b.index(a[i])
		except:
			result = None
		if result is not None:
			print('YES')
			print(f'1 {a[i]}')
			return
	print('NO')
for _ in range(t):
	main()


t = int(input())
f = []
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = list(set(a))
	b = list(set(b))
	if n < m:
		temp = a
		a = b
		b = temp
	for j in range(len(a)):
		if a[j] in b:
			f.append('YES\n1 ' + str(a[j]))
			break
	else:
		f.append('NO')
print(*f, sep='\n')


def element(a, b):
	for elem in a:
		if elem in b:
			print('YES')
			print(1, elem)
			return
	print('NO')
for i in range(int(input())):
	(size_1, size_2) = [int(elem) for elem in input().split()]
	element([int(elem) for elem in input().split()], [int(elem) for elem in input().split()])


from __future__ import division, print_function
import sys
from atexit import register
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
sys.stdin = stream(sys.stdin.read())
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.stdout = stream()
register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split(' ')))

def solve():
	(n, m) = read_ints()
	a = set(read_ints())
	b = set(read_ints())
	c = a & b
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c.pop())
T = read_int()
for _ in range(T):
	solve()


for x in range(int(input())):
	inp = input()
	set1 = {int(t) for t in input().split()}
	set2 = {int(c) for c in input().split()}
	for num in set1:
		if num in set2:
			print('YES')
			print(1, num)
			break
	else:
		print('NO')


import math
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d1 = {}
	d2 = {}
	for i in l1:
		d1[i] = 1
	for i in l2:
		d2[i] = 1
	ans = -1
	for i in d1:
		if d2.get(i, -1) != -1:
			ans = i
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = set(a)
	tf = True
	for i in b:
		if i in x:
			print('YES')
			print(1, i)
			tf = False
			break
	if tf:
		print('NO')


for t in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	flag = 0
	for i in range(m):
		for j in range(n):
			if b[i] > a[j]:
				continue
			elif b[i] == a[j]:
				flag = 1
				break
			else:
				break
		if flag == 1:
			print('YES')
			print(1, b[i])
			break
	if flag == 0:
		print('NO')


def f(L, M):
	L.sort()
	M.sort()
	for i in range(0, len(L)):
		for j in range(0, len(M)):
			if L[i] == M[j]:
				return L[i]
	return -1
t = int(input())
for i in range(0, t):
	mn = input().split()
	m = int(mn[0])
	n = int(mn[1])
	L = list(map(int, input().split()))
	M = list(map(int, input().split()))
	if f(L, M) == -1:
		print('NO')
	else:
		print('YES')
		print(*[1, f(L, M)])


__MULTITEST = True

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for x in a:
		try:
			v = b.index(x)
			print('YES')
			print(1, x)
			return
		except:
			pass
	print('NO')
t = int(input()) if __MULTITEST else 1
for tt in range(t):
	solve()


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = False
	ans = []
	for i in range(min(n, m)):
		if min(n, m) == n and a[i] in b:
			print('YES')
			print(1, a[i])
			ok = True
			break
		elif min(n, m) == m and b[i] in a:
			print('YES')
			print(1, b[i])
			ok = True
			break
	else:
		print('NO')


for _ in range(int(input())):
	(N, M) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	adic = {}
	for i in range(len(arr)):
		if arr[i] not in adic:
			adic[arr[i]] = 1
	flag = 1
	store = 0
	for j in range(len(brr)):
		if brr[j] not in adic:
			flag = 0
		else:
			store = brr[j]
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, store)


import sys
input = sys.stdin.readline
for i in range(int(input())):
	(n, m) = (int(x) for x in input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in range(n):
		if a[i] in b:
			print('YES')
			print(1, a[i])
			break
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	array1 = list(map(int, input().split()))
	array2 = list(map(int, input().split()))
	set1 = set(array1)
	for x in array2:
		if x in set1:
			print('YES')
			print(1, x)
			return
	print('NO')
t = int(input())
for i in range(t):
	solve()


b = int(input())
for i in range(b):
	c = []
	m = input().split()
	user_input = input().split()
	user_input2 = input().split()
	a = [int(x.strip()) for x in user_input]
	b = [int(x.strip()) for x in user_input2]
	for i in range(len(a)):
		if a[i] in b:
			c.append(a[i])
			print('YES')
			print(len(c), c[0])
			break
	if c == []:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	dic = {}
	elem = 0
	f = 0
	for x in a:
		if x in b:
			elem = x
			f = 1
			break
	if f == 1:
		print(f'YES\n1 {elem}')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	for j in range(len(b)):
		x = b.pop()
		if x in a:
			print('YES')
			print('1', x)
			break
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	set1 = set(list1)
	set2 = set(list2)
	set3 = set1.intersection(set2)
	if len(set3) > 0:
		print('YES')
		print(1, end=' ')
		for i in set3:
			print(i)
			break
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	done = 0
	for i in range(n):
		if b.count(a[i]):
			print('YES')
			print(1, a[i], sep=' ')
			done = 1
			break
	if not done:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = -1
	for i in range(1, 1001):
		if i in a and i in b:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


import io, os
from collections import deque
RL = lambda : list(map(int, input().split(' ')))
T = int(input())
for _ in range(T):
	(n, m) = RL()
	a = RL()
	b = RL()
	dic = [0] * 1001
	for i in range(n):
		dic[a[i]] = 1
	flag = 0
	ans = 0
	for i in range(m):
		if dic[b[i]] == 1:
			flag = 1
			ans = b[i]
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print('1 %d' % ans)


t = int(input())
for i in range(0, t):
	(m, n) = map(int, input().split())
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	L3 = []
	count = 0
	for i in L1:
		if i in L2:
			L3.append(i)
			count = count + 1
			break
	if count > 0:
		print('YES')
		print(count, '', end='')
		for i in L3:
			print(i)
	else:
		print('NO')


cases = []
t = int(input())
for i in range(t):
	input()
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	cases.append([a, b])

def solve(case):
	for element in case[0]:
		for e in case[1]:
			if element == e:
				print('YES')
				print(1, e)
				return
	print('NO')
for case in cases:
	solve(case)


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	union = set(a) & set(b)
	if not union:
		print('NO')
	else:
		print('YES')
		print(1, union.pop())
for _ in range(int(input())):
	solve()


t = int(input())
while t != 0:
	flag = 0
	(n, m) = map(int, input().split())
	ln = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	for i in ln:
		for j in lm:
			if i == j:
				print('YES')
				print(1, i)
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')
	t = t - 1


def help():
	input()
	a = set(map(int, input().split())) & set(map(int, input().split()))
	if a:
		print('YES')
		print(1, list(a)[0])
		return
	print('NO')
t = int(input())
for T in range(t):
	help()


t = int(input())
for i in range(0, t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	common = -1
	for i in arr1:
		if i in arr2:
			common = i
			break
	if common > -1:
		print('YES', end='\n')
		print(1, common)
	else:
		print('NO')


from sys import stdin

def solve(n1, n2, arr1, arr2):
	(smol, big) = [arr1, arr2] if n1 < n2 else [arr2, arr1]
	ans = []
	for i in range(min(n1, n2)):
		if smol[i] in big:
			ans += [smol[i]]
			break
	if len(ans) > 0:
		print(f'YES \n1 {ans[0]}')
	else:
		print('NO')
t = int(stdin.readline())
for _ in range(t):
	(n1, n2) = list(map(int, stdin.readline().rstrip().split()))
	arr1 = list(map(int, stdin.readline().rstrip().split()))
	arr2 = list(map(int, stdin.readline().rstrip().split()))
	solve(n1, n2, arr1, arr2)


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	i = 0
	flag = 0
	while i < m:
		if b[i] in a:
			flag = 1
			print('Yes')
			print(1, b[i])
			break
		i += 1
	if flag != 1:
		print('No')


def common_member(a, b):
	if len(set(a).intersection(set(b))) > 0:
		return list(set(a).intersection(set(b)))
	else:
		return []
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = common_member(a, b)
	if len(x) != 0:
		print('YES')
		print(1, x[0])
	else:
		print('NO')


a = input()
for x in range(int(a)):
	b = input()
	c = input().split(' ')
	d = input().split(' ')
	ans = -1
	for i in c:
		if i in d:
			ans = int(i)
			break
		if ans != -1:
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(1, 1001):
		(ina, inb) = (False, False)
		for j in a:
			if j == i:
				ina = True
				break
		for j in b:
			if j == i:
				inb = True
		if ina and inb:
			print('YES')
			print(1, i)
			return
	print('NO')
for _ in range(int(input())):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	check = 0
	ans = 1
	for i in li1:
		if i in li2:
			check = 1
			ans = i
			break
	if check == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	t = 0
	for i in range(len(a)):
		if a[i] in b:
			t = 1
			print('YES')
			print(1, a[i])
			break
	if t == 0:
		print('NO')


t = int(input())
while t:
	(a, b) = map(int, input().split(' '))
	l1 = []
	l2 = []
	l1 = input().split(' ')
	l2 = input().split(' ')
	intersect = list(set(l1) & set(l2))
	if len(intersect) == 0:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(intersect[0])
	t -= 1


t = int(input())
while t > 0:
	(n, m) = [int(k) for k in input().split(' ')]
	a = [int(k) for k in input().split(' ')]
	b = set([int(k) for k in input().split(' ')])
	for element in b:
		if element in a:
			print('YES')
			print(1, element)
			break
	else:
		print('NO')
	t -= 1


def solution(arr1, arr2):
	d = {}
	for i in arr1:
		d[i] = d.get(i, 0) + 1
	ans = []
	for j in arr2:
		val = d.get(j, 0)
		if val > 0:
			ans.append(j)
			return ans
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	ans = solution(arr1, arr2)
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(len(ans), end=' ')
		print(*ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	dic = {}
	for i in a:
		dic[i] = 1
	flag = False
	n = 0
	for i in b:
		if i in dic:
			n = i
			flag = True
			break
	if flag == False:
		print('NO')
	else:
		print('YES')
		print(1, n)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	(n, m) = listIn()
	a = listIn()
	b = listIn()
	di = Counter(b)
	f = 0
	for ele in a:
		if di[ele] >= 1:
			ans = ele
			f = 1
			break
	if f:
		print('YES')
		print(1, ele)
	else:
		print('NO')


for z in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	arr = [int(i) for i in input().split()]
	arr2 = [int(i) for i in input().split()]
	d = {}
	for i in arr:
		if i not in d:
			d[i] = 1
	ans = 0
	for i in arr2:
		if i in d:
			ans = i
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')
		print('1', ans)


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	l = [int(x) for x in input().split()]
	m1 = [int(y) for y in input().split()]
	c = 0
	if n >= m:
		for i in range(m):
			if m1[i] in l:
				print('YES')
				print(1, m1[i])
				c += 1
				break
		if c == 1:
			pass
		else:
			print('NO')
	else:
		for i in range(n):
			if l[i] in m1:
				print('YES')
				print(1, l[i])
				c += 1
				break
		if c == 1:
			pass
		else:
			print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	res = None
	x = 0
	for i in a:
		if i in b:
			res = i
			x += 1
			print('YES')
			print(1, i)
			break
	if x == 0:
		print('NO')


tt = int(input())

def intersect(lst1, lst2):
	temp = set(lst2)
	lst3 = [value for value in lst1 if value in temp]
	return lst3
for t in range(tt):
	(na, nb) = map(int, input().split())
	la = list(map(int, input().split()))
	lb = list(map(int, input().split()))
	inter = intersect(la, lb)
	if len(inter) == 0:
		print('NO')
		continue
	print('YES')
	print(1, inter[0])


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = set([int(x) for x in input().split()])
	b = set([int(x) for x in input().split()])
	found = False
	t = 0
	for i in a:
		if i in b:
			found = True
			t = i
			break
	if found:
		print('YES')
		print('{} {}'.format(1, t))
	else:
		print('NO')


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


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	s1 = set(map(int, input().split()))
	s2 = set(map(int, input().split()))
	s3 = s1.intersection(s2)
	if len(s3) != 0:
		print('YES')
		print(1, list(s3)[0])
	else:
		print('NO')


a = int(input())
for x in range(a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	j = 0
	for x in d:
		if x in e:
			print('YES')
			print(1, x)
			break
		else:
			j += 1
	if j == b:
		print('NO')


t = int(input())
for h in range(t):
	len_list = list(map(int, input().split()))
	list_1 = list(map(int, input().split()))
	list_2 = list(map(int, input().split()))
	set_1 = set(list_1)
	set_2 = set(list_2)
	diff = set_1 & set_2
	diff_list = list(diff)
	if len(diff_list) != 0:
		print('YES')
		print('1', end=' ')
		print(diff_list[0])
	else:
		print('NO')


t = int(input())
while t > 0:
	f = 0
	(a, b) = input().split(' ')
	a = int(a)
	b = int(b)
	arr = input().split()
	brr = input().split()
	if len(arr) <= len(brr):
		for i in arr:
			if i in brr:
				f = 1
				break
	else:
		for i in brr:
			if i in arr:
				f = 1
				break
	if f == 1:
		print('YES')
		print('1', i)
	else:
		print('NO')
	t -= 1


num = int(input())
for i in range(num):
	[m, n] = input().split()
	m = int(m)
	n = int(n)
	ms = input().split()
	ms = set([int(i) for i in ms])
	ns = input().split()
	ns = set([int(i) for i in ns])
	q = ms & ns
	if not q:
		print('NO')
	else:
		print('YES')
		print(1, list(q)[0])


from sys import stdin, stdout
for _ in range(int(input())):
	(n, m) = map(int, stdin.readline().split())
	la = set(map(int, stdin.readline().split()))
	lb = set(map(int, stdin.readline().split()))
	ans = list(la.intersection(lb))
	if len(ans) >= 1:
		print('YES')
		print(1, ans[0])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	h = []
	for _ in range(1001):
		h.append(0)
	for i in a:
		h[i] += 1
	min = -1
	for i in range(n):
		if h[b[i]] != 0:
			if min == -1:
				min = b[i]
			elif b[i] < min:
				min = b[i]
	if min == -1:
		print('NO')
	else:
		print('YES')
		print(1, min)


t = int(input())
for i in range(t):
	x = ''
	y = ''
	(a, b) = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	for i in arr1:
		if i in arr2:
			print('YES')
			print('1 ' + str(i))
			break
	else:
		print('NO')


t = int(input())
for u in range(t):
	(n, m) = map(int, input().split())
	a = set()
	b = set()
	for i in input().split():
		a.add(int(i))
	for i in input().split():
		b.add(int(i))
	a &= b
	if len(a) == 0:
		print('NO')
	else:
		print('YES')
		for i in a:
			print('1', i)
			break


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		for j in range(m):
			if lis1[i] == lis2[j]:
				print('YES')
				print('1', lis1[i], sep=' ')
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')


try:
	test = int(input())
	for i in range(test):
		(len_arr1, len_arr2) = map(int, input().strip().split())
		arr1 = list(map(int, input().strip().split()))[:len_arr1]
		arr2 = list(map(int, input().strip().split()))[:len_arr2]
		temp = []
		arr1_set = list(set(arr1))
		arr2_set = list(set(arr2))
		for i in range(len(arr1_set)):
			if arr1_set[i] in arr2_set:
				temp.append(arr1_set[i])
		if len(temp) == 0:
			print('NO')
		else:
			print('YES')
			print(1, temp[0])
except:
	pass


t = int(input())
while t > 0:
	(n, m) = [int(x) for x in input().split()]
	a = [int(y) for y in input().split()]
	b = [int(z) for z in input().split()]
	flag = 0
	for i in range(n):
		if a[i] in b:
			flag = 1
			print('YES')
			print(1, a[i])
			break
	if flag == 0:
		print('NO')
	t -= 1


from sys import stdin
from math import ceil, gcd

def func():
	return
for _ in range(int(stdin.readline())):
	(n, m) = map(int, stdin.readline().split())
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	cond = False
	for i in range(n):
		if a[i] in b:
			cond = True
			break
	if cond == True:
		print('YES')
		print(1, a[i])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	val = [0] * 1001
	for x in a:
		val[x] += 1
	for x in b:
		val[x] += 1
	ans = 'NO'
	for i in range(1001):
		if val[i] > 1:
			ans = 'YES'
			res = i
			break
	print(ans)
	if ans == 'YES':
		print(1, res)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	B = set(B)
	for a in A:
		if a in B:
			print('YES')
			print(1, a)
			break
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a1 = set(l1)
	a2 = set(l2)
	a1 = a1.intersection(a2)
	a1 = list(a1)
	if len(a1) == 0:
		print('NO')
	else:
		print('YES')
		print(1, a1[0])


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	stdin.readline()
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	no = True
	for x in a:
		if x in b:
			print('YES')
			print(1, x)
			no = False
			break
	if no:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dict1 = {}
	dict2 = {}
	c = 0
	for i in range(n):
		if a[i] in dict1:
			dict1[a[i]] += 1
		else:
			dict1[a[i]] = 1
	for i in range(m):
		if b[i] in dict2:
			dict2[b[i]] += 1
		else:
			dict2[b[i]] = 1
	for i in dict1:
		if i in dict2:
			print('YES')
			print('1', end=' ')
			print(i)
			c = 1
			break
	if c == 0:
		print('NO')


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')

def solve(n, m, a, b):
	sa = set(a)
	sb = set(b)
	s = sa.intersection(sb)
	if len(s) == 0:
		ws('NO')
	else:
		ws('YES')
		wia([1, next(iter(s))])

def main():
	for _ in range(ri()):
		(n, m) = ria()
		a = ria()
		b = ria()
		solve(n, m, a, b)
main()


t = int(input())
for i in range(t):
	ans = ''
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for j in l1:
		if j in l2:
			ans = j
			break
	if ans:
		print('YES')
		print(1, ans)
	else:
		print('NO')


def common(a, b):
	x = set(a)
	y = set(b)
	z = list(x.intersection(y))
	if not z:
		print('NO')
		return
	print('YES')
	print(1, z[0])
	return
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	common(a, b)


T = int(input())
for t in range(T):
	(N, M) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	found = False
	ans = 0
	for a in A:
		for b in B:
			if a == b:
				found = True
				ans = a
				break
		if found:
			break
	if found:
		print('YES')
		print('1 ', ans)
	else:
		print('NO')


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def bfs(adj):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

@bootstrap
def dfs(u, top, adj, vis):
	vis[u] = 1
	for (v, d) in adj[u]:
		if vis[v] == 2 or d == 0:
			continue
		if vis[v] == 1:
			yield 'No'
		x = (yield dfs(v, top, adj, vis))
		if x == 'No':
			yield 'No'
	vis[u] = 2
	top.append(u)
	yield

def solution(a, n, b, m):
	a = set(a)
	b = set(b)
	c = a.intersection(b)
	if len(c) == 0:
		return 'NO'
	return f'YES\n1 {c.pop()}'

def main():
	T = 1
	T = ri()
	for i in range(T):
		(n, m) = ria()
		a = ria()
		b = ria()
		x = solution(a, n, b, m)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


inp = lambda : map(int, input().split())
for _ in range(int(input())):
	(N, M) = inp()
	seq1 = set(inp())
	seq2 = set(inp())
	res = list(seq1.intersection(seq2))
	if res:
		print('YES')
		print(1, res[0])
	else:
		print('NO')


import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
	return int(input())

def rm():
	return map(int, input().split())

def rl():
	return list(map(int, input().split()))
for _ in range(r()):
	(na, nb) = rm()
	a = rl()
	b = rl()
	haveA = defaultdict(int)
	for i in a:
		haveA[i] = 1
	res = False
	for i in b:
		if haveA[i] == 1:
			ans = i
			res = True
			break
	if res:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
i = 0
while i < t:
	(x, y) = [int(x) for x in input().split()]
	a = set([int(x) for x in input().split()])
	b = set([int(x) for x in input().split()])
	common = list(a.intersection(b))
	l_common = len(common)
	if l_common > 0:
		print('YES')
		print('1', common[0])
	else:
		print('NO')
	i += 1


import heapq as hp
import collections
import bisect
import math
import re

def unpack(func=int):
	return map(func, input().split())

def l_unpack(func=int):
	return list(map(func, input().split()))

def s_unpack(func=int):
	return sorted(map(func, input().split()))

def ml_unpack(n):
	return [int(input()) for i in range(n)]

def range_n():
	return range(int(input()))

def counter(a):
	d = {}
	for x in a:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	return d

def getint():
	return int(input())

def lcs_bottom_up_subsequence(s1, s2, n1, n2):
	t = [[0] * (n2 + 1) for i in range(n1 + 1)]
	for i in range(1, n1 + 1):
		for j in range(1, n2 + 1):
			if s1[i - 1] == s2[j - 1]:
				t[i][j] = 1 + t[i - 1][j - 1]
			else:
				t[i][j] = max(t[i][j - 1], t[i - 1][j])
	(i, j) = (n1, n2)
	sub = []
	while i and j:
		if s1[i - 1] == s2[j - 1]:
			sub.append(i - 1)
			(i, j) = (i - 1, j - 1)
		else:
			(i, j) = (i - 1, j) if t[i - 1][j] > t[i][j - 1] else (i, j - 1)
	sub.sort()
	return sub

def main():
	for _ in range_n():
		(n, m) = unpack()
		a = l_unpack()
		b = l_unpack()
		sub = lcs_bottom_up_subsequence(a, b, n, m)
		if sub:
			print('YES')
			print(1, a[sub[0]])
		else:
			print('NO')
main()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	nl = list(map(int, input().split()))
	ml = list(map(int, input().split()))
	flag = 0
	for j in nl:
		if j in ml:
			print('YES')
			print(1, j)
			flag = 1
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	L = []
	if n > m:
		for i in range(n):
			if s1[i] in s2:
				L.append(s1[i])
	else:
		for i in range(m):
			if s2[i] in s1:
				L.append(s2[i])
	if len(L) == 0:
		print('NO')
	else:
		print('YES')
		print(1, min(L))


inp = lambda : map(int, input().split())
t = int(input())
for _ in range(t):
	(x, y) = inp()
	a = list(inp())
	b = list(inp())
	f = False
	for i in a:
		for j in b:
			if i == j:
				print('YES')
				print(1, i)
				f = True
				break
		if f:
			break
	if not f:
		print('NO')


n = int(input())
final = []
for j in range(n):
	(a, b) = input().split()
	l = [int(x) for x in input().split()]
	m = [int(x) for x in input().split()]
	l = set(l)
	m = set(m)
	intersection = l.intersection(m)
	fu = list(intersection)
	if len(fu) == 0:
		final.append('NO')
	else:
		a = []
		a.append('YES')
		a.append(1)
		a.append(fu[0])
		final.append(a)
for i in range(len(final)):
	if final[i] == 'NO':
		print(final[i])
	else:
		print(final[i][0])
		print(final[i][1], final[i][2])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = set(map(int, input().split()))
	k = set(map(int, input().split()))
	a = l.intersection(k)
	if len(a) == 0:
		print('NO')
	else:
		print('YES')
		a = list(a)
		print(1, end=' ')
		print(a[0])


def abc(n, arr, m, brr):
	arr = set(arr)
	brr = set(brr)
	x = arr.intersection(brr)
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		print('1 ', x.pop())
t = int(input())
while t != 0:
	(N, M) = input().split()
	n = int(N)
	m = int(M)
	arr = [int(item) for item in input().split()]
	brr = [int(item) for item in input().split()]
	abc(n, arr, m, brr)
	t = t - 1


t = int(input())
while t:
	(m, n) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	d = {}
	p = 'NO'
	for i in a:
		d[i] = True
	for j in b:
		if j in d:
			p = 'YES\n1 ' + str(j)
			f = 1
			break
	print(p)
	t -= 1


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = set([int(s) for s in input().split()])
	b = set([int(s) for s in input().split()])
	x = list(a & b)
	if x == []:
		print('NO')
	else:
		print('YES')
		print(1, x[0])


t = int(input())

def check(mas1, mas2):
	for x in mas1:
		for y in mas2:
			if x == y:
				return (1, y)
	return 'NO'
answers = []
for _ in range(t):
	noup = input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	answers.append(check(a, b))
for elem in answers:
	if elem == 'NO':
		print(elem)
	else:
		print('YES')
		print(elem[0], elem[1])


for t in range(int(input())):
	(n1, n2) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	count = 0
	if n1 <= n2:
		for i in range(n1):
			if l1[i] in l2:
				count = 1
				print('YES')
				print(1, end=' ')
				print(l1[i])
				break
	elif n1 >= n2:
		for i in range(n2):
			if l2[i] in l1:
				count = 1
				print('YES')
				print(1, end=' ')
				print(l2[i])
				break
	if count == 0:
		print('NO')


for tc in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	g = {}
	for i in b:
		g[i] = 1
	flg = 0
	for i in a:
		if i in g:
			print('YES')
			print(1, i)
			flg = 1
			break
	if flg == 0:
		print('NO')


from sys import stdin
T = int(stdin.readline())
A = []
B = []
for _ in range(T):
	(n, m) = map(int, stdin.readline().split())
	A = list(map(int, stdin.readline().split()))
	B = list(map(int, stdin.readline().split()))
	res = list(set(A) & set(B))
	if len(res) == 0:
		print('NO')
	else:
		print('YES')
		print(1, res[0])


import random
n = int(input())
for i in range(n):
	(m, n) = map(int, input().split())
	s = list(map(int, input().split()))
	t = list(map(int, input().split()))
	s = set(s)
	t = set(t)
	if len(s.intersection(t)) > 0:
		print('YES')
		print(str(1) + ' ' + str(random.choice(list(s.intersection(t)))))
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	if n > m:
		f = 0
		for i in range(m):
			if b[i] in a:
				f = 1
				print('YES')
				print(1, b[i])
				break
		if f == 0:
			print('NO')
	else:
		f = 0
		for i in range(n):
			if a[i] in b:
				f = 1
				print('YES')
				print(1, a[i])
				break
		if f == 0:
			print('NO')


t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	a = []
	b = []
	a = list(input().split(' '))
	b = list(input().split(' '))
	y = 0
	while y < m:
		c = b[y]
		if c in a:
			print('YES')
			print('1', c)
			break
		y = y + 1
	if y == m:
		print('NO')


T = int(input())
for __ in range(T):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = set(map(int, input().split()))
	flag = 1
	for element in A:
		if element in B:
			print('YES')
			print('1 ' + str(element))
			flag = 0
			break
	if flag == 1:
		print('NO')


for _ in ' ' * int(input()):
	(n, m) = map(int, input().split(' '))
	la = [int(i) for i in input().split(' ')]
	lb = [int(i) for i in input().split(' ')]
	la.sort()
	lb.sort()
	for j in range(n):
		if la[j] in lb:
			print('YES')
			print('1 ', la[j])
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split(' ')]
	xs = [int(x) for x in input().split(' ')]
	ys = [int(x) for x in input().split(' ')]
	ans = None
	for x in xs:
		if x in ys:
			ans = [x]
			break
	if ans:
		print('YES')
		print(1, ans[0])
	else:
		print('NO')


from collections import defaultdict as dd
for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	lsta = list(map(int, input().split()))
	lstb = list(map(int, input().split()))
	(x, y) = (dd(int), dd(int))
	c = 0
	for i in range(n):
		x[lsta[i]] += 1
	for i in range(m):
		y[lstb[i]] += 1
	if n > m:
		for i in range(n):
			if y.get(lsta[i], 0) != 0:
				c += 1
				print('YES')
				print('1', lsta[i])
				break
	else:
		for i in range(m):
			if x.get(lstb[i], 0) != 0:
				c += 1
				print('YES')
				print('1', lstb[i])
				break
	if c == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().strip().split(' '))
	arr = list(map(int, input().strip().split(' ')))
	brr = list(map(int, input().strip().split(' ')))
	arr.sort()
	brr.sort()
	num = [0 for i in range(1001)]
	for a in arr:
		if num[a] == 0:
			num[a] = 1
	for b in brr:
		if num[b] == 1:
			num[b] = 2
	ans = -1
	for (i, a) in enumerate(num):
		if a > 1:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	l1 = set(map(int, input().split()))
	l2 = set(map(int, input().split()))
	an = list(l1.intersection(l2))
	if len(an) == 0:
		print('NO')
	else:
		print('YES')
		print(1, an[0])
	t -= 1


def func(c, b):
	for i in b:
		if c[i] != 0:
			print('YES')
			print(1, i)
			return
	print('NO')
	return
from collections import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = Counter(a)
	func(c, b)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	ls = [1]
	b = False
	for i in a1:
		if i in a2:
			b = True
			ls.append(i)
			break
		else:
			continue
	if b:
		print('YES')
		print(*ls)
	else:
		print('NO')


def c(s1, s2):
	a = s1 + s2
	for i in a:
		if a.count(i) > 1:
			print('YES')
			print(1, i)
			return
	print('NO')
	return
t = int(input())
for i in range(t):
	n = input()
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	s1 = list(set(s1))
	s2 = list(set(s2))
	c(s1, s2)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = list((int(num) for num in input().split()))
	b = list((int(num) for num in input().split()))
	na = [x for x in a if x in b]
	if na:
		print('YES')
		print('1', na[0])
	else:
		print('NO')


def subSeq(a, b):
	a.sort()
	b.sort()
	j = 0
	found = 'NO'
	sub = []
	for i in range(len(a)):
		while b[j] < a[i] and j < len(b) - 1:
			j += 1
		if a[i] == b[j]:
			found = 'YES'
			sub.append(a[i])
			return (found, sub)
	return (found, sub)
tests = int(input())
for t in range(tests):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(result, sub) = subSeq(a, b)
	if result == 'YES':
		print(result)
		print(len(sub), sub[0])
	else:
		print(result)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	ans = -1
	for i in b:
		if i in a:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		(a1, b1, f) = (set(a), set(b), False)
		for i in range(m):
			if b[i] in a1:
				f = True
				print('YES')
				print(1, b[i])
				break
		if not f:
			print('NO')
main()


from itertools import combinations
from collections import defaultdict as D
try:
	t = int(input())
	for i in range(t):
		flag = 0
		(n, m) = map(int, input().split())
		l1 = list(map(int, input().split()))
		l2 = list(map(int, input().split()))
		for i in l1:
			if i in l2:
				a = i
				flag = 1
				break
		if flag == 1:
			print('YES')
			print(1, a)
		else:
			print('NO')
except:
	pass


test_cases = int(input())
answers = []
arr_ans = []
for _ in range(test_cases):
	(n, m) = [int(x) for x in input().split(' ')]
	arr1 = [int(x) for x in input().split(' ')]
	arr2 = [int(x) for x in input().split(' ')]
	arr2_set = set(arr2)
	p1 = 0
	found = False
	while p1 < len(arr1):
		elem1 = arr1[p1]
		if elem1 in arr2_set:
			arr_ans.append(elem1)
			found = True
			answers.append('YES')
			break
		else:
			p1 += 1
	if not found:
		answers.append('NO')
p0 = 0
for ans in answers:
	print(ans)
	if ans == 'YES':
		print(1, arr_ans[p0])
		p0 += 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set([int(i) for i in input().split()])
	b = list(map(int, input().split()))
	flag = False
	for j in b:
		if j in a:
			print('YES')
			print(1, j)
			flag = True
			break
	if flag:
		continue
	print('No')


t = int(input())
l = []
for i in range(t):
	(n, m) = list(map(int, input().split()))
	na = list(map(int, input().split()))
	nb = list(map(int, input().split()))
	na = set(na)
	nb = set(nb)
	s = list(na.intersection(nb))
	if len(s) == 0:
		l.append('No')
	else:
		l.append('Yes')
		l.append(f'1 {s[0]}')
for i in l:
	print(i)


import math
from sys import stdin
from collections import Counter, defaultdict, deque
mod = pow(10, 9) + 7
input = stdin.readline

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))

def solve():
	(n, m) = map1()
	l1 = list1()
	l2 = list1()
	l1 = set(l1)
	l2 = set(l2)
	l3 = list(l1 & l2)
	if len(l3) != 0:
		print('YES')
		print(1, l3[0])
	else:
		print('NO')
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	dict = {}
	f = True
	for i in lst:
		if i in dict:
			dict[i] += 1
		else:
			dict[i] = 1
	for i in lst1:
		if i in dict:
			print('YES')
			print(1, i)
			f = False
			break
	if f:
		print('NO')


def solution():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	set_a = set(a)
	for bi in b:
		if bi in set_a:
			print('YES')
			print(f'1 {bi}')
			return
	print('NO')
t = int(input())
for _ in range(t):
	solution()


from collections import Counter

def solve(a, b, n, m):
	d = Counter(a)
	for i in range(m):
		if d.get(b[i]):
			return b[i]
	return -1
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = solve(a, b, n, m)
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


inp = lambda cast=int: [cast(x) for x in input().split()]
printf = lambda s='', *args, **kwargs: print(str(s).format(*args), flush=True, **kwargs)
(t,) = inp()
for _ in range(t):
	(n, m) = inp()
	A = set(inp())
	B = set(inp())
	C = A.intersection(B)
	if len(C) > 0:
		print('YES')
		print(1, C.pop())
	else:
		print('NO')


def solve():
	[m, n] = [int(x) for x in input().split()]
	A = set([int(x) for x in input().split()])
	B = set([int(x) for x in input().split()])
	for i in A:
		if i in B:
			print('Yes')
			print(1, i)
			return
	print('NO')

def main():
	n = int(input())
	while n > 0:
		solve()
		n -= 1
main()


t = int(input())
while t:
	t += -1
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	ans = 0
	for i in l1:
		if i in l2:
			ans = i
			break
	if ans:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	g = list(map(int, input().split()))
	u = 0
	if len(l) > len(g):
		for i in l:
			if i in g:
				u = i
				break
	else:
		for i in g:
			if i in l:
				u = i
				break
	if u != 0:
		print('YES')
		print(1, u)
	else:
		print('NO')


import sys, os
cases = int(sys.stdin.readline())
for x in range(cases):
	sizes = sys.stdin.readline()[:-1].split(' ')
	arrA = set(sys.stdin.readline()[:-1].split(' '))
	arrB = sys.stdin.readline()[:-1].split(' ')
	good = False
	for c in arrB:
		if c in arrA:
			print('YES')
			print('1', c)
			good = True
			break
	if not good:
		print('NO')


def subsequence(s1, s2):
	for i in s1:
		if i in s2:
			return i
	return False
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	c = subsequence(s1, s2)
	if c:
		print('YES')
		print(1, c)
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
testcases = int(input())
for j in range(testcases):
	(n, m) = map(int, input().split())
	vala = list(map(int, input().split()))
	valb = list(map(int, input().split()))
	ans = []
	for s in range(n):
		val = vala[s]
		for b in range(m):
			if valb[b] == val:
				ans.append(val)
				break
	if len(ans) > 0:
		print('YES')
		outy = [1, ans[0]]
		print(*outy)
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = [int(num) for num in input().split()]
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	c1 = 1
	for i in range(0, len(x)):
		if x[i] in y:
			c1 = 0
			print('YES')
			print(1, x[i])
			break
		else:
			continue
	if c1 == 1:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	c = []
	for i in range(n):
		if a[i] in b:
			c.append(a[i])
	if len(c) == 0:
		print('No')
	else:
		print('Yes')
		print(1, c[0])


t = int(input())
for _ in range(t):
	input()
	arr1 = set(map(int, input().split()))
	arr2 = set(map(int, input().split()))
	common = list(arr1 & arr2)
	if common:
		print('YES')
		print('1 {}'.format(common[0]))
	else:
		print('NO')


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	ans = []
	for _ in range(n):
		(a, b) = LI()
		l1 = LI()
		d = {}
		for x in l1:
			d[x] = x
		l2 = LI()
		f = False
		for x in l2:
			if x in d:
				f = True
				ans.append(x)
				break
		if not f:
			ans.append(-inf)
	for x in ans:
		if x == -inf:
			print('NO')
		else:
			print('YES')
			print(1, x)
main()


T = int(input())
while T > 0:
	list_size = [int(x) for x in input().split()]
	list1 = [int(x) for x in input().split()]
	list2 = [int(x) for x in input().split()]
	flag = 0
	for i in list1:
		if i in list2:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')
	T -= 1


def solve():
	t = input().split()
	(n, m) = (int(t[0]), int(t[1]))
	a = set()
	t = input().split()
	for item in t:
		a1 = int(item)
		a.add(a1)
	t2 = input().split()
	for item in t2:
		b1 = int(item)
		if b1 in a:
			print('YES')
			print(1, b1)
			return
	print('NO')
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	chk = 0
	for x in a:
		if x in b:
			print('YES')
			print(1, x)
			chk = 1
			break
	if chk == 1:
		continue
	else:
		print('NO')


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()))
	l = []
	for i in range(n):
		if a[i] in b:
			l.append(a[i])
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(l[0])


import collections
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	v = collections.Counter(b)
	c = 0
	for i in range(n):
		if a[i] in v:
			print('YES')
			print(1, a[i])
			c = 1
			break
	if c == 0:
		print('NO')


t = int(input())
for g in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	c = 0
	for i in l:
		if i in p:
			print('YES')
			print('1 ' + str(i))
			c = 1
			break
	if c == 0:
		print('NO')


import math
t = int(input())
rez = []
for i in range(t):
	A = input().split(' ')
	n = int(A[0])
	m = int(A[1])
	a = input().split(' ')
	b = input().split(' ')
	k = 0
	for j in range(n):
		a[j] = int(a[j])
	for j in range(m):
		b[j] = int(b[j])
		if b[j] in a:
			rez.append('YES')
			rez.append('1 ' + str(b[j]))
			k = 1
			break
	if k != 1:
		rez.append('NO')
for i in range(len(rez)):
	print(rez[i])


import sys
import string
import math
from collections import defaultdict
from functools import lru_cache
from collections import Counter
from fractions import Fraction

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def tmi(s):
	return tuple(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def js(lst):
	return ' '.join((str(d) for d in lst))

def jsns(lst):
	return ''.join((str(d) for d in lst))

def line():
	return sys.stdin.readline().strip()

def linesp():
	return line().split()

def iline():
	return int(line())

def mat(n):
	matr = []
	for _ in range(n):
		matr.append(linesp())
	return matr

def matns(n):
	mat = []
	for _ in range(n):
		mat.append([c for c in line()])
	return mat

def mati(n):
	mat = []
	for _ in range(n):
		mat.append(lmi(line()))
	return mat

def pmat(mat):
	for row in mat:
		print(js(row))

def solve(A, B):
	inter = set(A) & set(B)
	if inter:
		print('YES')
		print(1, list(inter)[0])
	else:
		print('NO')

def main():
	t = iline()
	for _ in range(t):
		line()
		arr = lmi(line())
		arr1 = lmi(line())
		solve(arr, arr1)
main()


from collections import defaultdict
inputs_cnt = int(input())
tree = defaultdict(set)
for input_index in range(inputs_cnt):
	(a_len, b_len) = map(int, input().split())
	a = set(input().split())
	b = set(input().split())
	intersection = list(a & b)
	if intersection:
		print('YES')
		print(1, intersection[0])
	else:
		print('NO')


import collections
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	aa = set(a)
	bb = set(b)
	flag = False
	for val in list(set(a + b)):
		if val in a and val in b:
			print('YES')
			print(1, val)
			flag = True
			break
	if not flag:
		print('NO')


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, M, A, B):
	both = set(A) & set(B)
	if not both:
		return 'NO'
	ans = next(iter(both))
	return 'YES\n1 ' + str(ans)
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, M) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	ans = solve(N, M, A, B)
	print(ans)


t = int(input())
for i in range(t):
	(n, m) = [int(i) for i in input().split()]
	a = set([int(i) for i in input().split()])
	b = set([int(i) for i in input().split()])
	s = a.intersection(b)
	if len(s) == 0:
		print('NO')
	else:
		print('YES')
		print(1, next(iter(s)))


import sys
import os
from collections import Counter, deque, defaultdict
import itertools
import math
import io

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def check_sorted(a):
	for i in range(len(a) - 1):
		if a[i] > a[i + 1]:
			return False
	return True

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def main():
	for i in range(ii()):
		(one, two) = mi()
		oneli = li()
		twoli = li()
		oneset = set(oneli)
		intersect = oneset.intersection(twoli)
		il = list(intersect)
		if len(intersect) == 0:
			print('NO')
			continue
		if len(intersect) > 0:
			print('YES')
			print(1, il[0])
			continue
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = set(map(int, input().split()))
	br = list(map(int, input().split()))
	flag = True
	for i in range(m):
		if br[i] in ar:
			flag = False
			print('YES')
			print(1, br[i])
			break
	if flag:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().strip().split()]
	a = set([int(x) for x in input().strip().split()])
	b = set([int(x) for x in input().strip().split()])
	inter = a.intersection(b)
	if len(inter) == 0:
		print('NO')
	else:
		print('YES')
		print('1 {}'.format(inter.pop()))


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	f = 1
	for i in li:
		if i in li2:
			print('YES')
			print(1, i)
			f = 0
			break
	if f:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = map(int, input().split())
	(found, ans) = (False, -1)
	for x in b:
		if x in a:
			found = True
			ans = x
			break
	if found:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	h = {}
	out = 0
	p = 0
	for i in b:
		if i not in h:
			h[i] = 1
	for i in a:
		if i in h:
			p = 1
			out = i
			break
	if p == 0:
		print('NO')
	else:
		print('YES')
		print(1, out)


import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
letters = ascii_letters[:26]
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	first = set(map(int, input().split()))
	second = set(map(int, input().split()))
	res = list(first.intersection(second))
	if not len(res):
		print('NO')
	else:
		print('YES')
		print('1', res[0])


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	ar = set(map(int, input().split()))
	br = set(map(int, input().split()))
	cr = ar.intersection(br)
	if len(cr) == 0:
		print('NO')
	else:
		print('YES')
		print(1, cr.pop())


t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = dict()
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	flag = 0
	for i in range(n):
		val = b[i]
		if val in d:
			flag = 1
			ans = val
			break
	if flag == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	array1 = input().split()
	array1.sort()
	array2 = input().split()
	array2.sort()
	result = 0
	for i in range(len(array1)):
		if array1[i] in array2:
			result = int(array1[i])
			break
	if result > 0:
		print('YES')
		print('1', result)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 'n'
	for i in a:
		for j in b:
			if i == j:
				ans = i
	if ans == 'n':
		print('NO')
	else:
		print('YES')
		print('1', ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = list(map(int, input().split()))
	found = False
	for num in b:
		if num in a:
			found = True
			break
	if found:
		print('YES')
		print(1, num)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	num = [0 for i in range(1001)]
	ln = list(map(int, input().split()))
	for i in ln:
		if num[i] == 0:
			num[i] = 1
	lm = list(map(int, input().split()))
	di = -1
	for i in lm:
		if num[i] == 1:
			di = i
			break
	if di == -1:
		print('NO')
	else:
		print('YES')
		print(1, di)


import os
import sys
from io import BytesIO, IOBase
import math
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	sa = list(map(int, input().split()))
	sb = list(map(int, input().split()))
	v = -1
	b = 1
	c = -1
	s = list()
	s.append(4)
	for i in range(a):
		if sa[i] in sb:
			v = sa[i]
			break
	if v == -1:
		print('NO')
	else:
		v = v + b + c
		print('YES')
		print(1, v, sep=' ')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a & b
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		for x in c:
			print('1', x)
			break


for t in range(int(input())):
	(n, m) = tuple(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {el: True for el in a}
	(ispos, elem) = (False, None)
	for el in b:
		if d.get(el, None) is not None:
			ispos = True
			elem = el
			break
	if ispos:
		print('YES')
		print('1', elem)
	else:
		print('NO')


R = lambda : {*map(int, input().split())}
(t,) = R()
exec(t * "R();s=R()&R();print(s and f'YES 1 {s.pop()}'or'NO');")


import collections
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	cnt = collections.Counter(a)
	ans = -1
	for i in range(m):
		if b[i] in cnt:
			ans = b[i]
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


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


for _ in range(int(input())):
	input()
	flag = 0
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	for i in A:
		if B.count(i) > 0:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = input().split(' ')
	lst = list(map(int, input().split(' ')))
	lstt = list(map(int, input().split(' ')))
	a_set = set(lst)
	b_set = set(lstt)
	x = a_set.intersection(b_set)
	if len(x) > 0:
		print('YES')
		print(1, list(x)[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	arr1 = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	arr1.sort()
	arr2.sort()
	ans = 0
	flag = 0
	for i in range(n):
		for j in range(m):
			if arr1[i] == arr2[j]:
				ans = arr1[i]
				flag = 1
				break
		if flag == 1:
			break
	if flag == 1:
		print('YES')
		print('1', ans)
	else:
		print('NO')


for _ in range(0, int(input())):
	(n, m) = map(int, input().split())
	ar = set(map(int, input().split()))
	br = set(map(int, input().split()))
	a = ar & br
	ans = list(a)
	if len(ans) > 0:
		print('YES')
		print(1, ans[-1])
	else:
		print('NO')


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr1 = set(list(map(int, input().split())))
	arr2 = set(list(map(int, input().split())))
	ok = 'NO'
	for x in arr1:
		if x in arr2:
			ok = x
			break
	if ok == 'NO':
		print(ok)
	else:
		print('YES')
		print(1, ok)


import sys
t = int(input())

def sub(list1, list2):
	inter = list1.intersection(list2)
	if not inter:
		print('NO')
		return
	else:
		print('YES')
		print(1, list(inter)[0])
i = 0
for line in sys.stdin:
	if i == 0:
		(n, m) = (int(x) for x in line.split())
	elif i == 1:
		list1 = [int(x) for x in line.split()]
		list1 = set(list1)
	elif i == 2:
		list2 = [int(x) for x in line.split()]
		list2 = set(list2)
		sub(list1, list2)
		i = -1
	i += 1


t = int(input())
for f in range(t):
	x = input().split()
	n = int(x[0])
	m = int(x[1])
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	flag = True
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			flag = False
			break
	if flag:
		print('NO')


for _ in range(int(input())):
	input()
	A = list(map(int, input().strip().split()))
	B = list(map(int, input().strip().split()))
	vals_a = [0] * 1001
	for a in A:
		vals_a[a] += 1
		vals_a[a] = min(vals_a[a], 1)
	ans = -1
	for b in B:
		if vals_a[b] > 0:
			ans = b
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


n = int(input())
for i in range(n):
	l = input().split()
	li1 = input().split()
	li2 = input().split()
	for j in li2:
		if j in li1:
			print('YES')
			print(1, j)
			break
	else:
		print('NO')


for TEST in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	S = set(A) & set(B)
	if S:
		print('YES')
		print(1, next(iter(S)))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:m]
	ans = 0
	found = False
	for e in b:
		if e in a:
			ans = e
			found = True
			break
	if not found:
		for e in a:
			if e in b:
				ans = e
				found = True
				break
	if not found:
		print('NO')
	else:
		print('YES')
		print('1 ', ans)


testcases = int(input())
for i in range(testcases):
	(n, m) = map(int, input().strip().split(' '))
	x = list(map(int, input().strip().split(' ')))
	y = list(map(int, input().strip().split(' ')))
	flag = 0
	for p in range(len(x)):
		for q in range(len(y)):
			if x[p] == y[q]:
				print('YES')
				print(1, x[p])
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')


import os, io
from sys import stdout
import collections
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import sys

def primes(n):
	sieve = [True] * n
	for i in range(3, int(n ** 0.5) + 1, 2):
		if sieve[i]:
			sieve[i * i::2 * i] = [False] * ((n - i * i - 1) // (2 * i) + 1)
	return [2] + [i for i in range(3, n, 2) if sieve[i]]

def binomial_coefficient(n, k):
	if 0 <= k <= n:
		ntok = 1
		ktok = 1
		for t in range(1, min(k, n - k) + 1):
			ntok *= n
			ktok *= t
			n -= 1
		return ntok // ktok
	else:
		return 0

def powerOfK(k, max):
	if k == 1:
		return [1]
	if k == -1:
		return [-1, 1]
	result = []
	n = 1
	while n <= max:
		result.append(n)
		n *= k
	return result

def divisors(n):
	i = 1
	result = []
	while i * i <= n:
		if n % i == 0:
			if n / i == i:
				result.append(i)
			else:
				result.append(i)
				result.append(n / i)
		i += 1
	return result

def distance(xa, ya, xb, yb):
	return ((ya - yb) ** 2 + (xa - xb) ** 2) ** 0.5

def digitsSum(n):
	if n == 0:
		return 0
	r = 0
	while n > 0:
		r += n % 10
		n //= 10
	return r

def isValid(i, j, n, m):
	return i >= 0 and i < n and (j >= 0) and (j < m)

def print_grid(grid):
	for line in grid:
		print(' '.join(map(str, line)))

def kadane(a, size):
	max_so_far = 0
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def prefixSum(arr):
	for i in range(1, len(arr)):
		arr[i] = arr[i] + arr[i - 1]
	return arr

def ceil(n, d):
	if n % d == 0:
		return n // d
	else:
		return n // d + 1

def _abs(a, b):
	return int(abs(a - b))

def evenodd(l):
	even = [e for e in l if e & 1 == 0]
	odd = [e for e in l if e & 1]
	return (even, odd)
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if len(a) > len(b):
		(a, b) = (b, a)
	s = set(a)
	found = False
	for e in b:
		if e in s:
			print('YES')
			print(1, e)
			found = True
			break
	if found:
		continue
	print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	for x in a:
		if x in b:
			flag = 1
			z = x
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, z)


t = int(input())
while t:
	(n, m) = map(int, input().rstrip().split())
	a = set(map(int, input().rstrip().split()))
	b = set(map(int, input().rstrip().split()))
	T = False
	for i in a:
		if i in b:
			T = True
			ans = i
			break
	if T:
		print('YES')
		print('1 ' + str(ans))
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	d = {}
	for i in l:
		d[i] = 0
	ans = -1
	for i in p:
		try:
			c = d[i]
			ans = i
			break
		except:
			pass
	if ans + 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
if t >= 1 and t <= 1000:
	n_list = []
	m_list = []
	for test in range(t):
		(n, m) = map(int, input().split())
		n_list = [int(i) for i in input().split()][:n]
		m_list = [int(i) for i in input().split()][:m]
		a_set = set(n_list)
		b_set = set(m_list)
		common = list(a_set.intersection(b_set))
		if len(common) > 0:
			print('YES')
			if len(common) > 1:
				print('1', common[0], sep=' ')
			else:
				print(len(common), *common, sep=' ')
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	broken = 0
	for item in a:
		if item in b:
			print('YES')
			print(1, item)
			broken = 1
			break
	if not broken:
		print('NO')


for q in range(int(input())):
	(n, k) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	x = A & B
	if len(x) > 0:
		print('YES')
		print(1, list(A & B)[0])
	else:
		print('NO')


t = int(input())
for x in range(t):
	(n, m) = map(int, input().split())
	na = list(map(int, input().split()))
	ma = list(map(int, input().split()))
	if n > m:
		a = ma
		b = na
	else:
		a = na
		b = ma
	for y in range(len(a)):
		if a[y] in b:
			print('YES')
			print(1, a[y])
			break
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = list(set(a).intersection(b))
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c[0])
	t -= 1


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d = 0
	for i in l1:
		for j in l2:
			if i == j:
				print('YES')
				print(1, i)
				d = 1
				break
		if d == 1:
			break
	if d == 0:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(n):
		if a[i] in b:
			c.append(a[i])
			break
	if len(c) != 0:
		print('YES')
		print(len(c), *c)
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	if x == y:
		print('YES')
		print(1, x[0])
	else:
		su = 0
		flag = 0
		for i in range(0, len(x)):
			for j in range(0, len(y)):
				if x[i] == y[j]:
					flag = 1
					su = x[i]
					break
		if flag == 1:
			print('YES')
			print(1, su)
		else:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = sorted(a)
	b = sorted(b)
	c = -1
	d = -1
	for i in a:
		if i in b:
			c = i
			break
	if c == -1:
		print('NO')
	else:
		print('YES')
		print(1, c)


def fast(n, m, A, B):
	for num in set(A).intersection(set(B)):
		return [num]
	return []

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = [int(x) for x in input().split()]
		A = [int(x) for x in input().split()]
		B = [int(x) for x in input().split()]
		result = fast(n, m, A, B)
		if len(result) == 0:
			print('NO')
		else:
			print('YES')
			print(f'1 {result[0]}')
main()


def fuck(A, B):
	s = set(A)
	for i in B:
		if i in s:
			print('YES')
			print(1, ' ', i)
			return
	print('NO')
t = int(input())
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	A = [int(i) for i in input().split()][:n]
	B = [int(i) for i in input().split()][:m]
	fuck(A, B)


t = int(input())
while t:
	t = t - 1
	flag = 0
	(m, n) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in range(0, m):
		for j in range(0, n):
			if a[i] == b[j]:
				flag = 1
				value = a[i]
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, value)


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[a[i]] = 1
	f = 0
	for i in range(m):
		try:
			d[b[i]] += 1
			f = 1
			p = b[i]
			break
		except:
			continue
	if f == 1:
		print('YES')
		print(str(1) + ' ' + str(p))
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a1 = list(map(int, input().split()))[:n]
	b1 = list(map(int, input().split()))[:m]
	c = 0
	cl = []
	for i in range(len(b1)):
		if b1[i] in a1:
			print('YES')
			print(1, end=' ')
			print(b1[i])
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	nonmatch = list(set(a) - set(b)) + list(set(b) - set(a))
	match = []
	for i in a:
		if i not in nonmatch:
			match.append(i)
	if match == []:
		print('NO')
	else:
		print('YES')
		print(1, match[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	s = set(a) & set(b)
	if len(s) >= 1:
		print('YES\n1', s.pop())
	else:
		print('NO')


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


t = int(input())
dict = {}
for i in range(t):
	numm = str(input()).split(' ')
	nn = str(input()).split(' ')
	mm = str(input()).split(' ')
	dict[i] = (nn, mm)
stop = 0
for key in dict.keys():
	for j in range(len(dict[key][0])):
		for k in range(len(dict[key][1])):
			if dict[key][0][j] == dict[key][1][k]:
				print('YES')
				print('1', dict[key][0][j])
				stop = 1
				break
		if stop == 1:
			break
	if stop == 0:
		print('NO')
	stop = 0


t = int(input())
while t > 0:
	t -= 1
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ok = True
	val = -1
	for i in a:
		if i in b:
			ok = False
			val = i
			break
	if ok == True:
		print('NO')
	else:
		print('YES')
		print('1 {}'.format(val))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set([int(i) for i in input().split()])
	b = set([int(i) for i in input().split()])
	if a & b:
		print('YES')
		print(1, list(a & b)[0])
	else:
		print('NO')


from math import *
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	for i in range(m):
		for j in range(n):
			if a[j] == b[i]:
				k = a[j]
				f = 1
				break
		if f == 1:
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		print(1, k)


test = int(input())
for t in range(test):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			flag = True
			break
	if not flag:
		print('NO')


for i in range(int(input())):
	(m, n) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	a = max(l1, l2, key=len)
	if a == l2:
		b = l1
	else:
		b = l2
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 998244353
INF = float('inf')
from math import factorial
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		(n, m) = RL()
		arra = RLL()
		arrb = RLL()
		tag = False
		for i in range(n):
			for j in range(m):
				if arra[i] == arrb[j]:
					print('YES')
					print(1, arra[i])
					tag = True
					break
			if tag:
				break
		else:
			print('NO')
main()


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for i in range(n):
		if a[i] in b:
			flag = True
			print('YES')
			print(1, a[i])
			break
	if not flag:
		print('NO')


import math
import os
import random
import re
import sys
import copy
from collections import Counter

def bs(arr, x, l, r):
	if l <= r:
		mid = (r + l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			return bs(arr, x, mid + 1, r)
		else:
			return bs(arr, x, l, mid - 1)
	else:
		return -1

def solve():
	for _ in range(int(input())):
		(n, m) = map(int, input().strip().split())
		l1 = list(map(int, input().strip().split()))
		l2 = list(map(int, input().strip().split()))
		l1.sort()
		l2.sort()
		f = 0
		for i in range(n):
			if bs(l2, l1[i], 0, m - 1) != -1:
				print('YES')
				print(1, l1[i])
				f = 1
				break
			else:
				f = 0
				continue
		if f == 0:
			print('NO')
solve()


for _ in range(0, int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	aa = set(a)
	bb = set(b)
	cc = list(aa)
	cc += list(bb)
	n1 = len(cc)
	n2 = len(set(cc))
	if n1 == n2:
		print('NO')
	else:
		for i in cc:
			feq = cc.count(i)
			if feq == 2:
				print('YES')
				print('1 ', i)
				break


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	flag = False
	l = []
	for i in range(m):
		if b[i] in a:
			flag = True
			l.append(b[i])
			break
	if flag:
		print('YES')
		print(str(len(l)) + ' ' + str(l[0]))
	else:
		print('NO')


for x in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	r = 0
	k = 0
	for i in range(n):
		if a[i] in b:
			r = 1
			k = a[i]
			break
	if r == 0:
		print('NO')
	else:
		print('YES')
		print(1, k)


def ans():
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in b:
		if i in a:
			print('YES')
			print('1', end=' ')
			print(i)
			return
	print('NO')
t = int(input())
for i in range(t):
	ans()


def readn():
	return int(input())

def readlist():
	return list(map(int, input().split()))

def readnos():
	return map(int, input().split())
for _ in range(int(input())):
	(n, m) = readnos()
	a = readlist()
	b = readlist()
	f = 1
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				f = 0
				break
		if f == 0:
			break
	if f == 0:
		print('YES')
		print(1, a[i], sep=' ')
	else:
		print('NO')


def findcommon(arr_a, arr_b):
	for i in range(a):
		if arr_a[i] in arr_b:
			print('YES')
			print(str(1), arr_a[i])
			return
	else:
		print('NO')
t = int(input())
for i in range(t):
	ab = input().strip().split()
	a = int(ab[0])
	b = int(ab[1])
	arr_a = list(map(int, input().strip().split()))
	arr_b = list(map(int, input().strip().split()))
	findcommon(arr_a, arr_b)


for _ in range(int(input())):
	(n1, n2) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	found = False
	if n1 >= n2:
		for i in range(n1):
			if lst1[i] in lst2:
				print('YES')
				found = True
				print(1, lst1[i])
				break
	else:
		for i in range(n2):
			if lst2[i] in lst1:
				print('YES')
				found = True
				print(1, lst2[i])
				break
	if found == False:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = False
	for aa in a:
		for bb in b:
			if aa == bb:
				print('YES')
				print(1, aa)
				ok = True
				break
		if ok:
			break
	if not ok:
		print('NO')


y = int(input())
for i in range(y):
	(n, m) = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	sa = set(a)
	sb = set(b)
	sc = set()
	sc = sa.intersection(sb)
	if len(sc) == 0:
		print('NO')
	else:
		print('YES')
		print(1, ' ', sep='', end='')
		for j in sc:
			print(j)
			break


for _ in range(int(input())):
	(lena, lenb) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	found = False
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			found = True
			break
	if not found:
		print('NO')


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	(n, m) = li()
	l1 = set(li())
	l2 = set(li())
	ans = -1
	for i in l1:
		if i in l2:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arra = [0] * 1001
	arrb = [0] * 1001
	for i in range(len(a)):
		arra[a[i]] += 1
	for i in range(len(b)):
		arrb[b[i]] += 1
	u = 0
	for i in range(1001):
		if arra[i] != 0 and arrb[i] != 0:
			print('YES')
			print(1, i)
			u = 1
			break
	if u == 0:
		print('NO')


for i in range(int(input())):
	(m, n) = list(map(int, input().split()))
	m_arr = list(map(int, input().split()))
	n_arr = list(map(int, input().split()))
	c = False
	for i in range(m):
		if m_arr[i] in n_arr:
			print('YES')
			print(1, m_arr[i])
			c = True
			break
	if c == False:
		print('NO')


t = int(input())
for z in range(t):
	arr = list(map(int, input().split()))
	(n, m) = (arr[0], arr[1])
	c = []
	(i, j) = (0, 0)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	while i < n:
		array = []
		no = a[i]
		while j < m and b[j] != no:
			j += 1
		if j != m:
			array.append(no)
			break
		else:
			i += 1
			j = 0
	if len(array):
		print('YES')
		print(len(array), end=' ')
		for i in array:
			print(i, end=' ')
		print()
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	seen = set(a)
	for x in b:
		if x in seen:
			print('YES')
			print(1, x)
			break
	else:
		print('NO')


a = 1
for i in range(int(input())):
	l = 0
	x = input().split()
	y = list(input().split())
	z = list(input().split())
	for j in y:
		if j in z:
			print('YES')
			print(a, j)
			l = 1
			break
	if l != 1:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	k = list(set(arr1) & set(arr2))
	if k:
		print('YES')
		print('1', k[0])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = set(a)
	e = set(b)
	f = d.intersection(e)
	list1 = list(f)
	if list1 == []:
		print('NO')
	else:
		print('YES')
		print('1', list1[0])


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_elems = [0] * 1001
	for i in range(n):
		a_elems[a[i]] = 1
	for i in range(m):
		if a_elems[b[i]] == 1:
			print('YES')
			print(1, b[i])
			break
	else:
		print('NO')


import sys

def read():
	return [int(i) for i in sys.stdin.readline().strip().split()]
for i in range(int(input())):
	(n, m) = read()
	a = read()
	b = read()
	if m < n:
		for j in range(m):
			if b[j] in a:
				print('YES')
				print(1, b[j])
				break
		else:
			print('NO')
	else:
		for j in range(n):
			if a[j] in b:
				print('YES')
				print(1, a[j])
				break
		else:
			print('NO')


I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, m) = I()
	a = I()
	b = I()
	if not set(a) & set(b):
		print('NO')
	else:
		for i in a:
			if b.count(i):
				print('YES')
				print(1, i)
				break


t = int(input())
for qwe in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				flag = True
				ans = a[i]
		if flag:
			break
	if flag:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = (int(x) for x in input().split())
	a = list((int(x) for x in input().split()))
	b = list((int(x) for x in input().split()))
	c = []
	count = 0
	for i in range(n):
		if a[i] in b:
			count += 1
			if a[i] not in c:
				c.append(a[i])
	if count == 0:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(c[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(s) for s in input().split()]
	b = [int(s) for s in input().split()]
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


import sys
input = sys.stdin.readline
f = lambda : list(map(int, input().split()))
res = []
for _ in range(int(input())):
	(n, m) = f()
	a = f()
	b = f()
	c = set(a).intersection(set(b))
	if c:
		print('YES')
		print(1, c.pop())
	else:
		print('NO')


t = int(input())
for v in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		dic.update({a[i]: 1})
	found = False
	for i in range(m):
		ans = dic.get(b[i], -1)
		if ans != -1:
			found = True
			ele = b[i]
			break
	if found:
		print('YES')
		print(f'1 {ele}')
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = input().split(' ')
	n = int(n)
	m = int(m)
	arr_1 = input().split(' ')
	arr_2 = input().split(' ')
	check = 0
	for j in range(n):
		if arr_1[j] in arr_2:
			print('YES')
			print('1', arr_1[j])
			check = 1
			break
	if check == 0:
		print('NO')


def func(n, m):
	n = list(map(int, n.split()))
	m = list(map(int, m.split()))
	common = list(set(n).intersection(set(m)))
	if len(common) == 0:
		return 'NO'
	else:
		return 'YES' + '\n' + '1 ' + str(common[0])

def main():
	t = int(input())
	for i in range(t):
		input()
		n = input()
		m = input()
		print(func(n, m))
main()


def inArr(arr, i, n):
	if i == n - 1:
		return True
	if arr[i] in arr:
		return inArr(arr, i + 1)
	else:
		return False

def main():
	t = int(input())
	for _ in range(t):
		(n, m) = list(map(int, input().split()))
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		array = []
		flag = True
		current = -1
		for e in a:
			if e in b:
				flag = False
				current = e
				break
		if flag:
			print('NO')
		else:
			print('YES')
			print(1, current)
main()


import sys, heapq, bisect
tc = int(sys.stdin.readline())
for _ in range(tc):
	(n, m) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	c = []
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				c.append(a[i])
	if not c:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


cases = int(input())
for case in range(cases):
	answer = False
	(n, m) = [int(item) for item in input().split(' ')]
	a = [int(item) for item in input().split(' ')]
	b = [int(item) for item in input().split(' ')]
	for term in a:
		if term in b:
			answer = True
			break
	if answer:
		print('YES')
		print(1, term)
	else:
		print('NO')


t = int(input())
ans = []
for i in range(t):
	q = 1
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	for i in a:
		if i in b:
			q = 0
			ans.append('YES')
			ans.append((1, i))
			break
	if q == 1:
		ans.append('NO')
for i in ans:
	if type(i) != str:
		print(*i)
	else:
		print(i)


t = int(input())
for _ in range(t):
	nm = input().split()
	n = int(nm[0])
	m = int(nm[1])
	first = list(map(int, input().split()))
	second = list(map(int, input().split()))
	second_track = {k: True for k in second}
	for item in first:
		if item in second_track:
			print('YES')
			print(1, item)
			break
	else:
		print('NO')


def solve(n, k, a, b):
	for i in a:
		if i in b:
			return (i, True)
	return (0, False)
t = int(input())
for we in range(t):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	(x, res) = solve(n, k, a, b)
	if res:
		print('YES')
		print('1', x)
	else:
		print('NO')


for z in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	Set_a = set(a)
	Set_b = set(b)
	ans = 0
	flag = False
	for x in Set_a:
		if x in Set_b:
			flag = True
			ans = x
			break
	if flag:
		print('YES')
		print(1, ans)
	else:
		print('NO')


import sys, math, collections
from collections import defaultdict

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def get_array():
	l = list(map(int, input().split()))
	return l

def get_2_ints():
	(a, b) = map(int, input().split())
	return (a, b)

def get_3_ints():
	(a, b, c) = map(int, input().split())
	return (a, b, c)

def sod(n):
	(n, c) = (str(n), 0)
	for i in n:
		c += int(i)
	return c

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	floor = -1
	while left <= right:
		mid = (left + right) // 2
		if A[mid] == x:
			return A[mid]
		elif x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			left = mid + 1
	return floor

def main():
	for tt in range(int(input())):
		(a, b) = get_2_ints()
		l1 = get_array()
		flag = 0
		d = defaultdict(int)
		for i in range(a):
			d[l1[i]] = 1
		l2 = get_array()
		for i in range(b):
			if d[l2[i]]:
				print('YES')
				print(1, l2[i])
				flag = 1
				break
		if not flag:
			print('NO')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	run = False
	for i in a:
		for j in b:
			if i == j:
				run = True
				k = i
	if run == True:
		print('YES')
		print('1 ' + str(k))
	else:
		print('NO')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(n, m) = In()
		arr1 = L()
		arr2 = L()
		flag = 0
		v = 0
		for i in arr1:
			for j in arr2:
				if i == j:
					flag = 1
					v = i
					break
		if flag:
			print('YES')
			print(1, v)
		else:
			print('NO')
main()


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def solve():
	l = inlt()
	a = inlt()
	b = inlt()
	for x in a:
		if x in b:
			print('YES')
			print('1 ' + str(x))
			return
	print('NO')
	return
n = inp()
for i in range(n):
	solve()


for _ in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	for i in a:
		d[i] = 1
	c = 0
	for i in b:
		if d.get(i, None):
			print('YES')
			print('1', i)
			c = 1
			break
	if c == 0:
		print('NO')


def f(l1, l2):
	l = 0
	arr = 0
	for i in l1:
		if l == 0:
			if i in l2:
				l = 1
				arr = i
				return (l, arr)
	return (0, 0)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	(l, ele) = f(l1, l2)
	if l:
		print('YES')
		print(l, ele)
	else:
		print('NO')


import sys
from collections import defaultdict
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
t = inp()
for _ in range(t):
	(n, m) = inpl()
	a = inpl()
	b = inpl()
	B = set(b)
	res = -1
	for x in a:
		if x in B:
			res = x
			break
	if res == -1:
		print('NO')
	else:
		print('YES')
		print(1, res)


T = int(input())
while T:
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A = set(A)
	B = set(B)
	c = -1
	for i in A:
		if i in B:
			c = i
	if c != -1:
		print('YES')
		print(1, c)
	else:
		print('NO')
	T = T - 1


def common_member(a, b):
	a_set = set(a)
	b_set = set(b)
	if a_set & b_set:
		return a_set & b_set
	else:
		return 'F'
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()))
	res = common_member(a, b)
	if res != 'F':
		print('YES')
		res = list(res)
		print('1', res[0])
	else:
		print('NO')


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


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()))
	(c, ans) = (0, 0)
	a.sort()
	b.sort()
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ans = a[i]
				break
		if ans != 0:
			break
		c += 1
	if c == n:
		print('NO')
	else:
		print('YES')
		print('1', ans)


def binn(a, l, h, m):
	flag = True
	while l <= h:
		mid = (l + h) // 2
		if a[mid] == m:
			return mid
		if a[mid] > m:
			h = mid - 1
		else:
			l = mid + 1
	return -1
for t in range(int(input())):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	flag = True
	for x in a:
		if binn(b, 0, len(b) - 1, x) != -1:
			print('YES\n1', x)
			flag = False
			break
	if flag:
		print('NO')


import sys
(_ord, inp, num, neg, _Index) = (lambda x: x, [], 0, False, 0)
(i, s) = (0, sys.stdin.buffer.read())
try:
	while True:
		if s[i] >= b'0'[0]:
			num = 10 * num + _ord(s[i]) - 48
		elif s[i] == b'-'[0]:
			neg = True
		elif s[i] != b'\r'[0]:
			inp.append(-num if neg else num)
			(num, neg) = (0, False)
		i += 1
except IndexError:
	pass
if s and s[-1] >= b'0'[0]:
	inp.append(-num if neg else num)

def fin(size=None):
	global _Index
	if size == None:
		ni = _Index
		_Index += 1
		return inp[ni]
	else:
		ni = _Index
		_Index += size
		return inp[ni:ni + size]
t = fin()
for _ in range(t):
	(n, m) = fin(2)
	a = set(fin(n))
	b = set(fin(m))
	if a.intersection(b):
		print('YES', '\n1', list(a.intersection(b))[0])
	else:
		print('NO')


def solve():
	(n, m) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	a = set(l)
	b = set(l2)
	a = a & b
	if a:
		print('YES')
		print('1 ', a.pop())
	else:
		print('NO')
	return
t = int(input())
for _ in range(t):
	solve()


for __ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	for i in range(n):
		if a[i] in b:
			f = 1
			c = a[i]
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		print(1, c)


t = int(input())
cfl = []
for j in range(t):
	(n, m) = map(int, input().split())
	al = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	cl = []
	for i in range(n):
		if al[i] in bl:
			cl.append(al[i])
			break
	cfl.append(cl)
	j += 1
for it in range(len(cfl)):
	if bool(cfl[it]):
		print('YES')
		print(len(cfl[it]), ' ', end='')
		for x in range(len(cfl[it])):
			print(cfl[it][x], ' ', end='')
		print('')
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	arr1 = set(input().split())
	arr2 = set(input().split())
	commonset = arr1 & arr2
	if commonset != set():
		print('YES')
		print(1, list(commonset)[0])
	else:
		print('NO')
	t -= 1


for i in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(set(l1).intersection(l2))
	if len(l3) >= 1:
		print('YES')
		print(1, l3[0])
	else:
		print('NO')


a = int(input(''))
for i in range(0, a):
	(b, c) = map(int, input().split())
	d = list(map(int, input().split()))
	e = list(map(int, input().split()))
	k = []
	h = 0
	for j in d:
		if j in e:
			k.append(j)
	for m in k:
		if m >= 0:
			h += 1
	if h != 0:
		o = min(k)
		print('YES')
		print(f'1 {o}')
	else:
		print('NO')


def func():
	(s1, s2) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	for elem in a1:
		if elem in a2:
			return elem
	return 'NO'
t = int(input())
for _ in range(t):
	sol = func()
	if sol == 'NO':
		print('NO')
	else:
		print('YES')
		print('1 ', sol)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = set([int(i) for i in input().split()])
	b = set([int(i) for i in input().split()])
	c = list(a & b)
	if c:
		print('YES')
		print(1, min(c))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	record = set(map(int, input().split()))
	mArr = list(map(int, input().split()))
	possible = False
	for i in mArr:
		num = len(record)
		record.add(i)
		if num == len(record):
			possible = True
			print(f'\nYES\n1 {i}', end='')
			break
		else:
			record.remove(i)
	if not possible:
		print('\nNO', end='')


for i in range(int(input())):
	(n, m) = list(map(int, input().split(' ')))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	c = 0
	for j in a:
		if j in b:
			c = j
	if c == 0:
		print('NO')
	else:
		print('YES')
		print(1, c)


number = int(input())
for i in range(number):
	(a, b) = input().split()
	array1 = input().split()
	array2 = input().split()
	result_str = 'NO'
	result_val = 0
	for j in range(int(a)):
		for k in range(int(b)):
			if array1[j] == array2[k]:
				result_str = 'YES'
				result_val = array2[k]
				break
		else:
			continue
		break
	print(result_str)
	if result_str == 'YES':
		print(f'{1} {result_val}')


import sys
T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	G = [0 for i in range(1001)]
	for i in range(n):
		G[A[i]] = 1
	v = -1
	for i in range(m):
		if G[B[i]] == 1:
			v = B[i]
			break
	if v == -1:
		print('NO')
	else:
		print('YES')
		print(1, v)


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


for _ in range(int(input())):
	[int(x) for x in input().split()]
	x = set([int(x) for x in input().split()])
	y = set([int(x) for x in input().split()])
	if len(x.intersection(y)) > 0:
		print('YES')
		print(1, min(x.intersection(y)))
	else:
		print('NO')


from bisect import *
from collections import *
from itertools import *
import functools
import sys
import math
from decimal import *
from copy import *
from heapq import *
from fractions import *
getcontext().prec = 30
MAX = sys.maxsize
MAXN = 1000010
MOD = 10 ** 9 + 7
spf = [i for i in range(MAXN)]
spf[0] = spf[1] = -1

def sieve():
	for i in range(2, MAXN, 2):
		spf[i] = 2
	for i in range(3, int(MAXN ** 0.5) + 1):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def fib(n, m):
	if n == 0:
		return [0, 1]
	else:
		(a, b) = fib(n // 2)
		c = a % m * (b % m * 2 - a % m) % m
		d = a % m * (a % m) % m + b % m * b % m % m
		if n % 2 == 0:
			return [c, d]
		else:
			return [d, c + d]

def charIN(x=' '):
	return sys.stdin.readline().strip().split(x)

def arrIN(x=' '):
	return list(map(int, sys.stdin.readline().strip().split(x)))

def ncr(n, r):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % MOD
		den = den * (i + 1) % MOD
	return num * pow(den, MOD - 2, MOD) % MOD

def flush():
	return sys.stdout.flush()
for _ in range(int(input())):
	(n, m) = arrIN()
	a = arrIN()
	b = arrIN()
	ca = Counter(a)
	cb = Counter(b)
	for i in ca.keys():
		if cb[i] > 0:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	d = {}
	for j in arr1:
		if j not in d:
			d[j] = 1
	flag = 0
	for j in arr2:
		if j in d:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(str(1) + ' ' + str(j))


from sys import stdin, stdout
INF = 100000000000.0
import sys

def get_int():
	return int(stdin.readline().strip())

def get_ints():
	return map(int, stdin.readline().strip().split())

def get_array():
	return list(map(int, stdin.readline().strip().split()))

def get_string():
	return stdin.readline().strip()

def op(c):
	return stdout.write(c)
from collections import defaultdict
for _ in range(int(stdin.readline())):
	(n, m) = get_ints()
	a = get_array()
	b = get_array()
	ans = []
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ans.append(a[i])
				break
	if len(ans) >= 1:
		print('YES')
		print(1, ans[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ccc = [0] * 1006
	a = list(map(int, input().split()))
	a = list(set(a))
	b = list(map(int, input().split()))
	b = list(set(b))
	count = 0
	for i in range(len(a)):
		ccc[a[i]] += 1
		if ccc[a[i]] > 1:
			count += 1
	for i in range(len(b)):
		ccc[b[i]] += 1
		if ccc[b[i]] > 1:
			count += 1
	if count == 0:
		print('NO')
	else:
		print('YES')
		for i in range(len(ccc)):
			if ccc[i] == 2:
				break
		print(1, i)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = set()
	for i in a:
		d.add(i)
	for i in b:
		if i in d:
			print('YES')
			print('1', i)
			break
	else:
		print('NO')


results = []
tests = int(input())
for _x in range(tests):
	n = list((int(item) for item in input().split()))
	a = list((int(item) for item in input().split()))[:n[0]]
	b = list((int(item) for item in input().split()))[:n[1]]
	c = list(set(a) & set(b))
	if len(c) == 0:
		results.append('NO')
	else:
		results.append(f'YES\n1 {c[0]}')
print(*results, sep='\n')


try:
	t = int(input())
	while t != 0:
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		(result, vlaue) = (0, 0)
		for i in range(n):
			if a[i] in b:
				result = 1
				vlaue = a[i]
				break
		if result == 0:
			print('NO')
		else:
			print('YES')
			print(1, vlaue, sep=' ')
		t = t - 1
except EOFError:
	print(' ')


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools
from collections import deque, defaultdict, OrderedDict
import collections

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		(n, m) = ria()
		a = ria()
		b = ria()
		c = 0
		for i in a:
			if i in b:
				c = 1
				print('YES')
				print(1, i)
				break
		if c == 0:
			print('NO')
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0:
			return 0
	return 1
num = int(z())
for _ in range(num):
	(a, b) = map(int, z().split())
	l1 = list(map(int, z().split()))
	l2 = list(map(int, z().split()))
	l3 = []
	(t, c) = (0, 0)
	for i in l1:
		if i in l2:
			t += 1
			c += i
			break
	for i in l2:
		if i in l1 and t == 0:
			t += 1
			c += i
			break
	if t != 0:
		print('YES')
		print(t, c)
	else:
		print('NO')


i = int(input())
for x in range(i):
	_ = input()
	a = set(input().split())
	b = set(input().split())
	c = a.intersection(b)
	if len(c) != 0:
		print('YES')
		print('1', c.pop())
	else:
		print('NO')


import sys, collections, math

def in_out():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
from collections import Counter
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = 0
	for ele in a:
		if ele in b:
			print('YES')
			print(1, ele)
			f = 1
			break
	if f == 0:
		print('NO')


I = lambda : set(map(int, input().split()))
J = lambda : int(input())
K = lambda : list(map(int, input().split()))
for _ in range(int(input())):
	(n, m) = K()
	A = I()
	B = I()
	C = A & B
	print('YES\n1', C.pop()) if C else print('NO')


tot = int(input().strip())
while tot > 0:
	(n, m) = [int(x) for x in input().strip().split(' ', 1)]
	a = [int(x) for x in input().strip().split(' ')]
	b = [int(x) for x in input().strip().split(' ')]
	c = set(a).intersection(set(b))
	if c:
		print('YES')
		print(1, list(c)[0])
	else:
		print('NO')
	tot -= 1


tc = int(input())
while tc > 0:
	tc -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	b = set(b)
	c = a.intersection(b)
	if len(c) > 0:
		print('YES')
		c = list(c)
		print('1', c[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(c) for c in input().split()]
	a = set([int(c) for c in input().split()])
	b = {int(c) for c in input().split()}
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


def common_member(a, b):
	a_set = set(a)
	b_set = set(b)
	if a_set & b_set:
		return True
	else:
		return False
t = int(input())
nums = []
for i in range(t):
	n_m = [int(x) for x in input().split()]
	nums.append([])
	nums[-1].append([int(x) for x in input().split()])
	nums[-1].append([int(x) for x in input().split()])
output = []
for num in nums:
	a = num[0]
	b = num[1]
	common = list(set(a).intersection(b))
	if len(common) > 0:
		output.append(['YES', [1, common[0]]])
	else:
		output.append(['NO'])
for out in output:
	if out[0] == 'YES':
		print(out[0])
		print(*out[1])
	else:
		print(out[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a_list = list(map(int, input().split()))
	b_list = list(map(int, input().split()))
	ans = []
	for u in a_list:
		if u in b_list:
			ans.append(u)
			break
	if ans:
		print('YES')
		print(len(ans), *ans)
	else:
		print('NO')


t = int(input())
for z in range(t):
	al = []
	bl = []
	new_list = []
	(x, y) = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	for no in a:
		al.append(no)
	for digits in b:
		bl.append(digits)
	if x > y:
		for i in range(x - y):
			bl.append(0)
	elif y > x:
		for j in range(y - x):
			al.append(0)
	for m in al:
		for n in bl:
			if m == n:
				new_list.append(m)
	new_list.sort()
	if new_list == []:
		print('NO')
	else:
		print('YES')
		print(1, new_list[0])


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().rstrip().split()))
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	number = 0
	if len(a) > len(b):
		for x in b:
			if x in a:
				number = x
				break
	else:
		for x in a:
			if x in b:
				number = x
				break
	if number == 0:
		print('NO')
	else:
		print('YES')
		print(1, number)


import sys

def input():
	return sys.stdin.readline()[:-1]

def getInt():
	return int(input())

def getIntIter():
	return map(int, input().split())

def getIntList():
	return list(getIntIter())
for _ in range(getInt()):
	(n, m) = getIntIter()
	a = getIntList()
	b = getIntList()
	for item in a:
		if item in b:
			print('YES')
			print(1, item)
			break
	else:
		print('NO')


def binary_search(arr, l, r, x):
	if l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return arr[mid]
		elif arr[mid] < x:
			return binary_search(arr, mid + 1, r, x)
		else:
			return binary_search(arr, l, mid - 1, x)
	else:
		return -1
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(flag, k) = (0, 0)
	(a, b) = (sorted([int(x) for x in input().split()]), sorted([int(y) for y in input().split()]))
	for i in a:
		if binary_search(b, 0, len(b) - 1, i) != -1:
			k = i
			flag = 1
			break
		else:
			continue
	if flag == 1:
		print('YES')
		print(1, k)
	else:
		print('NO')


t = int(input())
for i in range(t):
	l = input().split()
	(n, m) = (int(l[0]), int(l[1]))
	nlist = input().split()
	mlist = input().split()
	f = False
	sol = ''
	for ni in nlist:
		if ni in mlist:
			sol = ni
			f = True
			break
	if f:
		print('YES')
		print('1 ', sol)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n1, n2) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	s = set()
	ans = -1
	for i in li1:
		s.add(i)
	for i in li2:
		if i in s:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(i)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	st = set(a) & set(b)
	if len(st):
		print('YES')
		print(1, st.pop())
	else:
		print('NO')


def solve(arr1, arr2, ans):
	for i in arr1:
		if i in arr2:
			ans.append('YES')
			ans.append('1 ' + str(i))
			return
	ans.append('NO')

def main():
	t = int(input())
	ans = []
	for i in range(t):
		(n, m) = map(int, input().split())
		arr1 = set(map(int, input().split()))
		arr2 = set(map(int, input().split()))
		solve(arr1, arr2, ans)
	for i in ans:
		print(i)
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split(' '))
	record = set(map(int, input().split()))
	mArr = list(map(int, input().split()))
	possible = False
	for i in mArr:
		if i in record:
			possible = True
			print(f'\nYES\n1 {i}', end='')
			break
	if not possible:
		print('\nNO', end='')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	if a & b != set():
		print('YES')
		print(1, end=' ')
		for i in a & b:
			print(i)
			break
	else:
		print('NO')


t = int(input())
while t > 0:
	t = t - 1
	(n, m) = map(int, input().split())
	a = input()
	A = list(map(int, list(a.split())))
	b = input()
	B = list(map(int, list(b.split())))
	d = {}
	e = {}
	flag = 0
	for i in A:
		d[i] = 1
	for i in B:
		e[i] = 1
	for i in d:
		if i in e:
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(i)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	c = 0
	for j in range(n):
		for i in range(m):
			if l2[i] == l1[j]:
				c += 1
				if c > 1:
					break
				else:
					print('YES')
					print(1, end=' ')
					print(l2[i])
	if c == 0:
		print('NO')


import sys
(input, print) = (sys.stdin.readline, sys.stdout.write)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(list(map(int, input().split())))
	b = set(list(map(int, input().split())))
	c = list(a.intersection(b))
	if c:
		print('YES' + '\n')
		print(str(1) + ' ' + str(c[0]) + '\n')
	else:
		print('NO' + '\n')


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, m) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d_a = {}
	for i in a:
		d_a[i] = 1
	res = 'NO'
	tt = 0
	for i in b:
		if i in d_a:
			res = 'YES'
			tt = (1, i)
	print(res)
	if res == 'YES':
		print(*tt)


import math
from collections import *
import sys
from functools import reduce
import time
from itertools import groupby

def input():
	return sys.stdin.readline()

def get_ints():
	return map(int, input().strip().split())

def get_list():
	return list(get_ints())

def get_string():
	return list(input().strip().split())

def printxsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')
DIRECTIONS = [(+0, +1), (+0, -1), (+1, +0), (+1, -1)]
NEIGHBOURS = [(-1, -1), (-1, +0), (-1, +1), (+0, -1), (+1, +1), (+1, +0), (+1, -1), (+0, +1)]
CAPS_ALPHABETS = {chr(i + ord('A')): i for i in range(26)}
SMOL_ALPHABETS = {chr(i + ord('a')): i for i in range(26)}
INF = float('inf')
S34t = time.time()
for _testcases_ in range(int(input())):
	(n, m) = get_ints()
	a = set(get_list())
	b = set(get_list())
	ans = -1
	flag = False
	for i in a:
		if i in b:
			ans = i
			flag = True
			break
		if flag:
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)
S34p = time.time()


for testcase in range(int(input())):
	input()
	a = set(input().split())
	b = set(input().split())
	ab = a & b
	if not ab:
		print('NO')
	else:
		print('YES')
		print(1, next(iter(ab)))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	flag = False
	x = 0
	for num in lst1:
		if num in lst2:
			flag = True
			x = num
			break
	if flag == True:
		print('YES')
		print(1, x)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	v = list(a & b)
	if v:
		print('YES')
		print(1, v[0])
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			return
	print('NO')
	return
for _ in range(int(input())):
	solve()


def main():
	(n, m) = map(int, input().split())
	arr_n = list(map(int, input().split()))
	arr_m = list(map(int, input().split()))
	for i in arr_n:
		if i in arr_m:
			print('YES')
			print('1 {}'.format(i))
			return
	print('NO')
for _ in range(int(input())):
	main()


t = int(input())
for i in range(t):
	(n, m) = [int(j) for j in input().split()]
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	a.sort()
	b.sort()
	i = 0
	j = 0
	flag = False
	while i < n and j < m:
		if a[i] < b[j]:
			i += 1
		elif a[i] > b[j]:
			j += 1
		else:
			flag = True
			print('YES')
			print('1', a[i])
			break
	if not flag:
		print('NO')


from sys import *
input = stdin.readline
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in a:
		if i in b:
			c.append(i)
			break
	if len(c) == 1:
		stdout.write('YES\n')
		stdout.write('1 ' + str(c[0]) + '\n')
	else:
		stdout.write('NO\n')


import sys

def solve():
	T = int(input())
	for tests in range(T):
		(n, m) = map(int, input().split())
		cnt = [False] * 1010
		for val in list(map(int, input().split())):
			cnt[val] = True
		ans = -1
		for val in list(map(int, input().split())):
			if cnt[val]:
				ans = val
		if ans == -1:
			print('NO')
		else:
			print('YES')
			print(1, ans)

def main():
	solve()
main()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(v) for v in input().split()]
	b = [int(v) for v in input().split()]
	x = -1
	for v in a:
		for p in b:
			if v == p:
				x = v
				break
	if x == -1:
		print('NO')
	else:
		print('YES')
		print(1, x)


t = int(input())
res = []
for i in range(t):
	(n, m) = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	commonArr = list(set(arr1).intersection(set(arr2)))
	if len(commonArr) == 0:
		res += [['NO']]
	else:
		res += [['YES'], ['1 ' + str(commonArr[0])]]
for i in res:
	for j in i:
		print(j)


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()))
	result = set(a) & set(b)
	if len(result) > 0:
		print('YES')
		print(1, min(result))
	else:
		print('NO')


t = int(input())
for t1 in range(t):
	(n, m) = input().split()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


for i in range(int(input())):
	input()
	a = set(list(map(int, input().split())))
	b = set(list(map(int, input().split())))
	t = 0
	for x in a:
		if x in b:
			t = 1
			print('YES')
			print(1, x)
			break
	if t == 0:
		print('NO')


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dic_a = defaultdict(lambda : 0)
	for i in a:
		dic_a[i] += 1
	tmp = 0
	for i in b:
		if dic_a[i] != 0:
			print('YES')
			print(1, i)
			tmp = 1
			break
	if tmp == 0:
		print('NO')


tC = int(input())
for __ in range(tC):
	(N, M) = map(int, input().split())
	A = set(list(input().split()))
	B = set(list(input().split()))
	C = A.intersection(B)
	print('NO') if not C else print('YES\n1', C.pop())


tc = int(input())
for _ in range(tc):
	input()
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a & b
	try:
		v = c.pop()
		print('YES')
		print(1, v)
	except:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().rstrip().split()))
	arr2 = list(map(int, input().rstrip().split()))
	arr1.sort()
	arr2.sort()
	val = -1
	for i in range(n):
		a = arr1[i]
		for j in range(m):
			b = arr2[j]
			if a == b:
				val = a
				break
			if b > a:
				break
		if val != -1:
			break
	if val == -1:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(val))


def main():
	test = int(input())
	for _ in range(test):
		(n, m) = map(int, input().split())
		arr1 = list(map(int, input().split()))
		arr2 = list(map(int, input().split()))
		l = []
		for i in arr1:
			for j in arr2:
				if i == j:
					l.append(i)
		if len(l) > 0:
			print('YES')
			print(1, l[0])
		else:
			print('NO')
main()


kl = int(input())
for tr in range(kl):
	(m, n) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	A.intersection_update(B)
	if len(A) == 0:
		print('NO')
	else:
		print('YES')
		rz = [1]
		for a in A:
			rz += [a]
			break
		print(*rz)


def case():
	(n, m) = map(int, input().split())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	for i in range(n):
		for j in range(m):
			if A[i] == B[j]:
				print('YES')
				print(1, A[i])
				return
	print('NO')

def sol():
	t = int(input())
	for _ in range(t):
		case()
sol()


def main():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		for i in a:
			if i in b:
				print('Yes')
				print(1, i)
				break
		else:
			print('No')
main()


def commonsubsequence(l1, l2, l3):
	c = list()
	for i in l2:
		if i in l3:
			c.append(i)
			break
	if len(c) == 0:
		print('No ')
	else:
		print('Yes ')
		print(len(c), end=' ')
		for i in c:
			print(i, end=' ')
		print()
t = int(input())
while t > 0:
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = list(map(int, input().split()))
	commonsubsequence(l1, l2, l3)
	t -= 1


for i in range(int(input())):
	(n, m) = [int(n) for n in input().split()]
	a = [int(n) for n in input().split()]
	b = [int(m) for m in input().split()]
	ans = list(set(a) & set(b))
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 0
	l = []
	for (index, i) in enumerate(b):
		for j in range(k, len(a)):
			if a[j] == i:
				l.append(i)
				k = index
				break
	if len(l) != 0:
		print('YES')
		print('1', l[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set()
	for i in a:
		s.add(i)
	f = 0
	ns = 0
	for j in b:
		if j in s:
			f = 1
			ns = j
			break
	if f:
		print('YES')
		print(1, ns)
	else:
		print('NO')


from sys import stdin
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gcl = lambda : list(g())
(t,) = gil()
for _ in range(t):
	(n, m) = gil()
	a = set(gil())
	b = gil()
	flag = True
	for ele in b:
		if ele in a:
			print('YES')
			print(1, ele)
			flag = False
			break
	if flag:
		print('NO')


T = int(input())
while T > 0:
	T -= 1
	input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	done = False
	for x in a:
		if x in b:
			print('YES')
			print('1 ' + str(x))
			done = True
			break
	if done == False:
		print('NO')


t = input()
n = int(t)
while n:
	(x, y) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = [i for i in a if i in b]
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print('1', c[0])
	n = n - 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = [int(x) for x in input().split()]
	ll = [int(x) for x in input().split()]
	a = 0
	for i in range(len(l)):
		if l[i] in ll:
			a = 1
			ans = l[i]
			break
	if a == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
	g = False
	for i in range(n):
		if a[i] in b:
			print('YES')
			print(1, a[i])
			g = True
			break
	if g == False:
		print('NO')


def serch(b, a, n):
	start = 0
	end = n - 1
	while start <= end:
		mid = (end + start) // 2
		if b[mid] == a:
			return mid
		elif b[mid] > a:
			end = mid - 1
		else:
			start = mid + 1
	return 'no'
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = sorted(list(map(int, input().split())))
	i = 0
	while i < n:
		t = serch(b, a[i], m)
		if t != 'no':
			print('YES')
			print('1', a[i])
			break
		i += 1
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	a_dict = {i: 1 for i in a}
	impossible = (True, 0)
	for i in b:
		if i in a_dict:
			impossible = (False, i)
			break
	if impossible[0]:
		print('NO')
	else:
		print('YES')
		print('{} {}'.format(1, impossible[1]))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	N = list(map(int, input().split()))
	M = list(map(int, input().split()))
	aj = 0
	for j in range(n):
		for k in range(m):
			if N[j] == M[k]:
				c = j + 0
				aj = 37
	if aj == 0:
		print('NO')
	else:
		print('YES')
		print(1, N[c])


test_cases = int(input())
final = []
for i in range(test_cases):
	e = [int(x) for x in input().split()]
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	count = 0
	for j in l1:
		if j in l2:
			final.append('YES')
			final.append('1' + ' ' + str(j))
			break
		else:
			count = count + 1
		if count == len(l1):
			final.append('NO')
for i in range(len(final)):
	print(final[i])


for _ in range(int(input())):
	length = list(map(int, input().split()))
	a_length = length[0]
	b_length = length[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	breaking = 0
	ans = -1
	for count_a in range(a_length):
		for count_b in range(b_length):
			if a[count_a] == b[count_b]:
				ans = a[count_a]
				breaking = 1
				break
		if breaking:
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(dlug_a, dlug_b) = map(int, input().split())
	a = set([int(_) for _ in input().split()])
	b = set([int(_) for _ in input().split()])
	wynik = list(a & b)
	if len(wynik) != 0:
		print('YES')
		print(1, wynik[0])
	else:
		print('NO')


def common(a, b):
	c = [value for value in a if value in b]
	return c
T = int(input())
for i in range(T):
	(n, m) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	d = []
	d = common(lst1, lst2)
	if len(d) == 0:
		print('NO')
	else:
		print('YES')
		print(1, d[0], sep=' ')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	arr1_list = list(map(int, input().split()))
	arr2_list = list(map(int, input().split()))
	ans = 'NO'
	arr1_set = set(arr1_list)
	arr2_set = set(arr2_list)
	if arr1_set & arr2_set:
		comm = list(arr1_set & arr2_set)
		ans = 'YES'
		ele = comm[0]
	if ans == 'YES':
		print(ans)
		print(1, ele)
	else:
		print(ans)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().strip().split())
	a = [int(i) for i in input().strip().split()]
	b = [int(i) for i in input().strip().split()]
	ele = -1
	ok = True
	for i in a:
		for j in b:
			if i == j:
				ele = i
				ok = False
				break
		if not ok:
			break
	if ok:
		print('NO')
	else:
		print('YES')
		print(1, ele)


t = int(input())
for x in range(t):
	flag = 0
	size = input().split()
	n = int(size[0])
	m = int(size[1])
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for x in a:
		if x in b:
			flag = 1
			break
	if flag == 1:
		print('YES')
		print(1, x, sep=' ')
	else:
		print('NO')


def input_values():
	return list(map(int, input().split()))
t = int(input())
for _ in range(t):
	(n, m) = input_values()
	array1 = input_values()
	array2 = input_values()
	intersection = list(set(array1) & set(array2))
	if not intersection:
		print('NO')
	else:
		result = intersection[0]
		results = [1, result]
		print('YES')
		print(' '.join(map(str, results)))


import sys
from collections import Counter

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
for _ in range(INT()):
	(N, M) = MAP()
	A = LIST()
	B = LIST()
	C1 = Counter(A)
	C2 = Counter(B)
	for k in C1.keys():
		if C2[k] != 0:
			YES()
			print(1, k)
			break
	else:
		NO()


from sys import stdin

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	(n, m) = minput()
	a = linput()
	b = linput()
	for i in range(n):
		if a[i] in b:
			print('YES')
			print(1, a[i])
			break
	else:
		print('NO')


def solve(l1, l2):
	for j in range(m):
		if l1[j] in l2:
			return (1, l1[j])
			break
	return (0, 0)
t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	(res, val) = solve(l1, l2)
	if res == 1:
		print('YES')
		print(res, val)
	else:
		print('NO')


TC = int(input())
for tc in range(TC):
	(N, M) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	C = A.intersection(B)
	if C:
		print('YES')
		print('1 {}'.format(next(iter(C))))
	else:
		print('NO')


def check(l, m):
	j = 0
	i = 0
	while i < len(l) and j < len(m):
		if l[i] == m[j]:
			return l[i]
		elif l[i] > m[j]:
			j = j + 1
		else:
			i = i + 1
	return -1
t = int(input())
for t1 in range(t):
	(n, m) = [int(x) for x in input().split()]
	l = [int(x) for x in input().split()]
	m = [int(x) for x in input().split()]
	l.sort()
	m.sort()
	a = check(l, m)
	if a == -1:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(a)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	f = 0
	c = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				c = b[j]
				f = 1
				break
	if f:
		print('YES')
		print(f, c)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a = sorted(a)
	b = sorted(b)
	i = 0
	j = 0
	flag = False
	while i < n and j < m:
		if a[i] == b[j]:
			flag = True
			print('YES')
			print(1, b[j])
			break
		elif a[i] < b[j]:
			i = i + 1
		else:
			j = j + 1
	if flag:
		pass
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	for i in arr1:
		flag = True
		for j in arr2:
			if i == j:
				flag = False
				x = j
				break
		if flag == False:
			break
	if flag:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(x)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, m) = int_array()
	a = int_array()
	b = int_array()
	aset = set(a)
	bset = set(b)
	f = 0
	for i in a:
		if f:
			break
		if i in bset:
			f = i
			break
	if not f:
		print('NO')
	else:
		print('YES')
		print(1, f)


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	(n, m) = inputnums()
	a = inputlist()
	b = inputlist()
	mp = [0] * 1001
	for i in range(n):
		mp[a[i]] += 1
	ans = 0
	for i in range(m):
		if mp[b[i]] >= 1:
			ans = b[i]
	if ans > 0:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split(' ')))
	l1 = set(map(int, input().split(' ')))
	l2 = set(map(int, input().split(' ')))
	out = []
	out.extend(l1)
	out.extend(l2)
	out.sort()
	flag = 0
	for k in range(1, len(out)):
		if out[k - 1] == out[k]:
			print('YES')
			print('1', out[k])
			flag = 1
			break
	if flag == 0:
		print('NO')


cases = int(input())
for i in range(cases):
	l1 = input().split(' ')
	n = int(l1[0])
	m = int(l1[1])
	arr1 = []
	l2 = input().split(' ')
	for j in l2:
		arr1.append(int(j))
	arr2 = []
	l3 = input().split(' ')
	for k in l3:
		arr2.append(int(k))
	pos = False
	for ele in arr1:
		if ele in arr2:
			print('YES')
			print(1, ele)
			pos = True
			break
	if not pos:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	c = 0
	f = 0
	for i in range(n):
		if A[i] in B:
			c = A[i]
			f = 1
			break
	if f != 1:
		print('NO')
	else:
		print('YES')
		print(1, c)


t = int(input())
for abc in range(t):
	f = True
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			f = False
			break
	if f:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	c = 0
	ans = 0
	for i in range(len(b)):
		if b[i] in a:
			c = 1
			ans = b[i]
			break
	if c == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	flag = -1
	for i in a:
		if i not in d.keys():
			d[i] = 1
		else:
			d[i] += 1
	for j in b:
		if j in d.keys():
			print('YES')
			print(1, j)
			flag = 0
			break
	if flag == -1:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 0
	for num in a:
		if num in b:
			k = num
			break
	print('NO') if k == 0 else print('YES', '1 {}'.format(k), sep='\n')


def ans(a, b):
	return list(a.intersection(b))
t = int(input())
L = []
for i in range(t):
	(n, m) = map(int, input().split())
	a = set([int(x) for x in input().split()])
	b = set([int(x) for x in input().split()])
	L.append(ans(a, b))
for l in L:
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(1, l[0])


t = int(input())
for _ in range(t):
	(N, M) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	C = []
	for i in B:
		if i in A:
			C.append(i)
			break
	if C == []:
		print('NO')
	else:
		print('YES')
		print(1, C[0])


rw = int(input())
for ewqr in range(rw):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	aset = set(a)
	bset = set(b)
	c = aset & bset
	c = list(c)
	if c == []:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	answ = None
	for elem in a:
		if elem in b:
			answ = elem
			break
	if answ == None:
		print('NO')
	else:
		print('YES')
		print(f'1 {elem}')


t = int(input())
i = 0
while i < t:
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	if n <= m:
		res = []
		for x in range(n):
			if arr1[x] in arr2:
				res.append(arr1[x])
				print('YES')
				print(1, res[0])
				break
		if len(res) == 0:
			print('NO')
	else:
		res = []
		for x in range(m):
			if arr2[x] in arr1:
				res.append(arr2[x])
				print('YES')
				print(1, res[0])
				break
		if len(res) == 0:
			print('NO')
	i = i + 1


def resolver():
	testes = int(input())
	while testes > 0:
		testes -= 1
		ipt = input().split(' ')
		(n, m) = (int(ipt[0]), int(ipt[1]))
		conjunto = set()
		x = [int(e) for e in input().split(' ')]
		for e in x:
			conjunto.add(e)
		resp_bool = False
		resp = 0
		x = [int(e) for e in input().split(' ')]
		for e in x:
			if e in conjunto:
				resp_bool = True
				resp = e
		if resp_bool:
			print('YES')
			print(f'1 {resp}')
		else:
			print('NO')
resolver()


def c(a, b):
	for j in range(0, len(a)):
		x = a[j]
		if a[j] in b:
			return x
			break
	return -1
t = int(input())
for i in range(0, t):
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	x = c(a, b)
	if x != -1:
		print('YES')
		print('1 ' + str(x))
	else:
		print('NO')


def foo():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for e in a:
		if e in b:
			print('YES')
			print(1, end=' ')
			print(e)
			return
	print('NO')
t = int(input())
for _ in range(t):
	foo()


t = int(input())
if 1 <= t <= 1000:
	for i in range(t):
		(n, m) = map(int, input().split())
		if 1 <= n <= 1000 and 1 <= m <= 1000:
			a = list(map(int, input().split()))
			b = list(map(int, input().split()))
			if len(a) == n and len(b) == m:
				for x in a:
					if 1 <= x <= 1000:
						continue
					else:
						exit()
				for x in b:
					if 1 <= x <= 1000:
						continue
					else:
						exit()
				set1 = set(a)
				set2 = set(b)
				com = set1.intersection(set2)
				com = list(com)
				if len(com) != 0:
					print('YES')
					print('1', com[0])
				else:
					print('NO')
			else:
				exit()
		else:
			exit()
else:
	exit()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	k = list(map(int, input().split()))
	a = set(p)
	b = set(k)
	z = a.intersection(b)
	s = list(z)
	if len(z) != 0:
		print('YES')
		print('1', s[0])
	else:
		print('NO')


import bisect
import decimal
from decimal import Decimal
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate
decimal.getcontext().prec = 46

def primeFactors(n):
	prime = set()
	while n % 2 == 0:
		prime.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			prime.add(i)
			n = n // i
	if n > 2:
		prime.add(n)
	return list(prime)

def getFactors(n):
	factors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				factors.append(i)
			else:
				factors.append(i)
				factors.append(n // i)
		i = i + 1
	return factors

def modefiedSieve():
	mx = 10 ** 7 + 1
	sieve = [-1] * mx
	for i in range(2, mx):
		if sieve[i] == -1:
			sieve[i] = i
			for j in range(i * i, mx, i):
				if sieve[j] == -1:
					sieve[j] = i
	return sieve

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	num = []
	for p in range(2, n + 1):
		if prime[p]:
			num.append(p)
	return num

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def DFS(n, s, adj):
	visited = [False for i in range(n + 1)]
	stack = []
	stack.append(s)
	while len(stack):
		s = stack[-1]
		stack.pop()
		if not visited[s]:
			visited[s] = True
		for node in adj[s]:
			if not visited[node]:
				stack.append(node)

def maxSubArraySum(a, size):
	maxint = 10 ** 10
	max_so_far = -maxint - 1
	max_ending_here = 0
	for i in range(0, size):
		max_ending_here = max_ending_here + a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
		if max_ending_here < 0:
			max_ending_here = 0
	return max_so_far

def solve():
	(n, m) = num_input()
	a = list_input()
	B = list_input()
	b = {}
	for i in B:
		b[i] = 1
	for i in a:
		try:
			b[i]
			print('YES')
			print(1, i)
			return
		except KeyError:
			pass
	print('NO')
t = 1
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	a = set(A)
	b = set(B)
	z = a.intersection(b)
	if len(z) >= 1:
		print('YES')
		print(1, z.pop())
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	state = 0
	for el in a:
		if el in b:
			print('YES')
			print(1, el)
			state = 1
		if state == 1:
			break
	if state == 0:
		print('NO')


def func(A, B):
	for i in A:
		for j in B:
			if i == j:
				res = i
				print('Yes')
				return (1, i)
	return -1
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	res = func(A, B)
	if res == -1:
		print('No')
	else:
		print(res[0], res[1])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	k = 1
	for i in a:
		d[i] = 1
	for i in b:
		if i in d:
			k = 0
			p = i
			break
	if k == 0:
		print('YES')
		print(1, p)
	else:
		print('NO')


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	an = list(map(int, stdin.readline().split()))
	am = list(map(int, stdin.readline().split()))
	found = False
	for i in an:
		for j in am:
			if i == j:
				print(f'YES\n1 {i}')
				found = True
				break
		if found:
			break
	if found:
		continue
	print('NO')


numberoftests = int(input())
for _ in range(numberoftests):
	whocares = input()
	a = input().split()
	b = input().split()
	combined = [x for x in a if x in b]
	if len(combined) == 0:
		print('NO')
	else:
		print('YES')
		print('1', combined[0])


t = int(input())
while t > 0:
	(x, y) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	m = []
	for i in range(len(A)):
		for j in range(len(B)):
			if A[i] == B[j]:
				m.append(A[i])
				break
	if len(m) > 0:
		print('YES')
		print(1, m[0])
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	b = 0
	for a in arr1:
		if a in arr2:
			print('YES')
			print('1 ' + str(a))
			b = 1
			break
	if b == 0:
		print('NO')


for _ in range(int(input())):
	(m, n) = map(int, input().strip().split(' '))
	d = {}
	l = list(map(int, input().strip().split(' ')))
	ll = list(map(int, input().strip().split(' ')))
	for i in l:
		if i not in d:
			d[i] = 1
	flag = -1
	val = 0
	for i in ll:
		if i in d:
			flag = 1
			val = i
			break
	if flag == -1:
		print('NO')
	else:
		print('YES')
		print(1, i)


t = int(input())
for t1 in range(0, t):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	f = 0
	ans = []
	for i in b:
		if i in d:
			ans.append(i)
			f = 1
			break
	if f == 1:
		print('YES')
		print(1, *ans)
	else:
		print('NO')


for tc in range(int(input())):
	(a, b) = input().split(' ')
	A = set(input().split(' '))
	B = set(input().split(' '))
	C = A - (A - B)
	if len(C) == 0:
		print('NO')
	else:
		print('YES')
		print(1, C.pop())


from sys import *
t = int(stdin.readline())
while t > 0:
	(n, m) = map(int, stdin.readline().split())
	arr = list(map(int, stdin.readline().split()))
	brr = list(map(int, stdin.readline().split()))
	s = set()
	flag = 0
	for i in range(n):
		if arr[i] not in s:
			s.add(arr[i])
	for j in range(m):
		if brr[j] in s:
			flag = 1
			print('YES')
			print(1, brr[j])
			break
	if flag == 0:
		print('NO')
	t -= 1


t = int(input())
for tests in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	member = []
	for x in a.intersection(b):
		member = x
		break
	if member != []:
		print('YES')
		print('1 {}'.format(x))
	else:
		print('NO')


def intersection(lst1, lst2):
	return list(set(lst1) & set(lst2))
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = intersection(a, b)
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	d = {}
	for i in range(n):
		d[a1[i]] = 1
	p = 0
	ind = -1
	for i in range(m):
		if a2[i] in d.keys():
			p = 1
			ind = a2[i]
			break
	if p == 0:
		print('NO')
	else:
		print('YES')
		print(1, ind)
	t = t - 1


t = int(input())
for _ in range(t):
	(n, x) = input().split()
	(a, b) = (list(map(int, input().split())), list(map(int, input().split())))
	try:
		check = [i for i in a if i in b]
		print('YES\n' + '1', check[0])
	except:
		print('NO')


for h in range(int(input())):
	(n, m) = map(int, input().strip().split())
	arr1 = set(list(map(int, input().strip().split())))
	arr2 = list(map(int, input().strip().split()))
	for i in arr2:
		if i in arr1:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())
for tes in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	h = [0] * 1001
	res = []
	f = 0
	for i in range(n):
		h[arr1[i]] += 1
	for i in range(m):
		if h[arr2[i]] != 0:
			print('YES')
			print(1, arr2[i])
			f = 1
			break
	if f == 0:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	check = 0
	for i in range(n):
		if a[i] in b:
			print('YES')
			print(str(1), str(a[i]))
			check = 1
			break
	if check == 0:
		print('NO')


rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')
(YES, NO) = ('YES', 'NO')

def solve(N, M, A, B):
	C = set(A) & set(B)
	if len(C) > 0:
		print(YES)
		first = -1
		for v in C:
			first = v
			break
		print(1, first)
	else:
		print(NO)
t = rri()
for _ in range(t):
	(N, M) = rrm()
	A = rrm()
	B = rrm()
	solve(N, M, A, B)


for _ in range(int(input())):
	(size1, size2) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	block = True
	if a < b:
		for i in a:
			if i in b:
				print('YES')
				print(1, i)
				block = False
				break
	else:
		for i in b:
			if i in a:
				print('YES')
				print(1, i)
				block = False
				break
	if block:
		print('NO')


for _ in range(0, int(input())):
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	hashmap1 = [0 for a in range(0, 1005)]
	hashmap2 = [0 for a in range(0, 1005)]
	flag5 = 0
	for i in a:
		hashmap1[i] += 1
	for i in b:
		hashmap2[i] += 1
	for i in range(0, len(hashmap2)):
		if hashmap1[i] > 0 and hashmap2[i] > 0:
			print('YES')
			print(1, i)
			flag5 = 1
			break
	if flag5 == 0:
		print('NO')


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2
from bisect import bisect_right, bisect_left
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def factors(n):
	return list(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))
MOD = 1000000007
PMOD = 998244353
T = 1
T = int(stdin.readline())
for _ in range(T):
	(n, m) = list(map(int, stdin.readline().rstrip().split()))
	a = list(map(int, stdin.readline().rstrip().split()))
	b = list(map(int, stdin.readline().rstrip().split()))
	ans = -1
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ans = a[i]
				break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


T = int(input())
for _ in range(T):
	(n, m) = tuple(map(int, input().split()))
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	ok = False
	for i in range(len(x)):
		if x[i] in y:
			print('YES')
			print('1 {}'.format(x[i]))
			ok = True
			break
	if ok:
		continue
	else:
		print('NO')


for t in range(int(input())):
	(n1, n2) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	flag = a = 0
	for i in l1:
		for j in l2:
			if i == j:
				flag = 1
				a = i
				break
	if flag == 1:
		print('YES')
		print(1, a)
	else:
		print('NO')


def main(r):
	(n, k) = map(int, input().split())
	a = set(list(map(int, input().split())))
	b = list(map(int, input().split()))
	for i in b:
		if i in a:
			print('YES')
			print(1, i)
			return
	print('NO')
t = int(input())
for i in range(t):
	main(i)


def binarySearch(arr, l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binarySearch(arr, l, mid - 1, x)
		else:
			return binarySearch(arr, mid + 1, r, x)
	else:
		return -1
t = int(input())
for x in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	B.sort()
	for y in A:
		if binarySearch(B, 0, m - 1, y) != -1:
			print('YES')
			print('1', y)
			break
	else:
		print('NO')


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	lst = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	f = 0
	lst1.sort()
	lst.sort()
	lst1 = set(lst1)
	lst = set(lst)
	for i in lst:
		if i in lst1:
			print('YES')
			print('1 ' + str(i))
			f = 1
			break
	if f == 0:
		print('NO')


def check(arr1, arr2, count=0):
	ls = []
	for i in range(len(arr1)):
		if arr1[i] in arr2:
			count += 1
			ls.append(arr1[i])
	if count > 0:
		ls.append(count)
	return ls
test = int(input())
for _ in range(test):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	count = 0
	lis = []
	if check(arr1, arr2, count) != lis:
		print('YES')
		lis += check(arr1, arr2, count)
		lis = lis[::-1]
		if lis[0] > 1:
			lis[0] = 1
			lis[1] = lis[-2]
			del lis[2:]
		for i in range(len(lis)):
			print(lis[i], end=' ')
		print()
	else:
		print('NO')


import sys

def common_sub(a1, a2):
	found = False
	for c in a1:
		if c in a2 and (not found):
			print('YES')
			print('1 ' + c)
			found = True
			continue
	if not found:
		print('NO')
num_tests = int(next(sys.stdin).strip())
for x in range(num_tests):
	next(sys.stdin)
	a1 = next(sys.stdin).strip().split(' ')
	a2 = next(sys.stdin).strip().split(' ')
	common_sub(a1, a2)


t = int(input())
for i2 in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	mass = [0 for i in range(1001)]
	for i in range(n):
		mass[l1[i]] += 1
	o = 0
	for i in range(m):
		if mass[l2[i]] > 0:
			print('YES')
			print(1, l2[i])
			o = 1
			break
	if o == 0:
		print('NO')


for t in range(int(input())):
	input()
	s = set(input().split()) & set(input().split())
	print(f'YES\n1 {next(iter(s))}' if s else 'NO')


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = Counter(a)
	d = Counter(b)
	flag = 1
	for i in range(1, 1001):
		if c[i] > 0 and d[i] > 0:
			print('YES')
			print(1, i)
			flag = 0
			break
	if flag:
		print('NO')


for _ in range(int(input())):
	l = list(map(int, input().split()))
	n = l[0]
	m = l[1]
	a1 = list(map(int, input().split()))
	a2 = list(map(int, input().split()))
	flag = False
	if n > m or n == m:
		for i in range(n):
			j = 0
			while j < m:
				if a2[j] == a1[i]:
					print('YES')
					print('1 {}'.format(a2[j]))
					flag = True
					break
				j = j + 1
			if flag == True:
				break
	else:
		for i in range(m):
			j = 0
			while j < n:
				if a2[i] == a1[j]:
					print('YES')
					print('1 {}'.format(a1[j]))
					flag = True
					break
				j = j + 1
			if flag == True:
				break
	if flag == False:
		print('NO')


t = int(input())
while t != 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:m]
	x = set(a)
	y = set(b)
	z = x.intersection(y)
	k = list(z)
	if len(z) == 0:
		print('NO')
	else:
		print('YES')
		print(1, k[0])
	t -= 1


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	for i in l:
		if i in l1:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(w) for w in input().split()]
	l1 = [int(q) for q in input().split()]
	l2 = [int(r) for r in input().split()]
	l3 = [val for val in l1 if val in l2]
	l3.sort()
	if len(l3) > 0:
		print('YES')
		print(1, l3[0])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	C = A.intersection(B)
	if len(C) == 0:
		print('NO')
		continue
	print('YES')
	print(1, C.pop())


from pprint import pprint
import sys
q = int(input())
for _ in range(q):
	(n, m) = map(int, input().split())
	data = list(map(int, input().split()))
	datb = list(map(int, input().split()))
	d = dict()
	for i in range(n):
		d[data[i]] = True
	can = False
	for i in range(m):
		if datb[i] in d:
			print('YES')
			print(1, datb[i])
			can = True
			break
	if can is False:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	ans = -1
	for i in range(n):
		for j in range(m):
			if brr[j] == arr[i]:
				ans = arr[i]
				break
		if ans != -1:
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	dict1 = {}
	dict2 = {}
	for i in range(len(ar)):
		if ar[i] in dict1:
			dict1[ar[i]] += 1
		else:
			dict1[ar[i]] = 1
	for i in range(len(br)):
		if br[i] in dict2:
			dict2[br[i]] += 1
		else:
			dict2[br[i]] = 1
	flag = False
	for i in dict1:
		if i in dict2:
			flag = True
			val = i
			break
	if flag == True:
		print('YES')
		print('1 {}'.format(val))
	else:
		print('NO')


for _ in range(int(input())):
	z = 0
	[x, y] = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for i in range(len(l1)):
		if l1[i] in l2:
			z = 1
			print('YES')
			print(1, l1[i])
			break
	if z == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	f = 0
	for i in range(n):
		for j in range(m):
			if l[i] == a[j]:
				f = 1
				break
		if f == 1:
			break
	if f == 1:
		print('YES')
		print(1, a[j])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	iSub = False
	for ch in a:
		if ch in b:
			print('YES')
			print(1, ch)
			iSub = True
			break
	if not iSub:
		print('NO')


import sys
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ans = 'NO'
	for i in a:
		for j in b:
			if i == j:
				ans = 'YES'
				pivot = i
				break
	print(ans)
	if ans == 'YES':
		print(1, pivot)


for test in range(0, int(input())):
	(x, y) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	key = 0
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			key = 1
			break
	if key == 0:
		print('NO')


t = int(input())
a = []
b = []
for _ in range(t):
	len_a_b = input()
	a.append([int(x) for x in input().split()])
	b.append([int(x) for x in input().split()])
for i in range(t):
	a_set = set(a[i])
	b_set = set(b[i])
	c_set = a_set.intersection(b_set)
	if len(c_set):
		print('YES')
		print(1, end=' ')
		print(c_set.pop())
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().rstrip().split()))
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	da = {}
	for i in range(n):
		if a[i] not in da.keys():
			da[a[i]] = True
	c = []
	for i in range(m):
		if b[i] in da.keys():
			c.append(b[i])
			break
	if len(c) != 0:
		print('YES')
		print(1, c[0])
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = set([int(i) for i in input().split()])
	r = ''
	for i in range(n):
		if a[i] in b:
			r = a[i]
			break
	if r != '':
		print('YES')
		print(1, r)
	else:
		print('NO')


from sys import stdin, stdout
import math
input = stdin.readline

def print(x='', y='', end='\n'):
	if y == '':
		stdout.write(str(x) + end)
	else:
		stdout.write(str(x) + ' ' + str(y) + end)

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s1 = set(a)
	s2 = set(b)
	t = s1.intersection(s2)
	if t:
		print('YES')
		t = list(t)
		print(1, t[0])
	else:
		print('NO')
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


for t in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	maxi = max(l1, l2, key=len)
	if maxi == l2:
		mini = l1
	else:
		mini = l2
	for i in maxi:
		if i in mini:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())

def case():
	[n, m] = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in a:
		for j in b:
			if i == j:
				return i
	return 0
for test_case in range(t):
	x = case()
	if x:
		print('YES')
		print('1 ' + str(x))
	else:
		print('NO')


for test in range(int(input())):
	n = input()
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	a1 = {}
	a2 = {}
	for i in arr1:
		a1[i] = 1
	for i in arr2:
		a2[i] = 1
	counter = 0
	for i in sorted(a1):
		if i in a2:
			print('YES')
			print(1, i)
			counter = 1
			break
	if counter == 0:
		print('NO')


N = int(input())
for i in range(N):
	input()
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	res = list(filter(lambda x: x in a, b))
	if len(res) > 0:
		print('YES\n1', res[0])
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	c = 0
	d = 'No'
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	for j in range(0, len(l)):
		for k in range(0, len(l1)):
			if l[j] == l1[k]:
				p = l[j]
				c = 1
				d = 'Yes'
	if d == 'Yes':
		print(d)
		print(str(c) + ' ' + str(p))
	else:
		print('No')


from sys import stdin, stdout
import bisect
import math

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def li():
	return list(map(int, stdin.readline().split()))

def mp():
	return map(int, stdin.readline().split())

def pr(n):
	stdout.write(str(n) + '\n')

def soe(limit):
	l = [1] * (limit + 1)
	prime = []
	for i in range(2, limit + 1):
		if l[i]:
			for j in range(i * i, limit + 1, i):
				l[j] = 0
	for i in range(2, limit + 1):
		if l[i]:
			prime.append(i)
	return prime

def segsoe(low, high):
	limit = int(high ** 0.5) + 1
	prime = soe(limit)
	n = high - low + 1
	l = [0] * (n + 1)
	for i in range(len(prime)):
		lowlimit = low // prime[i] * prime[i]
		if lowlimit < low:
			lowlimit += prime[i]
		if lowlimit == prime[i]:
			lowlimit += prime[i]
		for j in range(lowlimit, high + 1, prime[i]):
			l[j - low] = 1
	for i in range(low, high + 1):
		if not l[i - low]:
			if i != 1:
				print(i)

def power(a, n):
	r = 1
	while n:
		if n & 1:
			r = r * a
		a *= a
		n = n >> 1
	return r

def solve():
	(n, m) = mp()
	l = set(map(int, input().split()))
	k = set(map(int, input().split()))
	a = l.intersection(k)
	if len(a) == 0:
		print('NO')
	else:
		print('YES')
		a = list(a)
		print(1, end=' ')
		print(a[0])
for _ in range(inp()):
	solve()


for _ in range(int(input())):
	X = list(map(int, input().split()))
	(First, Second) = (set(list(map(int, input().split()))), set(list(map(int, input().split()))))
	Common = First.intersection(Second)
	if len(Common) != 0:
		print('YES')
		print('1', list(Common)[0])
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ha = {}
	f = 0
	for i in range(n):
		ha[a[i]] = 1
	for i in range(m):
		if b[i] in ha:
			f = 1
			print('YES')
			print(1, end=' ')
			print(b[i])
			break
	if f == 0:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a1 = [int(i) for i in input().split()]
	a2 = [int(i) for i in input().split()]
	a = None
	if n < m:
		for i in a1:
			if i in a2:
				a = i
				break
	else:
		for i in a2:
			if i in a1:
				a = i
				break
	if a == None:
		print('NO')
	else:
		print('YES')
		print(1, a)


import sys
input = sys.stdin.readline
t = int(input())
for t1 in range(t):
	(n, m) = list(map(int, input().split(' ')))
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	d = {}
	for i in a:
		d[i] = 1
	ans = []
	for i in b:
		if d.get(i, 0) == 1:
			ans.append(i)
			break
	if len(ans) > 0:
		print('YES')
		print(1, ans[0])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	X = A.intersection(B)
	if len(X) == 0:
		print('NO')
	else:
		print('YES')
		z = X.pop()
		print(f'1 {z}')


t = int(input(''))
for i in range(t):
	(a, b) = list(map(int, input('').split(' ')))
	list1 = list(map(int, input('').split(' ')))
	list2 = list(map(int, input('').split(' ')))
	list3 = []
	for i in list1:
		if i in list2:
			list3.append(str(i))
	if len(list3) > 0:
		print('YES')
		print('1 ' + list3[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	val = -1
	for i in ar:
		for j in br:
			if i == j:
				val = i
				break
	if val == -1:
		print('NO')
	else:
		print('YES')
		print(1, val)


t = int(input())
while t:
	(n1, n2) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	c = 0
	if len(l1) >= len(l2):
		for i in range(len(l1)):
			for j in range(len(l2)):
				if l1[i] == l2[j]:
					c += 1
					ans = l1[i]
					break
	else:
		for i in range(len(l2)):
			for j in range(len(l1)):
				if l2[i] == l1[j]:
					c += 1
					ans = l2[i]
					break
	if c == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)
	t = t - 1


def solution(arr1, arr2):
	res = 'No'
	for e1 in arr1:
		if res != 'No':
			break
		for e2 in arr2:
			if e1 == e2:
				res = 'Yes\n1 ' + str(e1)
				break
	return res

def main():
	for test in range(int(input())):
		(_, _) = map(int, input().split())
		arr1 = list(map(int, input().split()))
		arr2 = list(map(int, input().split()))
		result = solution(arr1, arr2)
		print(result)
main()


t = int(input())
for x in range(t):
	l1 = [int(x) for x in input().split()]
	(n, m) = (l1[0], l1[1])
	l2 = set([int(x) for x in input().split()])
	l3 = set([int(x) for x in input().split()])
	done = 0
	for x in l2:
		if x in l3:
			done = 1
			print('YES')
			print(1, x)
			break
	if not done:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = input().split()
	b = input().split()
	a = set(a)
	b = set(b)
	f = 1
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			f = 0
			break
	if f == 1:
		print('NO')


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
import operator as op
from functools import reduce
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def myCode():
	d = defaultdict(int)
	(n, m) = In()
	l1 = L()
	l2 = L()
	lst = [0] * 1001
	flag = False
	for i in l1:
		lst[i] += 1
	for i in l2:
		if lst[i] > 0:
			print('YES')
			print(1, i)
			flag = True
			break
	if flag == False:
		print('NO')

def main():
	for t in range(I()):
		myCode()
main()


import sys
input = sys.stdin.buffer.readline

def prog():
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = set(map(int, input().split()))
		b = list(map(int, input().split()))
		found = False
		for c in b:
			if c in a:
				print('YES')
				print(1, c)
				found = True
				break
		if not found:
			print('NO')
prog()


for _ in range(int(input())):
	(num, mum) = map(int, input().split())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	flg = 0
	for i in range(num):
		if lis1[i] in lis2:
			print('YES')
			print('1 {0}'.format(lis1[i]))
			flg = 1
			break
	if flg == 0:
		print('NO')


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	(n, m) = IP()
	a = L()
	b = L()
	for ele in a:
		if ele in b:
			print('YES')
			print(1, ele)
			return
	else:
		print('NO')
t = II()
for i in range(t):
	solve()


def common_elements(a, b, n, m):
	(D, E, common) = ([], [], [])
	(i, j, lc, ld) = (0, 0, 0, 0)
	while i < n and j < m:
		if a[i] == b[j]:
			common.append(a[i])
			lc += 1
			break
			i += 1
			j += 1
		elif a[i] < b[j]:
			D.append(a[i])
			ld += 1
			i += 1
		else:
			E.append(b[j])
			j += 1
	return (D, E, common, ld, lc)
g = int(input())
for _ in range(g):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split(' ')))
	b = list(map(int, input().split(' ')))
	a.sort()
	b.sort()
	(D, E, common, ld, lc) = common_elements(a, b, n, m)
	if lc == 1:
		print('YES')
		print('1', common[0])
	else:
		print('NO')


i = int
I = input
p = print
s = set
m = map
l = list
exec(i(I()) * "I();a=s(m(i,I().split()));b=s(m(i,I().split()))&a;p(f'''YES\n1 {l(b)[0]}''' if len(b) else 'NO');")


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	lst1 = list(map(int, input().strip().split()))
	lst2 = list(map(int, input().strip().split()))
	f = False
	for i in lst2:
		if i in lst1:
			print('YES')
			print(1, i)
			f = True
			break
		else:
			continue
	if f == False:
		print('NO')


for _ in range(int(input())):
	input().split()
	n = input().split()
	m = input().split()
	c = ''
	p = 0
	if len(n) < len(m):
		for i in range(len(n)):
			if n[i] in m:
				c = c + n[i] + ' '
				p = p + 1
				break
	else:
		for i in range(len(m)):
			if m[i] in n:
				c = c + m[i] + ' '
				p = p + 1
				break
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(p, ' ', c, sep='')


testcases = int(input())
for i in range(testcases):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(freq_dict_a, freq_dict_b) = ({}, {})
	for ele in a:
		if ele not in freq_dict_a:
			freq_dict_a[ele] = 1
	for ele in b:
		if ele not in freq_dict_b:
			freq_dict_b[ele] = 1
	got_it = False
	for key in freq_dict_a.keys():
		if key in freq_dict_b:
			print('YES')
			print(1, key)
			got_it = True
			break
	if not got_it:
		print('NO')


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	b = set(b)
	f = 0
	for i in a:
		if i in b:
			f = 1
			pos = i
			break
	if f:
		print('YES')
		print(1, pos)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = (int(x) for x in input().split())
	a = list((int(x) for x in input().split()))
	b = list((int(x) for x in input().split()))
	a_set = set(a)
	intersection = list(a_set.intersection(b))
	if intersection != []:
		print('YES\n1 %s' % intersection[0])
	else:
		print('NO')


try:
	for t in range(int(input())):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		k = 0
		for i in range(0, m):
			if b[i] in a:
				g = b[i]
				k = 1
				break
		if k == 0:
			print('NO')
		else:
			print('YES')
			print(k, ' ', g)
except EOFError as e:
	pass


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	d = dict()
	for i in arr:
		d[i] = 1
	ans = -1
	for i in brr:
		if i in d:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


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


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	g = list(map(int, input().split()))
	l = set(l)
	g = set(g)
	ans = l.intersection(g)
	if len(ans) == 0:
		print('NO')
	else:
		actualans = ans.pop()
		print('YES')
		print('1', actualans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	set_n = set(map(int, input().split()))
	set_m = set(map(int, input().split()))
	intersection = set_n & set_m
	if intersection != set():
		print('YES')
		for j in intersection:
			answer = j
			break
		print(1, answer)
	else:
		print('NO')


from collections import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	(x, y) = (Counter(l), Counter(l1))
	f = 1
	for (i, j) in x.items():
		if i in y:
			print('YES')
			print(1, i)
			f = 0
			break
	if f == 1:
		print('NO')


test = int(input())
while test > 0:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = n if n < m else m
	flag = False
	if l == n:
		for i in range(n):
			if a[i] in b:
				flag = True
				print('YES')
				print('1', a[i])
				break
		if flag == False:
			print('NO')
	else:
		for i in range(m):
			if b[i] in a:
				flag = True
				print('YES')
				print('1', b[i])
				break
		if flag == False:
			print('NO')
	test -= 1


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().strip().split()))
	A = list(map(int, input().strip().split()))
	B = list(map(int, input().strip().split()))
	k = 0
	for i in range(n):
		for j in range(m):
			if A[i] == B[j]:
				print('YES')
				print(1, A[i])
				k = 1
				break
		if k == 1:
			break
	if k == 0:
		print('NO')


c = int(input())
while c:
	c -= 1
	(n, m) = input().split()
	set1 = set(map(int, input().split()))
	set2 = set(map(int, input().split()))
	x = set1.intersection(set2)
	if x == set():
		print('NO')
	else:
		print('YES')
		print(1, list(x)[0])


import math, sys, bisect, heapq
from collections import defaultdict, Counter, deque
from itertools import groupby, accumulate
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def Y(c):
	print(['NO', 'YES'][c])

def y(c):
	print(['no', 'yes'][c])

def Yy(c):
	print(['No', 'Yes'][c])
for _ in range(int(input())):
	(a, b) = ilele()
	A = alele()
	B = alele()
	f = 0
	for i in A:
		if i in B:
			Y(1)
			print(1, i)
			f = 1
			break
	if f == 0:
		Y(0)


import sys
input = sys.stdin.readline
t = int(input())
for tt in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d = {}
	for i in l1:
		d[i] = 0
	for i in l2:
		try:
			d[i] += 1
		except:
			pass
	ans = -1
	for i in d:
		if d[i] > 0:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_set = set(a)
	b_set = set(b)
	if a_set & b_set:
		l = a_set & b_set
		k1 = list(l)
		print('YES')
		print(1, k1[0])
	else:
		print('NO')


import sys

def readlines(type=int):
	return list(map(type, sys.stdin.readline().split()))

def read(type=int):
	return type(sys.stdin.readline().strip())
joint = lambda it, sep=' ': sep.join([str(i) if type(i) != list else sep.join(map(str, i)) for i in it])

def solve(a, b):
	a_set = set(a)
	b_set = set(b)
	intersc = list(a_set.intersection(b_set))
	if len(intersc) > 0:
		return 'YES\n1 {}'.format(intersc[0])
	return 'NO'

def main():
	n = read()
	for _ in range(n):
		readlines()
		a = readlines()
		b = readlines()
		print(solve(a, b))
main()


t = int(input())
for it in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = True
	for i in range(n):
		if a[i] in b:
			k = False
			print('YES')
			print(1, a[i])
			break
	if k:
		print('NO')


from collections import deque
from math import *
import heapq
t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	d = {}
	for j in range(len(l1)):
		d[l1[j]] = 1
	beta = False
	for j in range(len(l2)):
		if l2[j] in d:
			print('YES')
			print(1, l2[j])
			beta = True
			break
	if beta == False:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split() if i != '\n']
	b = [int(i) for i in input().split() if i != '\n']
	store = [0] * (max(b) + 1)
	for i in b:
		store[i] = 1
	for i in a:
		try:
			if store[i] == 1:
				print('YES')
				print(1, i)
				break
		except:
			pass
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(x) for x in input().strip().split()]
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:m]
	tyler = -1
	for i in range(n):
		if b.count(a[i]) > 0:
			tyler = a[i]
			break
	if tyler == -1:
		print('NO')
	else:
		print('YES')
		print(1, tyler)


for tt in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a1 = list(set(a))
	b1 = list(set(b))
	s = list(set(a + b))
	d = {}
	for i in s:
		d[i] = 0
	for i in a1:
		d[i] += 1
	for i in b1:
		d[i] += 1
	ans = -1
	for i in d:
		if d[i] > 1:
			ans = i
			break
	if ans != -1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(eval(input())):
	extra = input()
	list1 = input().split()
	list2 = input().split()
	found = False
	for e in list1:
		if e in list2:
			print('YES')
			print('1', e)
			found = True
			break
	if found == False:
		print('NO')


for test in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = True
	for i in a:
		if i in b:
			ok = False
			print('YES')
			print(1, i)
			break
	if ok:
		print('NO')


t = 1
t = int(input())
while t:
	t -= 1
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_map = {}
	for el in a:
		a_map[el] = True
	for el in b:
		if el in a_map:
			print('YES')
			print(1, el)
			break
	else:
		print('NO')


num = int(input())
arr3 = []
while num != 0:
	(m, n) = map(int, input().split())
	arr1 = set([int(x) for x in input().split()])
	arr2 = set([int(x) for x in input().split()])
	c = arr1.intersection(arr2)
	if c:
		print('YES')
		print('1 ' + str(list(c)[0]))
	else:
		print('NO')
	num = num - 1


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	aset = set(a)
	bset = set(b)
	ans = []
	if aset & bset:
		print('YES')
		print(1, list(aset & bset)[0])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	c = set(c)
	d = set(d)
	c = c.intersection(d)
	if len(c) >= 1:
		print('Yes')
		c = list(c)
		print(1, end=' ')
		print(c[0])
	else:
		print('No')


import math
num_cases = int(input())
for _ in range(num_cases):
	(n, m) = list(map(int, input().strip().split()))
	arr1 = list(map(int, input().strip().split()))
	arr2 = list(map(int, input().strip().split()))
	lis = [0 for _ in range(1001)]
	for elem in arr1:
		lis[elem] = 1
	done = 0
	for elem in arr2:
		if lis[elem] == 1:
			print('YES')
			print('%d %d' % (1, elem))
			done = 1
			break
	if done == 0:
		print('NO')


t = int(input())
for _ in range(t):
	u = input()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	ans = False
	for i in b:
		if i in a:
			print('YES')
			print(f'1 {i}')
			ans = True
			break
	if ans == False:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	m = set(map(str, input().split()))
	n = set(map(str, input().split()))
	inter = m.intersection(n)
	if len(inter) == 0:
		print('NO')
	else:
		print('YES')
		print(1, inter.pop())


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().rstrip().split(' ')))
	a = set(map(int, input().rstrip().split(' ')))
	b = set(map(int, input().rstrip().split(' ')))
	c = a.intersection(b)
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c.pop())


t = int(input())
for i in range(t):
	sizes = input().split()
	a = input().split()
	for k in range(int(sizes[0])):
		a[k] = int(a[k])
	b = input().split()
	for k in range(int(sizes[1])):
		b[k] = int(b[k])
	found = False
	k = 0
	while k < len(a) and (not found):
		if a[k] in b:
			print('YES')
			print(1, a[k])
			found = True
		k += 1
	if not found:
		print('NO')


import sys
from math import floor as fl
from math import ceil as ce
from math import sqrt
cont = sys.stdin.readlines()
cont = [i.strip('\n').split() for i in cont]
num = int(cont.pop(0)[0])
for i in range(num):
	arrs = cont[:3]
	cont = cont[3:]
	(l1, l2) = [int(j) for j in arrs.pop(0)]
	arrs[0] = [int(j) for j in arrs[0]]
	arrs[1] = [int(j) for j in arrs[1]]
	ret = list(set(arrs[0]) & set(arrs[1]))
	if ret == []:
		print('NO')
	else:
		print(f'YES\n1 {ret[0]}')


from sys import stdin, stdout
import math
from collections import Counter, defaultdict
LI = lambda : list(map(int, input().split()))
MAP = lambda : map(int, input().split())
IN = lambda : int(input())
S = lambda : input()

def case():
	(n, m) = MAP()
	ans = 'NO'
	a = LI()
	b = LI()
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			return
	print(ans)
for _ in range(IN()):
	case()


def f(l1, l2):
	for i in l1:
		if i in l2:
			return i
	return 'NO'
a = int(input())
for i in range(a):
	(y, z) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	k = f(l1, l2)
	if k == 'NO':
		print('NO')
	else:
		print('YES')
		print(1, k)


T = int(input())

def solve(arr1, arr2):
	for el in arr1:
		if arr2.count(el) >= 1:
			print('YES')
			print('1 {}'.format(el))
			return
	print('NO')
while T > 0:
	(n, m) = [int(el) for el in input().split(' ')]
	arr1 = [int(el) for el in input().split(' ')]
	arr2 = [int(el) for el in input().split(' ')]
	solve(arr1, arr2)
	T -= 1


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flg = 1
	p = -1
	for i in a:
		if i in b:
			flg = 0
			p = i
			break
	if flg:
		print('NO')
	else:
		print('YES')
		print(1, p)


def solve():
	(n, m) = [int(v) for v in input().split()]
	arr = {int(v) for v in input().split()}
	brr = {int(v) for v in input().split()}
	crr = arr & brr
	if crr:
		print('YES')
		print(1, crr.pop())
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


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


t = int(input())
for i in range(t):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	arrA = input().split()
	arrB = input().split()
	maxIter = min(len(arrA), len(arrB))
	arrC = []
	for a in arrA:
		if a in arrB:
			arrC.append(a)
	if not arrC:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(arrC[0])


t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	m = int(l[1])
	l = input().split()
	ai = [int(i) for i in l]
	l = input().split()
	bi = [int(i) for i in l]
	ans = 0
	done = 0
	hashi = dict()
	for i in ai:
		hashi[i] = 1
	for i in bi:
		if i in hashi:
			done = 1
			ans = i
			break
	if done:
		print('YES')
		print(1, end=' ')
		print(ans)
	else:
		print('NO')


n = int(input())
for i in range(n):
	flag = 0
	c = list(map(int, input().strip().split()))
	d = list(map(int, input().strip().split()))
	e = list(map(int, input().strip().split()))
	for each in d:
		if each in e:
			print('YES')
			print('1 ' + str(each))
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l = set(list(map(int, input().split())))
	y = set(list(map(int, input().split())))
	z = list(l.intersection(y))
	if len(z) == 0:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(z[0]))


for ii in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = min(n, m)
	a.sort()
	b.sort()
	if x == m:
		c = 0
		for i in range(x):
			if b[i] in a:
				print('YES')
				print(1, b[i])
				c += 1
				break
		if c == 0:
			print('NO')
	else:
		c = 0
		for i in range(x):
			if a[i] in b:
				print('YES')
				print(1, a[i])
				c += 1
				break
		if c == 0:
			print('NO')


t = int(input())
while t:
	(m, n) = [int(x) for x in input().split()]
	a = list(map(int, input().strip().split()))[:m]
	b = list(map(int, input().strip().split()))[:n]
	flag = 0
	for i in range(m):
		if a[i] in b:
			flag = 1
			num = a[i]
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1)
		print(num)
	t = t - 1


import sys

def smallest_subsequence(a, b):
	b_set = set(b)
	for i in a:
		if i in b_set:
			return i
	return None

def main(fd=sys.stdin):
	t = int(next(fd))
	for _ in range(t):
		next(fd)
		a = [int(i) for i in next(fd).split()]
		b = [int(i) for i in next(fd).split()]
		c = smallest_subsequence(a, b)
		if c is None:
			print('NO')
		else:
			print('YES')
			print(f'1 {c}')
main()


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
from queue import PriorityQueue
from collections import Counter as cc
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	flag = 0
	for i in l1:
		if i in l2:
			flag = 1
			print('YES')
			print(1, i)
			break
	if flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	r = list(map(int, input().split()))
	ans = -1
	for i in range(n):
		if l[i] in r:
			ans = l[i]
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
while t != 0:
	temp = list(map(int, input().strip().split()))[:2]
	n = temp[0]
	m = temp[1]
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:m]
	flag = False
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			flag = True
			break
	if flag == False:
		print('NO')
	t -= 1


def main():
	t = int(input())
	for case in range(t):
		(n, m) = input().split()
		s1 = set(input().split())
		s2 = set(input().split())
		res = s1.intersection(s2)
		if len(res) == 0:
			print('NO')
		else:
			print('YES')
			print(1, res.pop())
main()


for _ in range(int(input())):
	llll = input()
	l = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l = set(l)
	l2 = set(l2)
	x = l.intersection(l2)
	x = list(x)
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		print(1, x[0])


def main():
	t = Iint()
	for _ in range(t):
		(n, m) = Imap()
		a = Ilist()
		b = Ilist()
		a = set(a)
		for bi in b:
			if bi in a:
				print('YES')
				print(1, bi)
				break
		else:
			print('NO')
FIO = 1

def I():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
en = enumerate
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import sys
	import os
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_as_set = set(a)
	intersection = a_as_set.intersection(b)
	intersection_as_list = list(intersection)
	if len(intersection_as_list) > 0:
		print('YES')
		print(1, intersection_as_list[0])
	else:
		print('NO')


import sys
t = int(sys.stdin.readline().strip())
inp = []
for i in range(t):
	quantity = sys.stdin.readline().strip()
	lineOne = sys.stdin.readline().strip().split(' ')
	lineTwo = sys.stdin.readline().strip().split(' ')
	inter = set(lineOne) & set(lineTwo)
	if inter:
		print('YES')
		print(str(1) + ' ' + str(inter.pop()))
	else:
		print('NO')


import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil, atan, pi

def input():
	return sys.stdin.readline()[:-1]
import string
from bisect import bisect_left
MOD = int(1000000000.0) + 7
INF = float('inf')

def solve():
	(n, m) = [int(x) for x in input().split()]
	a = set([int(x) for x in input().split()])
	b = [int(x) for x in input().split()]
	for e in b:
		if e in a:
			print('YES')
			print(1, e)
			return
	print('NO')
t = 1
t = int(input())
for case in range(1, t + 1):
	ans = solve()


from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[a[i]] = 1
	ans = 0
	for i in range(m):
		if d[b[i]] == 1:
			ans = b[i]
			break
	if ans != 0:
		print('YES')
		print(1, b[i])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split(' ')]
	l1 = [int(x) for x in input().split(' ')]
	l2 = [int(x) for x in input().split(' ')]
	s1 = set(l1)
	inter = s1.intersection(l2)
	z1 = list(inter)
	if len(z1) >= 1:
		print('YES')
		print('{} {}'.format(1, z1[0]))
	else:
		print('NO')


tc = int(input())
while tc != 0:
	(a, b) = map(int, input().split())
	i = 0
	j = 0
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	tc -= 1
	c = 0
	for i in range(0, a):
		for j in range(0, b):
			if arr[i] == arr2[j]:
				print('yes')
				c = 1
				print(1, arr[i])
				break
		if c == 1:
			break
	if c == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	ans = -5
	if n < m:
		for i in li1:
			if i in li2:
				ans = i
				break
	else:
		for i in li2:
			if i in li1:
				ans = i
				break
	if ans < 0:
		print('No')
	else:
		print('Yes')
		print(1, ans)


import sys
input = sys.stdin.buffer.readline
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	crr = list(set(arr) & set(brr))
	if len(crr) == 0:
		print('NO')
	else:
		print('YES')
		print('1', crr[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = []
	for i in a:
		if i in b:
			k.append(i)
			break
	kk = []
	for j in b:
		if j in a:
			kk.append(j)
			break
	if min(len(kk), len(k)) >= 1:
		print('YES')
		print(1, *kk)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr_n = list(map(int, input().split()))
	arr_m = list(map(int, input().split()))
	flag = False
	ans = 0
	for i in range(n):
		for j in range(m):
			if arr_n[i] == arr_m[j]:
				flag = True
				ans = arr_n[i]
				break
		if flag == True:
			break
	if flag == True:
		print('YES')
		print(1, ans)
	else:
		print('NO')


def examA():
	T = I()
	for _ in range(T):
		(N, M) = LI()
		A = LI()
		B = LI()
		B = set(B)
		cur = -1
		for a in A:
			if a in B:
				cur = a
				break
		if cur == -1:
			print('NO')
			continue
		print('YES')
		print('1', cur)
	return

def examB():
	T = I()
	ans = []
	for _ in range(T):
		cur = 0
		ans.append(cur)
	for v in ans:
		print(v)
	return

def examC():
	T = I()
	ans = []
	for _ in range(T):
		cur = 0
		ans.append(cur)
	for v in ans:
		print(v)
	return

def examD():
	ans = 0
	print(ans)
	return

def examE():
	ans = 0
	print(ans)
	return

def examF():
	ans = 0
	print(ans)
	return
from decimal import getcontext, Decimal as dec
import sys, bisect, heapq
from copy import deepcopy
from heapq import heappop, heappush, heapify
from collections import Counter, defaultdict, deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def I():
	return int(input())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def DI():
	return dec(input())

def LDI():
	return list(map(dec, sys.stdin.readline().split()))

def LSI():
	return list(map(str, sys.stdin.readline().split()))

def LS():
	return sys.stdin.readline().split()

def SI():
	return sys.stdin.readline().strip()
global mod, mod2, inf, alphabet, _ep
mod = 10 ** 9 + 7
mod2 = 998244353
inf = 10 ** 18
_ep = dec('0.000000000001')
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}
getcontext().prec = 28
sys.setrecursionlimit(2 * 10 ** 5)
examA()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	myans = -1
	for i in arr1:
		if i in arr2:
			myans = i
			break
	if myans == -1:
		print('NO')
	else:
		print('YES')
		print(1, myans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
t = ip()
for _ in range(t):
	(n, m) = inp()
	a = list(inp())
	b = list(inp())
	ch = set(a) & set(b)
	if len(ch) == 0:
		print('NO')
	else:
		print('YES')
		ch = list(ch)
		print(1, ch[0])


import random
hasil = []

def elemensama(arr1, arr2):
	global hasil
	sama = []
	found = False
	for data1 in arr1:
		for data2 in arr2:
			if data1 == data2:
				found = True
				sama += [data1]
	if found == True:
		x = random.choice(sama)
		hasil += ['YES']
		hasil += ['1 ' + str(x)]
	else:
		hasil += ['NO']
t = int(input())
for i in range(t):
	len = input().split(' ')
	Tab_a = input().split(' ')
	Tab_b = input().split(' ')
	elemensama(Tab_a, Tab_b)
for row in hasil:
	print(row)


t = int(input())
while t != 0:
	(n, m) = map(int, input().split())
	arrA = sorted(list(map(int, input().split())))
	arrB = sorted(list(map(int, input().split())))
	result = 0
	resultIndex = -1
	for i in range(len(arrA)):
		for j in range(len(arrB)):
			if arrA[i] == arrB[j]:
				result = 1
				resultIndex = i
				break
		if result != 0:
			break
	if result == 0:
		print('NO')
	else:
		print('YES')
		print('1 {0}'.format(arrA[resultIndex]))
	t -= 1


w = int(input())
for o in range(w):
	(n, m) = list(map(int, input().split(' ')))
	A = list(map(int, input().split(' ')))
	B = list(map(int, input().split(' ')))
	dic = {}
	for i in B:
		dic[i] = 1
	done = False
	for i in A:
		if i in B:
			print('YES')
			print(1, i)
			done = True
			break
	if not done:
		print('NO')


t = int(input(''))
for i in range(0, t):
	(p, q) = input('').split(' ')
	n = int(p)
	m = int(q)
	a = list(map(int, input('').strip().split()))
	b = list(map(int, input('').strip().split()))
	c = list(set(a).intersection(b))
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(c[0]))


for _ in range(int(input())):
	input()
	l = set(map(int, input().split()))
	m = set(map(int, input().split()))
	l = list(l.intersection(m))
	if len(l):
		print('YES')
		print(1, l[0])
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
letters = 'abcdefghijklmnopqrst'
for _ in range(t):
	(m, n) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	common = []
	for el in a:
		for kel in b:
			if el == kel:
				common.append(el)
	if len(common) > 0:
		print('YES')
		print(1, common[0])
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a.intersection(b)
	if c:
		print('YES')
		print('1 {}'.format(c.pop()))
	else:
		print('NO')


def work(l1, l2):
	for i in l1:
		if i in l2:
			return i
	return 0
t = int(input())
for i in range(t):
	(n1, n2) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	x = work(l1, l2)
	if x == 0:
		print('NO')
	else:
		print('YES')
		print('1', x, sep=' ')


def tc():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = set(a) & set(b)
	if c:
		print('YES')
		print(1, c.pop())
	else:
		print('NO')
T = int(input())
for _ in range(T):
	tc()


t = int(input())
for i in range(t):
	(n, m) = input().split()
	l = list(map(int, input().strip().split()))
	l1 = list(map(int, input().strip().split()))
	flag = 0
	for j in l:
		if j in l1:
			flag = 1
			print('YES')
			print(1, end=' ')
			print(j)
			break
	if flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l3 = []
	if n >= m:
		for i in l1:
			if i in l2:
				l3.append(i)
				break
	else:
		for i in l2:
			if i in l1:
				l3.append(i)
				break
	if len(l3) > 0:
		print('YES')
		print(len(l3), end=' ')
		print(*l3)
	else:
		print('NO')


t = int(input())
while t:
	(q, r) = input().split()
	x = input()
	y = input()
	a = [int(n) for n in x.split()]
	b = [int(m) for m in y.split()]
	flag = 0
	for num in a:
		for num1 in b:
			if num == num1 and num > flag:
				flag = num
	if flag != 0:
		print('YES')
		print('{} {}'.format(1, flag))
	else:
		print('NO')
	t = t - 1


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(input().split())
	b = list(input().split())
	for k in a:
		x = []
		if k in b:
			print('YES')
			x.append(int(k))
			print(len(x), str(x).replace('[', '').replace(']', ''))
			break
	if k not in b:
		print('NO')


def common(a, b):
	a = set(a)
	b = set(b)
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			return
	print('NO')
t = int(input())
for _ in range(t):
	nm = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	common(a, b)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	lis1 = list(map(int, input().split()))
	lis2 = list(map(int, input().split()))
	check = 0
	ans = 1
	for i in lis1:
		if i in lis2:
			check = 1
			ans = i
			break
	if check == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	tr = True
	for j in a:
		if j in b:
			tr = False
			print('YES')
			print(1, j)
			break
	if tr:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	l = [int(num) for num in input().split()]
	r = [int(num) for num in input().split()]
	l1 = set(l)
	r1 = set(r)
	if l1 & r1:
		print('YES')
		print('1', list(l1 & r1)[0])
	else:
		print('NO')


import math as mt

def tran(ar1, ar2):
	an = []
	for i in ar1:
		if i in ar2:
			an.append('YES')
			break
	if len(an) == 1:
		an.append(1)
		an.append(i)
	else:
		an.append('NO')
	return an
t = int(input())
ans = []
for i in range(t):
	nm = list(map(int, input().rstrip().split()))
	ar1 = list(map(int, input().rstrip().split()))
	ar2 = list(map(int, input().rstrip().split()))
	r = tran(ar1, ar2)
	ans.append(r)
for i in ans:
	if len(i) == 3:
		print(i[0])
		i.pop(0)
		print(*i)
	else:
		print('NO')


def common_data(list1, list2):
	result = False
	for x in list1:
		for y in list2:
			if x == y:
				result = x
				print('YES')
				print(1, x)
				flag = 1
				break
			else:
				flag = 0
		if flag == 1:
			break
	if flag == 0:
		print('NO')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	common_data(a, b)


t = int(input())
for t_ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flat = 0
	for i in a:
		if i in b:
			print('YES')
			print(f'1 {i}')
			flat = 1
			break
	if flat == 0:
		print('NO')


t = int(input())
for i in range(t):
	c = 1
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = max(n, k)
	res = 0
	if n < k:
		for i in range(n):
			if a[i] in b:
				c = 0
				res = a[i]
				break
	elif n > k:
		for i in range(k):
			if b[i] in a:
				c = 0
				res = b[i]
				break
	elif n == k:
		for i in range(n):
			if a[i] in b:
				c = 0
				res = a[i]
				break
	if c == 0:
		print('YES')
		print(1, res)
	else:
		print('NO')


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	cnt = [0] * 1001
	input()
	for i in map(int, input().split()):
		cnt[i] = 1
	(*b,) = map(int, input().split())
	for i in b:
		if cnt[i]:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	res = 'NO'
	number = -1
	for i in arr1:
		if i in arr2:
			res = 'YES'
			number = i
	if number == -1:
		print('NO')
	else:
		print('YES')
		print('1', number)
	t -= 1


from __future__ import division, print_function
from sys import stdin, stdout
import bisect
import math
import heapq
i_m = 9223372036854775807

def inin():
	return int(input())

def stin():
	return input()

def spin():
	return map(int, stin().split())

def lin():
	return list(map(int, stin().split()))

def matrix(n):
	return [list(map(int, input().split())) for i in range(n)]

def count2Dmatrix(i, list):
	return sum((c.count(i) for c in list))

def modinv(n, p):
	return pow(n, p - 2, p)

def GCD(x, y):
	x = abs(x)
	y = abs(y)
	if min(x, y) == 0:
		return max(x, y)
	while y:
		(x, y) = (y, x % y)
	return x

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l
prime = []

def SieveOfEratosthenes(n):
	global prime
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j
for _ in range(inin()):
	(n, m) = spin()
	a = lin()
	b = lin()

	def intersection(lst1, lst2):
		temp = set(lst2)
		lst3 = [value for value in lst1 if value in temp]
		return lst3
	l = intersection(a, b)
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(1, l[0])


t = int(input())
for w in range(t):
	(n, m) = (int(i) for i in input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = 0
	for i in range(n):
		for j in range(m):
			if b[j] == a[i]:
				c = 1
				k = a[i]
				break
	if c == 0:
		print('NO')
	else:
		print('YES')
		print(1, k)


T = int(input())
for t in range(T):
	(n, m) = map(int, input().split())
	a = map(int, input().split())
	b = map(int, input().split())
	res = set(a) & set(b)
	if len(res):
		print('YES')
		print('1', end=' ')
		print(res.pop())
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m) = [int(i) for i in input().split()]
	A = set([int(i) for i in input().split()])
	B = set([int(i) for i in input().split()])
	C = list(A & B)
	if len(C) > 0:
		print('YES')
		print(*[1, C[0]])
	else:
		print('NO')


i = lambda : input().split()
for _ in range(int(*i())):
	i()
	s = set(i()) & set(i())
	print('YES 1 ' + [*s][0] if s else 'NO')


t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(map(int, input().split()))
	found = None
	for i in a:
		if i in b:
			found = i
			break
	if found is None:
		print('NO')
	else:
		print('YES')
		print(1, found)


for _ in range(int(input())):
	input()
	common = set(input().split()).intersection(input().split())
	if common:
		print('YES')
		for e in common:
			break
		print(1, e)
	else:
		print('NO')


def solve():
	(n, m) = list(map(int, input().split()))
	a = set(list(map(int, input().split())))
	b = set(list(map(int, input().split())))
	d = a.intersection(b)
	if len(d) > 0:
		print('YES')
		print('1 {}'.format(d.pop()))
	else:
		print('NO')
t = int(input())
for test in range(t):
	solve()


T = int(input())
for _ in range(T):
	(N, M) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	c = list(set(a) & set(b))
	if c:
		print(f'YES\n1 {c[0]}')
	else:
		print('NO')


from collections import defaultdict
test_case_count = int(input())
for i in range(test_case_count):
	arr_lens = input().split(' ')
	arr1 = input().split(' ')
	arr2 = input().split(' ')
	d = defaultdict(bool)
	for item in arr1:
		d[item] = True
	length = 0
	for item in arr2:
		if item in d.keys():
			length = 1
			scs = item
	if length:
		print('YES\n1 ', scs)
	else:
		print('NO')


test_case = int(input())
for _ in range(test_case):
	(r1, r2) = map(int, input().split())
	array1 = list(map(int, input().split()))
	array2 = list(map(int, input().split()))
	flag = False
	for number in array1:
		if number in array2:
			flag = True
			print('YES')
			print('1', number)
			break
	if not flag:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	t = True
	for i in range(len(A)):
		for j in range(len(B)):
			if A[i] == B[j]:
				t = False
				break
		if t == False:
			break
	if t:
		print('NO')
	else:
		print('YES')
		print(1, A[i])


t = int(input())
for k in range(t):
	s = input().split()
	(n, m) = [int(x) for x in s]
	ap = input().split()
	a = [x for x in ap]
	bp = input().split()
	b = [x for x in bp]
	c = [int(i) for i in a if i in b]
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		if len(c) >= 1:
			print('1 {}'.format(c[0]))


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ar = set()
	for i in range(n):
		for j in range(m):
			if a[i] == b[j] and len(ar) < 1:
				ar.add(a[i])
	ar = list(ar)
	if len(ar) > 0:
		print('YES')
		print(len(ar), *ar)
	else:
		print('NO')


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()))
	answer = -1
	mas = [0] * 1009
	for i in range(n):
		mas[a[i]] = 1
	for i in range(m):
		if mas[b[i]] == 1:
			answer = b[i]
	if answer > 0:
		print('YES')
		print(1, answer)
	else:
		print('NO')


n = int(input())
k = []
for i in range(n):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	f = False
	for j in a:
		if j in b:
			f = True
			k.append(j)
			break
		else:
			f = False
	if not f:
		k.append(-1)
for i in k:
	if i == -1:
		print('NO')
	else:
		print('YES')
		print(1, i)


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])


import sys
input = sys.stdin.readline
for f in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for i in a:
		if i in b:
			ans = i
			flag = True
			break
	if flag == True:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().strip().split()))
	list1 = list(map(int, input().strip().split()))
	list2 = list(map(int, input().strip().split()))
	b = 0
	for val in list1:
		if val in list2:
			b = 1
			ans = val
			break
	if b:
		print('YES')
		print(1, ans)
	else:
		print('NO')


test = int(input())
for _ in range(test):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr = []
	flag = 0
	if n > m:
		for i in arr1:
			if i in arr2:
				flag = 1
				arr.append(i)
				break
	else:
		for i in arr2:
			if i in arr1:
				flag = 1
				arr.append(i)
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(len(arr), ' ', arr[0])


test = int(input())
for t in range(test):
	(l, r) = map(int, input().split())
	lst1 = set(list(map(int, input().split())))
	lst2 = set(list(map(int, input().split())))
	k = list(set(lst1) & set(lst2))
	if len(k) != 0:
		print('YES')
		if len(k) > 1:
			print(1, end=' ')
		else:
			print(len(k), end=' ')
		for x in k:
			print(x)
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(i) for i in input().split()]
	a = set([int(i) for i in input().split()])
	b = set([int(i) for i in input().split()])
	count = len(a & b)
	mas = a & b
	if count > 0:
		print('YES')
		for num in mas:
			print(1, num)
			break
	else:
		print('NO')


t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q = True
	for i in a:
		for j in b:
			if i != j:
				q = False
			else:
				q = True
				print('YES')
				print(1, i)
				break
		if q == True:
			break
	if q == False:
		print('NO')


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = list(map(int, input().split()))
	for j in b:
		if j in a:
			print('YES')
			print(1, j)
			break
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = list(set(a) & set(b))
	if len(ans) > 0:
		print('YES')
	else:
		print('NO')
		continue
	print(1, ' ', ans[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	num = list(set(l1) & set(l2))
	if num:
		print('YES')
		print(1, min(num))
	else:
		print('NO')


tc = int(input())
for _ in range(tc):
	[leng1, leng2] = list(map(int, input().split()))
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1_as_set = set(arr1)
	intersection = list(arr1_as_set.intersection(arr2))
	if intersection:
		print('YES')
		print(1, intersection[0])
	else:
		print('NO')


def inp():
	return int(input())

def insr():
	s = input()
	return s

def inlt():
	return list(map(int, input().split()))
r = inp()
for i in range(r):
	l2 = inlt()
	p1 = inlt()
	p2 = inlt()
	a = list(set(p1).intersection(set(p2)))
	if len(a) > 0:
		print('YES\n')
		print('1 ' + str(a[0]) + '\n')
	else:
		print('NO\n')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	lis = set(map(int, input().split()))
	lis1 = set(map(int, input().split()))
	r = lis & lis1
	k = 0
	for i in r:
		k = i
		break
	if len(r) != 0:
		print('YES')
		print('1', k)
	else:
		print('NO')


import sys
import os.path

def solve():
	T = int(input())
	for tests in range(T):
		(n, m) = map(int, input().split())
		cnt = [False] * 1010
		for val in list(map(int, input().split())):
			cnt[val] = True
		ans = -1
		for val in list(map(int, input().split())):
			if cnt[val]:
				ans = val
		if ans == -1:
			print('NO')
		else:
			print('YES')
			print(1, ans)

def main():
	if os.path.exists('test.inp'):
		sys.stdin = open('test.inp', 'r')
	solve()
main()


import random

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	f = -1
	a.sort()
	b.sort()
	d = {}
	for i in a:
		d[i] = 1
	for i in b:
		if i in d:
			f = i
	if f == -1:
		print('NO')
	else:
		print('YES')
		print(1, f)


def answer(n, m, A, B):
	d = {}
	for i in range(n):
		if A[i] not in d:
			d[A[i]] = 1
	for i in range(m):
		if B[i] in d:
			return ('YES', [1, B[i]])
	return ('NO', [])
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()))
	(x, y) = answer(n, m, a, b)
	if x == 'NO':
		print('NO')
	else:
		print('YES')
		print(*y)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	ls = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	f = False
	for i in range(a):
		for j in range(b):
			if ls[i] == lm[j]:
				print('YES')
				print(1, ls[i])
				f = True
				break
		if f:
			break
	if not f:
		print('NO')


t = int(input())
for tt in range(t):
	(n, m) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	a.sort()
	b.sort()
	all_members_a = set(a)
	all_members_b = set(b)
	fl = 1
	for mem in all_members_a:
		if mem in all_members_b:
			print('YES')
			print(1, mem)
			fl = 0
			break
	if fl:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	flag = 1
	for i in range(n):
		if a[i] in b:
			ans = a[i]
			print('YES')
			print(1, ans)
			flag = 0
			break
	if flag:
		print('NO')
	t -= 1


def ans(l, l1):
	l.sort()
	l1.sort()
	k = list(set(l) & set(l1))
	k.sort()
	if k:
		print('YES')
		if len(k) > 1:
			print(1, k[1])
		else:
			print(1, k[0])
	else:
		print('NO')
t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	if a == 1 and b == 1:
		if l[0] == l1[0]:
			print('YES')
			print(1, l[0])
		else:
			print('NO')
	elif l == l1:
		print('YES')
		print(1, l[1])
	else:
		ans(l, l1)
	t -= 1


def solve(arr, arr2):
	for i in arr:
		if i in arr2:
			print('YES')
			print(1, end=' ')
			print(i)
			return
	print('NO')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arra = list(map(int, input().split()))
	arrb = list(map(int, input().split()))
	solve(arra, arrb)


t = int(input())

def bin_search(l1, l, num):
	beg = 0
	end = l
	while beg <= end:
		mid = (beg + end) // 2
		if l1[mid] < num:
			beg = mid + 1
		elif l1[mid] > num:
			end = mid - 1
		else:
			return l1[mid]
	if num == l1[0]:
		return l1[0]
	return -1
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in b:
		if i in a:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')
	t = t - 1


def io():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n > m:
		c = a.copy()
		d = b.copy()
	else:
		c = b.copy()
		d = a.copy()
	return [n, m, c, d]

def solve():
	(n, m, a, b) = io()
	ans = 'NO'
	for i in range(len(b)):
		for j in range(len(a)):
			if b[i] == a[j]:
				ans = 'YES'
				print(ans)
				print(1, b[i])
				break
			if ans == 'YES':
				break
		if ans == 'YES':
			break
	if ans != 'YES':
		print('NO')
T = int(input())
for _ in range(T):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	L1 = list(map(int, input().split()))
	L2 = list(map(int, input().split()))
	k = 0
	for i in L1:
		if i in L2:
			k += 1
			z = i
			break
	if k > 0:
		print('YES')
		print(k, z)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	lstn = list(map(int, input().split()))
	lstm = list(map(int, input().split()))
	count = {}
	flag = 0
	for i in lstn:
		if i not in count:
			count[i] = 1
	for j in lstm:
		if j in count:
			print('YES')
			print(1, j)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = [int(n) for n in input().split()]
	arr = [int(item) for item in input().split()]
	brr = [int(item) for item in input().split()]
	d = dict()
	for i in range(1001):
		d[i] = 0
	for j in arr:
		d[j] = d[j] + 1
	flag = 0
	for k in brr:
		if d[k] > 0:
			s = k
			flag = 1
			break
	if flag == 1:
		print('YES')
		print(1, s)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(__) for __ in input().split()]
	a = [int(___) for ___ in input().split()]
	b = [int(____) for ____ in input().split()]
	ans = 0
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())
for t1 in range(t):
	(a, b) = input().split()
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	s1 = set(ar1)
	s2 = set(ar2)
	f = 0
	fd = int()
	for data in s1:
		if data in s2:
			f = 1
			fd = data
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		print(1, fd)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(list(map(int, input().split())))
	pos = False
	for i in range(n):
		if a[i] in b:
			pos = True
			print('YES')
			print(1, a[i])
			break
	if not pos:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	for number in a:
		if number in b:
			print('YES')
			print(1, number)
			break
	else:
		print('NO')

def main():
	for _ in range(int(input())):
		solve()
main()


for _ in range(int(input())):
	(N, M) = map(int, input().split())
	A = [int(x) for x in input().split()]
	B = [int(x) for x in input().split()]
	flag = 0
	for i in A:
		if i in B:
			print('YES')
			print(1, i)
			flag = 1
			break
	if not flag:
		print('NO')


for i in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	e = True
	for j in c:
		if j in d:
			print('YES')
			print(1, j)
			e = False
			break
	if e == True:
		print('NO')


for _ in range(int(input())):
	(a1, b1) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(set(a) & set(b))
	if len(c) != 0:
		print('YES')
		print(1, c[0])
	else:
		print('NO')


def multiple_input():
	return map(int, input().split())

def list_input():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(n, m) = multiple_input()
	a = list_input()
	b = list_input()
	d = {}
	for i in a:
		d[i] = 1
	flag = 0
	for i in b:
		if i in d:
			flag = 1
			print('YES')
			print('1 ', i)
			break
	if flag == 0:
		print('NO')


import time
from collections import deque

def inpt():
	return int(input())

def inpl():
	return list(map(int, input().split()))

def inpm():
	return map(int, input().split())

def solve():
	(n, m) = inpm()
	l = inpl()
	q = inpl()
	d = {}
	for i in l:
		d[i] = 1
	for i in q:
		if i in d:
			print('YES')
			print(1, i)
			return
	print('NO')
	return

def main():
	m = 10 ** 9 + 7
	t = int(input())
	while t:
		t -= 1
		solve()
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	Arr1 = list(map(int, input().split()))
	Arr2 = list(map(int, input().split()))
	flag = False
	for i in range(m):
		if Arr2[i] in Arr1:
			flag = True
			value = Arr2[i]
			break
	if flag:
		print('YES')
		print(1, end=' ')
		print(value)
	else:
		print('NO')


t = int(input())
while t > 0:
	a = [int(x) for x in input().split()]
	n = a[0]
	m = a[1]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	k = 0
	for i in a:
		for j in b:
			if j == i:
				num = i
				k = 1
				break
		if k == 1:
			break
	if k == 1:
		print('YES')
		print(1, num)
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	q = input().split()
	len_a = int(q[0])
	len_b = int(q[1])
	a = input().split()
	b = input().split()
	for i in range(len_a):
		a[i] = int(a[i])
	for i in range(len_b):
		b[i] = int(b[i])
	a.sort()
	b.sort()
	flag = 0
	if len_a == 1:
		if a[0] in b:
			flag = 1
			print('YES')
			print(1, a[0])
	elif len_b == 1:
		if b[0] in a:
			flag = 1
			print('YES')
			print(1, b[0])
	elif len_a <= len_b:
		for i in range(len_a):
			if flag == 1:
				break
			d = 0
			while d < len_b - 1 and b[d] < a[i]:
				d += 1
			if b[d] == a[i]:
				flag = 1
				print('YES')
				print(1, a[i])
	else:
		for i in range(len_b):
			if flag == 1:
				break
			d = 0
			while b[i] > a[d] and d < len_a - 1:
				d += 1
			if b[i] == a[d]:
				flag = 1
				print('YES')
				print(1, b[i])
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	f = 0
	for i in arr1:
		if i in arr2:
			print('YES')
			print(1, i)
			f = 1
			break
	if f == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	s = set(l1)
	flag = 0
	for i in l2:
		if i in s:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	s1 = s.split()
	n = int(s1[0])
	m = int(s1[1])
	l1 = []
	l2 = []
	k = input()
	k1 = k.split()
	for j in k1:
		l1.append(int(j))
	p = input()
	p1 = p.split()
	for k in p1:
		l2.append(int(k))
	if n < m:
		a = 0
		for i in l1:
			if i in l2:
				print('YES')
				print(1, i)
				a = 1
				break
		if a == 0:
			print('NO')
	else:
		b = 0
		for i in l2:
			if i in l1:
				print('YES')
				print(1, i)
				b = 1
				break
		if b == 0:
			print('NO')


T = int(input())
for t in range(T):
	(N, M) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	counts = set()
	for e in a:
		counts.add(e)
	found = False
	for e in b:
		if e in counts:
			print('YES')
			print(1, e)
			found = True
			break
	if not found:
		print('NO')


t = int(input())
while t > 0:
	(m, n) = map(int, input().split())
	arr1 = list(map(int, input().strip().split()))[:m]
	arr2 = list(map(int, input().strip().split()))[:n]
	final = ['/']
	index = [-1]
	for i in range(len(arr1)):
		for j in range(len(arr2)):
			if arr1[i] == arr2[j] and j > index[-1]:
				final.append(arr1[i])
				index.append(j)
	final.pop(0)
	if len(final) == 0:
		print('NO')
	else:
		print('YES')
		print('1' + ' ' + str(min(final)))
	t -= 1


for i in range(int(input())):
	(n, m) = map(int, input().split())
	n = list(map(int, input().split()))
	m = list(map(int, input().split()))
	l = []
	for i in n:
		if i in m:
			l.append(i)
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(1, l[0])


import sys
input = sys.stdin.readline
import heapq
import copy
import math
import decimal

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def insr2():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def pr_list(a):
	print(*a, sep=' ')

def main():
	tests = inp()
	mod = 1000000007
	limit = 10 ** 18
	ans = 0
	stack = []
	hashm = {}
	arr = []
	heapq.heapify(arr)
	for test in range(tests):
		[n, m] = inlt()
		a = inlt()
		b = inlt()
		hashm = {}
		for i in a:
			hashm[i] = 1
		ans = []
		for i in b:
			if i in hashm:
				ans = [1, i]
				break
		if ans == []:
			print('No')
		else:
			print('Yes')
			pr_list(ans)
main()


import sys
I = lambda : int(input())
readline = lambda : sys.stdin.readline().strip('\n')
readgen = lambda : map(int, readline().split())
R = readgen
S = lambda : set(R())
for _ in range(I()):
	(a, b) = R()
	inter = S().intersection(S())
	if inter:
		print('YES\n1 %d' % inter.pop())
	else:
		print('NO')


from collections import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c1 = Counter(a)
	c2 = Counter(b)
	ans = -1
	for (key, value) in c1.items():
		if c2[key] > 0:
			ans = key
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


from collections import Counter, defaultdict
BS = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def to_base(s, b):
	res = ''
	while s:
		res += BS[s % b]
		s //= b
	return res[::-1] or '0'
alpha = 'abcdefghijklmnopqrstuvwxyz'
from math import floor, ceil, pi, log
import sys
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, 7877, 7879, 7883, 7901, 7907, 7919]
import timeit

def primef(n, plst=[]):
	if n == 1:
		return plst
	else:
		for m in primes:
			if n % m == 0:
				return primef(n // m, plst + [m])
		return primef(1, plst + [n])

def lmii():
	return list(map(int, input().split()))

def ii():
	return int(input())

def countOverlapping(string, sub):
	count = start = 0
	while True:
		start = string.find(sub, start) + 1
		if start > 0:
			count += 1
		else:
			return count

def base10Len(n):
	return len(str(n))
t = int(input())
for i in range(t):
	(n, m) = lmii()
	a = set(lmii())
	b = set(lmii())
	done = False
	for i in a:
		if i in b:
			print('YES')
			print(f'1 {i}')
			done = True
			break
	if not done:
		print('NO')


for z in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = False
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ok = True
				break
		if ok:
			break
	if ok:
		print('YES')
		print(1, a[i])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [False for p in range(1001)]
	b = [False for p in range(1001)]
	for c in input().split():
		a[int(c)] = True
	for c in input().split():
		b[int(c)] = True
	found = False
	for j in range(1, 1001):
		if a[j] == True and b[j] == True:
			found = True
			print('YES')
			print('1 ' + str(j))
			break
	if not found:
		print('NO')


for s in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	maxi = max(s1, s2, key=len)
	if maxi == s2:
		mini = s1
	else:
		mini = s2
	for i in maxi:
		if i in mini:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


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()))
	res = 0
	i = 0
	if n < m:
		while i < n and a[i] not in b:
			i += 1
		if i == n:
			print('NO')
		else:
			print('YES')
			print('1 ' + str(a[i]))
	else:
		while i < m and b[i] not in a:
			i += 1
		if i == m:
			print('NO')
		else:
			print('YES')
			print('1 ' + str(b[i]))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	aa = set((int(a) for a in input().split()))
	bb = set((int(a) for a in input().split()))
	cc = aa & bb
	if len(cc) == 0:
		print('NO')
	else:
		print('YES')
		print(1, [*cc][0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	temp = 0
	flag = False
	for i in range(n):
		for j in range(m):
			if l1[i] == l2[j]:
				temp = l1[i]
				flag = True
				break
	if flag:
		print('YES')
		print(1, temp)
	else:
		print('NO')


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()))
	k = 0
	if n == 1 and m == 1:
		if a[0] == b[0]:
			print('YES')
			print('1', a[0])
		else:
			print('NO')
	else:
		for x in range(n):
			for y in range(m):
				if a[x] == b[y]:
					k = a[x]
					break
		if k == 0:
			print('NO')
		else:
			print('YES')
			print('1', k)


def lcs(str1, str2):
	n = len(str1)
	m = len(str2)
	dp = [[0 for i in range(m + 1)] for j in range(n + 1)]
	for i in range(n - 1, -1, -1):
		for j in range(m - 1, -1, -1):
			if str1[i] == str2[j]:
				dp[i][j] = 1 + dp[i + 1][j + 1]
			else:
				dp[i][j] = max(dp[i + 1][j], dp[i][j + 1])
	return dp[0][0]

def printIntersection(arr1, arr2, m, n):
	(i, j) = (0, 0)
	li = []
	arr1.sort()
	arr2.sort()
	while i < m and j < n:
		if arr1[i] < arr2[j]:
			i += 1
		elif arr2[j] < arr1[i]:
			j += 1
		else:
			li.append(arr2[j])
			j += 1
			i += 1
	return li[0]
t = int(input())
while t > 0:
	(n, m) = [int(ele) for ele in input().split()]
	li = [int(ele) for ele in input().split()]
	li1 = [int(ele) for ele in input().split()]
	ans = lcs(li, li1)
	if ans == 0:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(printIntersection(li, li1, n, m))
	t = t - 1


import sys
import math
from collections import defaultdict
t = int(sys.stdin.readline())
for _ in range(t):
	(n, m) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	b = list(map(int, sys.stdin.readline().split()))
	dica = defaultdict(int)
	for i in range(n):
		dica[a[i]] += 1
	z = True
	for i in range(m):
		if dica[b[i]] >= 1:
			z = False
			print('YES')
			print(1, b[i])
			break
	if z:
		print('NO')


from sys import stdin
import heapq
T = int(input())
for case in range(T):
	(num1, num2) = [int(x) for x in stdin.readline().split()]
	lst1 = []
	lst1 = [int(item) for item in input().split()]
	flag = False
	lst2 = []
	lst2 = [int(item) for item in input().split()]
	for i in range(num2):
		if lst1.count(lst2[i]) != 0:
			print('YES')
			print(1, end=' ')
			print(lst2[i])
			flag = True
			break
	if not flag:
		print('NO')


T = int(input())
for _ in range(T):
	(n1, n2) = list(map(int, input().split()))
	s1 = list(map(int, input().split()))
	s2 = list(map(int, input().split()))
	flag = 0
	for i in range(n1):
		if s1[i] in s2:
			print('YES')
			print(1, s1[i])
			flag = 1
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l = []
	f = 0
	for i in range(len(l1)):
		l.append(l1[i])
	for i in range(len(l2)):
		if l2[i] in l:
			print('YES')
			print('1', l2[i])
			f = 1
			break
	if f == 0:
		print('NO')


import sys
inp = sys.stdin.readline

def linp(x):
	return list(map(int, x.split()))

def minp(x):
	return map(int, x.split())

def main():
	for _ in range(int(inp())):
		(n, m) = minp(inp())
		nl = linp(inp())
		ml = linp(inp())
		for i in nl:
			if i in ml:
				print('YES')
				print('1', i)
				break
		else:
			print('NO')
main()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	(a, b) = ([int(x) for x in input().split()], [int(y) for y in input().split()])
	flag = -1
	k = 0
	for i in a:
		for j in b:
			if i == j:
				k = i
				flag = 0
				break
			else:
				continue
	if flag == 0:
		print('YES')
		print(1, k)
	else:
		print('NO')


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt

def solve():
	(n, m) = read()
	a = get_list()
	b = get_list()
	c = list(set(a).intersection(set(b)))
	if len(c) == 0:
		print('NO')
		return
	else:
		print('YES')
	print(min(1, len(c)), *c[:1])
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	x = -1
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


try:
	for _ in range(int(input())):
		(n, m) = map(int, input().split())
		a = set([int(i) for i in input().split()])
		b = set([int(i) for i in input().split()])
		c = list(a & b)
		if len(c) != 0:
			print('YES')
			print(1, c[0])
		else:
			print('NO')
except:
	pass


from sys import stdin
from bisect import bisect_left as bl
from bisect import bisect_right as br

def input():
	return stdin.readline()[:-1]

def intput():
	return int(input())

def sinput():
	return input().split()

def intsput():
	return map(int, sinput())

class RangedList:

	def __init__(self, start, stop, val=0):
		self.shift = 0 - start
		self.start = start
		self.stop = stop
		self.list = [val] * (stop - start)

	def __setitem__(self, key, value):
		self.list[key + self.shift] = value

	def __getitem__(self, key):
		return self.list[key + self.shift]

	def __repr__(self):
		return str(self.list)

	def __iter__(self):
		return iter(self.list)

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
t = intput()
for _ in range(t):
	(n, m) = intsput()
	a = set(intsput())
	b = set(intsput())
	ans = False
	for x in a:
		if x in b:
			ans = True
			break
	if not ans:
		print('NO')
	else:
		print('YES')
		print(1, x)


for case in range(int(input())):
	(n, m) = map(int, input().split())
	N = list(map(int, input().split()))
	M = list(map(int, input().split()))
	for i in N:
		if i in M:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


for i in range(int(input())):
	a = map(int, input())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	ans = []
	flag = 0
	for k in range(len(l)):
		for j in range(len(l1)):
			if l[k] == l1[j]:
				ans.append(l[k])
				flag = -1
				break
		if flag == -1:
			break
	if len(ans) > 0:
		print('YES')
		print(len(ans), *ans)
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	check = 0
	smallest_l = 1
	if n >= m:
		for i in range(len(b)):
			if b[i] in a:
				k = b[i]
				check = 1
				break
	else:
		for i in range(len(a)):
			if a[i] in b:
				k = a[i]
				check = 1
				break
	if check == 0:
		print('NO')
	else:
		print('YES')
		print(smallest_l, k)
	t -= 1


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def multi():
	return map(int, input().split())

def strmulti():
	return map(str, inp().split())

def lis():
	return list(map(int, inp().split()))

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def stringlis():
	return list(map(str, inp().split()))

def out(var):
	sys.stdout.write(str(var))

def printlist(a):
	print(' '.join((str(a[i]) for i in range(len(a)))))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
t = int(inp())
for _ in range(t):
	(n, m) = multi()
	a = lis()
	b = lis()
	ans = -1
	flag = False
	for i in a:
		if i in b:
			flag = True
			ans = i
			break
	if flag:
		print('YES')
		print(1, ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	a.sort()
	b.sort()
	ap = 0
	bp = 0
	found = False
	while ap < n and bp < m:
		if a[ap] == b[bp]:
			found = True
			el = a[ap]
			break
		elif a[ap] < b[bp]:
			ap += 1
		elif a[ap] > b[bp]:
			bp += 1
	if found:
		print('YES')
		print(1, el, sep=' ')
	else:
		print('NO')


from sys import stdin, stdout
test = int(stdin.readline())
for _ in range(test):
	(n, k) = map(int, stdin.readline().split())
	a = [int(x) for x in stdin.readline().split()]
	b = [int(x) for x in stdin.readline().split()]
	ans = False
	for i in a:
		if i in b:
			ans = True
			ind = i
			break
		if ans:
			break
	if ans:
		print('YES')
		print(1, ind)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	sa = set(a)
	sb = set(b)
	c = sa.intersection(sb)
	for i in c:
		ans = i
		break
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print('1', ans)


for _ in range(int(input())):
	(m, l) = map(int, input().split())
	m1 = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	for i in range(m):
		if m1[i] in l1:
			print('YES')
			print(1, m1[i], sep=' ')
			break
		elif i == m - 1:
			print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a.intersection(b)
	if len(c):
		print('YES')
		cnt = 0
		print(1, end=' ')
		for j in a:
			if j in b:
				print(j, end=' ')
				print()
				break
	else:
		print('NO')


for l in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	c = []
	am = 0
	j1 = 0
	for i in range(n):
		for j in range(j1, m):
			if a[i] == b[j]:
				c.append(a[i])
				j1 += 1
				am = 1
				break
			elif a[i] < b[j]:
				break
			else:
				j1 += 1
		if am == 1:
			break
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print(1, c[0])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = {*map(int, input().split())}
	s &= {*map(int, input().split())}
	if s:
		print('YES\n1', s.pop())
	else:
		print('NO')


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


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	put = input()
	counts = dict()
	for i in range(n):
		counts[put.split()[i]] = counts.get(put.split()[i], 0) + 1
	put = input()
	flag = 1
	for i in range(m):
		if put.split()[i] in counts:
			flag = 0
			print('YES')
			print(1, put.split()[i])
			break
	if flag == 1:
		print('NO')


T = int(input())
for test in range(T):
	input()
	a = set([int(u) for u in input().split()])
	b = set([int(u) for u in input().split()])
	u = a.intersection(b)
	if len(u) == 0:
		print('NO')
	else:
		print('YES')
		for i in u:
			print(1, i)
			break


def sub():
	(N, M) = input().split()
	N = int(N)
	M = int(M)
	a1 = [int(i) for i in input().split()][:N]
	b1 = [int(i) for i in input().split()][:M]
	a1.sort()
	for i in a1:
		for j in b1:
			if i == j:
				print('YES')
				return print('1 {}'.format(i))
	return print('NO')
testcase = int(input())
for k in range(testcase):
	sub()


t = int(input())
while t > 0:
	(n, m) = map(int, input().strip().split())
	l1 = list(map(int, input().strip().split()))
	l2 = list(map(int, input().strip().split()))
	l3 = []
	count = 0
	for i in l1:
		for j in l2:
			if i == j:
				l3.append(i)
				count += 1
	if count == 0:
		print('NO')
	elif count >= 1:
		print('YES')
		print('1', l3[0])
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = list(map(int, input().split()))
	m = list(map(int, input().split()))
	p = 1
	for i in range(n):
		if s[i] in m:
			p = 0
			print('YES')
			print(1, s[i])
			break
	if p == 1:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	e = -1
	for i in range(n):
		if a[i] in b:
			e = a[i]
			break
	if e == -1:
		print('NO')
	else:
		print('YES')
		print(1, e)


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])


def go(a, b):
	for i in a:
		for j in b:
			if i == j:
				print('YES')
				print(1, i)
				return
			if i < j:
				break
	print('NO')
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	go(a, b)


test = int(input())
result = []
for t in range(test):
	arrLen = [int(length) for length in input().split()]
	a = [int(A) for A in input().split()]
	b = [int(B) for B in input().split()]
	c = -1
	for n in range(len(a)):
		if a[n] in b:
			c = a[n]
	if c == -1:
		result.append('NO')
	else:
		result.append('YES')
		result.append('1 ' + str(c))
for m in range(len(result)):
	print(result[m])


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		(n, m) = [int(x) for x in input().split()]
		set_a = set([int(x) for x in input().split()])
		set_b = set([int(x) for x in input().split()])
		possible = False
		ans = -1
		for x in set_a:
			if x in set_b:
				possible = True
				ans = x
				break
		if possible:
			print('YES')
			print(1, x)
		else:
			print('NO')
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


def f(a, b):
	l = []
	for i in a:
		if i in b:
			l.append(i)
	if l == []:
		print('NO')
		return
	print('YES')
	print('1 ' + str(min(l)))
for _ in range(int(input())):
	input()
	f([int(x) for x in input().split()], [int(x) for x in input().split()])


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	(n, m) = ip()
	x = ip()
	y = ip()
	dt = {}
	for i in x:
		dt[i] = dt.get(i, 0) + 1
	flag = 0
	ans = -1
	for i in y:
		if dt.get(i, 0):
			ans = i
			flag = 1
			break
	if flag:
		print('YES')
		print(1, ans)
	else:
		print('NO')


from collections import *
for u in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	d = list(map(int, input().split()))
	dd = defaultdict(int)
	for i in l:
		dd[i] += 1
	f = 0
	for i in range(m):
		if dd[d[i]] > 0:
			x = d[i]
			f = 1
			break
	if f == 1:
		print('YES')
		print(1, x)
	else:
		print('NO')


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return set(map(int, sys.stdin.readline().strip().split()))
t = int(input())
for x in range(t):
	(n, m) = get_ints()
	a = get_list()
	b = get_list()
	inter = a.intersection(b)
	if len(inter) > 0:
		print('YES')
		print('1 %d' % inter.pop())
	else:
		print('NO')


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


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	a = [int(num) for num in input().split(' ', n - 1)]
	b = [int(num) for num in input().split(' ', m - 1)]
	flag = 0
	for k in a:
		if k in b:
			flag = 1
			print('YES')
			print(1, k)
			break
	if flag == 0:
		print('NO')


for i in range(int(input())):
	l = []
	p = 0
	a1 = []
	b1 = []
	s = ''
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	q = set(a)
	r = set(b)
	z = q.intersection(r)
	u = list(z)
	c = len(z)
	if c == 0:
		print('NO')
	else:
		print('YES')
		print('1', u[0])


for i in range(int(input())):
	(a, b) = map(int, input().split(' '))
	s1 = list(map(int, input().split(' ')))
	s2 = list(map(int, input().split(' ')))
	for each in s1:
		if each in s2:
			print('YES')
			print(1, each)
			break
	else:
		print('NO')


for testcases in range(int(input())):
	(n, m) = map(int, input().split())
	ar = list(map(int, input().split()))
	br = list(map(int, input().split()))
	flag = 0
	ans = 0
	for i in ar:
		for j in br:
			if i == j:
				ans = i
				flag = 1
				break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


from collections import defaultdict
for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	d = defaultdict(int)
	for i in brr:
		d[i] = 1
	x = -1
	for i in arr:
		if d[i] == 1:
			x = i
	if x == -1:
		print('NO')
	else:
		print('YES')
		print(1, x)


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	y = False
	for i in a:
		for j in b:
			if i == j:
				x = i
				y = True
				break
		if y == True:
			break
	if y == True:
		print('Yes')
		print('1 ' + str(x))
	else:
		print('No')


def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	res = intersection(a, b)
	k = 1
	if len(res) >= 1:
		print('YES')
		print(k, res[0])
	else:
		print('NO')


test = int(input())
for t in range(test):
	lis = input().split()
	a = int(lis[0])
	b = int(lis[1])
	arr = input().split()
	brr = input().split()
	dic1 = {}
	dic2 = {}
	for i in arr:
		if i not in dic1:
			dic1[i] = 1
		else:
			dic1[i] += 1
	for i in brr:
		if i not in dic2:
			dic2[i] = 1
		else:
			dic2[i] += 1
	flag = 0
	for i in dic1:
		if i in dic2:
			print('YES')
			print('1', end=' ')
			print(i)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())

def common(l, l1):
	for i in l:
		if i in l1:
			return (True, i)
	return (False, -1)
for i in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	(a, x) = common(l, l1)
	if a:
		print('YES')
		print(1, x)
	else:
		print('NO')


import sys
infile = sys.stdin
next(infile)
for line in infile:
	len = list(map(int, line.split()))
	n = len[0]
	m = len[1]
	a = list(map(int, infile.readline().split()))
	b = list(map(int, infile.readline().split()))
	k = []
	q = 0
	for ai in a:
		for bi in b:
			if ai == bi:
				k.append(ai)
				q += 1
	if q != 0:
		print('YES')
		print('1 ' + str(k[0]))
	else:
		print('NO')


a = int(input())
for i in range(a):
	(l, r) = map(int, input().split())
	s1 = set(map(int, input().split()))
	s2 = set(map(int, input().split()))
	s3 = s1.intersection(s2)
	if len(s3) != 0:
		print('Yes')
		print(1, min(s3))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	l = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = 0
	for i in a:
		for j in b:
			if i == j:
				ans = i
			if ans > 0:
				break
		if ans > 0:
			break
	if ans:
		print('Yes')
		print(1, ans)
	else:
		print('No')


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()))
	ans = 'NO'
	for j in a:
		if j in b:
			ans = 'YES'
			k = j
			break
	print(ans)
	if ans == 'YES':
		print(1, k)


for i in range(int(input())):
	a = list(map(int, input().strip().split()))[:2]
	b = list(map(int, input().strip().split()))[:a[0]]
	c = list(map(int, input().strip().split()))[:a[1]]
	e = set(b)
	f = set(c)
	g = list(e.intersection(f))
	if len(g) != 0:
		print('YES')
		print(str(1) + ' ' + str(g[0]))
	else:
		print('NO')


import array as arr
test = int(input())
q = 0
while q < test:
	q += 1
	(k, l) = map(int, input().split())
	m = list(map(int, input().split()[:k]))
	n = list(map(int, input().split()[:l]))
	ans = 0
	for i in m:
		if i in n:
			ans = i
			break
	if ans:
		print('YES')
		print(1, ans)
	else:
		print('NO')
q += 1


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, m) = LI()
		a = LI()
		b = LI()
		c = set(a) & set(b)
		if len(c) == 0:
			rr.append('NO')
		else:
			rr.append('YES')
			rr.append(JA([1, list(c)[0]], ' '))
	return JA(rr, '\n')
print(main())


n = int(input())
for i in range(n):
	list1 = []
	(m, n) = [int(x) for x in input().split()]
	x = [int(x) for x in input().split()]
	y = [int(y) for y in input().split()]
	for ele1 in x:
		for ele2 in y:
			if ele1 == ele2:
				list1.append(ele1)
	if len(list1) != 0:
		print('YES')
		if len(list1) > 1:
			try:
				if x == y:
					list1.remove(1)
			except Exception:
				pass
		print(1, min(list1))
	else:
		print('NO')


for c in range(0, int(input())):
	(n, m) = input().split(' ')
	n = int(n)
	m = int(m)
	a = input().split(' ')
	b = input().split(' ')
	d = -1
	f = 0
	while d < n - 1:
		if f == 1:
			break
		e = -1
		d = d + 1
		a[d] = int(a[d])
		while e < m - 1:
			e = e + 1
			b[e] = int(b[e])
			if a[d] == b[e]:
				print('YES')
				print(1, a[d])
				f = f + 1
				break
	if f == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	fl = 0
	ans = 0
	for i in a:
		if i in b:
			fl = 1
			ans = i
			break
	if fl:
		print('YES')
		print(1, ans)
	else:
		print('NO')


tests = int(input())
i = 0
while i < tests:
	lengths = input().split()
	a = set(input().split())
	b = input().split()
	found = False
	for number in b:
		if number in a:
			found = True
			print('YES')
			print(1, number)
			break
	if not found:
		print('NO')
	i += 1


def sub_sequence_numbers(n, m, list_an, list_am):
	no = 0
	if n <= m:
		for i in list_an:
			if i in list_am:
				print('YES')
				print(1, i)
				no = 1
				break
		if no == 0:
			print('NO')
	else:
		for j in list_am:
			if j in list_an:
				print('YES')
				print(1, j)
				no = 1
				break
		if no == 0:
			print('NO')
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	list_an = list(map(int, input().split()))
	list_am = list(map(int, input().split()))
	sub_sequence_numbers(n, m, list_an, list_am)


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	da = Counter(a)
	db = Counter(b)
	f = 0
	ans = 0
	if min(n, m) == n:
		d1 = da
		d2 = db
	else:
		d1 = db
		d2 = da
	for i in d1:
		if d2[i] >= 1:
			f = 1
			ans = i
			break
	if f == 1:
		print('YES')
		print(f'1 {ans}')
	else:
		print('NO')


import sys
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()
for _ in range(INT()):
	(n, m) = MAP()
	arr = ARR()
	brr = ARR()
	c = {}
	if n > m:
		(arr, brr) = (brr, arr)
	for i in arr:
		c[i] = 0
	for i in brr:
		if i in c:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	lst = list(map(int, input().split()))
	arr = list(map(int, input().split()))
	op = []
	count = 0
	if n <= m:
		for i in range(n):
			if lst[i] in arr:
				op.append(lst[i])
				count += 1
			if count == 1:
				break
	else:
		for i in range(m):
			if arr[i] in lst:
				op.append(arr[i])
				count += 1
			if count == 1:
				break
	if op == []:
		print('NO')
	else:
		print('YES')
		print(count, *op)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	mark = 0
	for i in x:
		if i in y:
			print('YES')
			print(1, i)
			mark = 1
			break
	if mark == 0:
		print('NO')


from sys import stdin, stdout
from sys import maxsize
input = stdin.readline

def solve():
	pass
test = 1
test = int(input().strip())
for t in range(0, test):
	(n, k) = list(map(int, input().strip().split()))
	a = [int(x) for x in input().strip().split()]
	b = [int(x) for x in input().strip().split()]
	a = set(a)
	b = set(b)
	x = a.intersection(b)
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		x = list(x)
		print(1, x[0])
	ans = solve()


t = int(input())
for test_cases in range(t):
	(m, n) = input().split(' ')
	m_list = input().split(' ')
	n_list = input().split(' ')
	common_list = set(m_list).intersection(n_list)
	if len(common_list) > 0:
		print('YES')
		print(1, list(common_list)[0])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n1, n2) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	found = False
	if n1 >= n2:
		for i in arr1:
			if i in arr2:
				print('YES')
				print(1, i)
				found = True
				break
	else:
		for i in arr2:
			if i in arr1:
				print('YES')
				print(1, i)
				found = True
				break
	if not found:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = input().split()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	g = {}
	c = 1000
	f = 0
	for x in a:
		if x in b:
			print('YES')
			f = 1
			print(1, end=' ')
			print(x)
			break
	if f != 1:
		print('NO')


t = int(input())
for i in range(t):
	first = [int(s) for s in input().split(' ')]
	n = first[0]
	m = first[1]
	a = [int(s) for s in input().split(' ')]
	b = [int(s) for s in input().split(' ')]
	dct_a = {}
	for i in a:
		try:
			if dct_a[i] == 1:
				dct_a[i] += 1
		except KeyError:
			dct_a[i] = 1
	ok = 0
	for i in b:
		try:
			if dct_a[i] > 0:
				print('YES')
				print('1' + ' ' + str(i))
				ok = 1
				break
		except KeyError:
			dct_a[i] = -1
	if ok == 0:
		print('NO')


production = True
import sys, math, collections

def input(input_format=0, multi=0):
	if multi > 0:
		return [input(input_format) for i in range(multi)]
	else:
		next_line = sys.stdin.readline()[:-1]
		if input_format >= 10:
			use_list = False
			input_format = int(str(input_format)[-1])
		else:
			use_list = True
		if input_format == 0:
			formatted_input = [next_line]
		elif input_format == 1:
			formatted_input = list(map(int, next_line.split()))
		elif input_format == 2:
			formatted_input = list(map(float, next_line.split()))
		elif input_format == 3:
			formatted_input = list(next_line)
		elif input_format == 4:
			formatted_input = list(map(int, list(next_line)))
		elif input_format == 5:
			formatted_input = next_line.split()
		else:
			formatted_input = [next_line]
		return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format=0, newline=True):
	formatted_output = ''
	if output_format == 0:
		formatted_output = str(output_line)
	elif output_format == 1:
		formatted_output = ' '.join(map(str, output_line))
	elif output_format == 2:
		formatted_output = '\n'.join(map(str, output_line))
	print(formatted_output, end='\n' if newline else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)

def mapl(iterable, format=0):
	if format == 0:
		return list(map(int, iterable))
	elif format == 1:
		return list(map(str, iterable))
	elif format == 2:
		return list(map(list, iterable))

def solve():
	(n, m) = input(1)
	a = input(1)
	b = input(1)
	y = set(a)
	for i in b:
		if i in y:
			out('YES')
			out(f'1 {i}')
			return
	else:
		out('NO')
	return
for i in range(input(11)):
	solve()


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	la = [int(i) for i in input().split()]
	lb = [int(i) for i in input().split()]
	cnt = None
	for i in la:
		if i in lb:
			cnt = i
			break
	if cnt == None:
		print('NO')
	else:
		print('YES')
		print(1, cnt)


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	r = list(map(int, input().split()))
	s = list(map(int, input().split()))

	def func(r, s):
		if len(r) <= len(s):
			for i in r:
				if i in s:
					print('YES')
					return str(1) + ' ' + str(i)
		elif len(r) > len(s):
			for i in s:
				if i in r:
					print('YES')
					return str(1) + ' ' + str(i)
		return 'NO'
	print(func(r, s))


def solve():
	(n, m) = (int(_x) for _x in input().strip().split())
	a = [int(_x) for _x in input().strip().split()]
	b = [int(_x) for _x in input().strip().split()]
	for el in a:
		if el in b:
			print('YES')
			print(1, el)
			return
	print('NO')
for _t in range(int(input())):
	solve()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	k = 'NO'
	l = 0
	for i in c:
		for j in d:
			if i == j:
				k = 'YES'
				l = i
				break
		if k == 'YES':
			break
	if k == 'YES':
		print(k)
		print(1, l)
	else:
		print(k)


for i in [0] * int(input()):
	f = 1
	input()
	l = input().split()
	l1 = input().split()
	for x in l:
		if x in l1:
			print('YES')
			print('1 ' + x)
			f = 0
			break
	if f == 1:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if len(a) < len(b):
		(A, B) = (a, b)
	else:
		(A, B) = (b, a)
		(n, m) = (m, n)
	value = 0
	flag = 'NO'
	for i in A:
		if i in B:
			flag = 'YES'
			value = i
			break
	print(flag)
	if flag == 'YES':
		print(1, value)


def solve():
	(n, m) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	for i in range(n):
		if lst1[i] in lst2:
			print('YES')
			print(1, lst1[i])
			return
	print('NO')
t = int(input())
for i in range(t):
	solve()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1 = set(l1)
	l2 = set(l2)
	l3 = l1 & l2
	l3 = list(l3)
	if len(l3) != 0:
		print('YES')
		print(1, l3[0])
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	(N, M) = map(int, input().split())
	list1 = list(map(int, input().split()))
	list2 = list(map(int, input().split()))
	mp = set()
	c = 0
	e = 0
	for i in range(0, N):
		mp.add(list1[i])
	for i in range(0, M):
		if list2[i] in mp:
			c = c + 1
			e = list2[i]
			break
	if c == 0:
		print('NO')
	else:
		print('YES')
		print(c, end=' ')
		print(e)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = set(a)
	d = set(b)
	e = c.intersection(d)
	if len(e) == 0:
		print('NO')
	else:
		print('YES')
		print(1, e.pop())


def main():

	def find():
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		for i in a:
			for j in b:
				if i == j:
					print('YES')
					print(1, i)
					return
		print('NO')
	t = int(input())
	for _ in range(t):
		find()
main()


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	A = set([int(s) for s in input().split()])
	B = set([int(s) for s in input().split()])
	C = A.intersection(B)
	if C != set():
		print('YES')
		print(1, C.pop())
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	vis = [0 for i in range(1001)]
	for i in a:
		vis[i] = 1
	flg = False
	for j in b:
		if vis[j]:
			flg = True
			break
	if flg:
		print('YES')
		print(1, j)
	else:
		print('NO')


def intersection(lst1, lst2):
	return list(set(lst1) & set(lst2))
for x in range(int(input())):
	a = list(map(int, input().split()))
	n1 = a[0]
	n2 = a[-1]
	b = list(map(int, input().split()))
	c = list(map(int, input().split()))
	d = intersection(b, c)
	d.sort()
	if len(d) > 0:
		print('YES')
		print(1, str(d[0]))
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	buckets = {}
	for i in a:
		if i in buckets:
			buckets[i] += 1
		else:
			buckets[i] = 1
	found = False
	ans = 0
	for i in b:
		if i in buckets:
			ans = i
			found = True
			break
	if found:
		print('YES')
		print(1, ans)
	else:
		print('NO')


n = int(input())
for i in range(n):
	l = [int(p) for p in input().split(' ')]
	a = set([int(p) for p in input().split(' ')])
	b = set([int(p) for p in input().split(' ')])
	intersection = a.intersection(b)
	if len(intersection) > 0:
		print('YES')
		print(1, intersection.pop())
	else:
		print('NO')


t = int(input())
while t:
	(n, m) = map(int, input().split())
	a = [i for i in input().split()]
	b = [i for i in input().split()]
	k = -1
	for i in range(n):
		found = False
		for j in range(m):
			if a[i] == b[j]:
				k = a[i]
				found = True
				break
		if found:
			break
	if k != -1:
		print('YES')
		print(1, k)
	else:
		print('NO')
	t -= 1


from collections import Counter
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	l = Counter(l)
	m = Counter(m)
	f = 1
	for i in l:
		if i in m:
			print('YES')
			print(1, i, end=' ')
			f = 0
			print()
			break
	if f:
		print('NO')


t = int(input())
for i in range(t):
	f = 0
	(n, m) = map(int, input().split())
	n1 = list(map(int, input().split()))
	n2 = list(map(int, input().split()))
	for j in range(n):
		if n1[j] in n2:
			print('YES')
			print(1, n1[j])
			f = 1
			break
			f = 0
	if f == 0:
		print('NO')


from __future__ import division, print_function
import itertools, os, sys, threading
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from math import gcd
from bisect import bisect
from random import randrange
input = lambda : sys.stdin.readline().rstrip('\r\n')
read = lambda : list(map(int, input().strip().split(' ')))

def main():
	for _ in range(int(input())):
		(n, m) = read()
		a = read()
		b = read()
		b.sort()
		flag = 1
		for i in a:
			ind = bisect(b, i) - 1
			if b[ind] == i:
				print('YES')
				print(1, b[ind])
				flag = 0
				break
		if flag:
			print('NO')
main()


for __ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	x = -1
	ar1 = set(ar1)
	ar2 = set(ar2)
	lol = ar1.intersection(ar2)
	if len(lol) == 0:
		print('NO')
	else:
		print('YES')
		x = 0
		for elem in lol:
			x = elem
		print(1, x)


t = int(input())
cases = []
for i in range(t):
	line = input().split()
	n = int(line[0])
	m = int(line[1])
	a = [int(item) for item in input().split()]
	b = [int(item) for item in input().split()]
	case = [a, b]
	cases.append(case)
for case in cases:
	a = case[0]
	b = case[1]
	a = list(set(a))
	b = list(set(b))
	for num in a:
		if num in b:
			print('YES')
			print(f'1 {num}')
			break
	else:
		print('NO')


for tc in range(int(input())):
	(n, m) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	count = 0
	for x in lst2:
		if x in lst1:
			count = 1
			print('YES')
			print(1, x)
			break
	if count == 0:
		print('NO')


from sys import *
input = stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	p = set(p)
	q = set(q)
	l = p.intersection(q)
	l = list(l)
	if l == []:
		print('NO')
	else:
		print('YES')
		print(1, l[0])


t = int(input())
for _ in range(0, t):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	a = 9999
	for i in A:
		for j in B:
			if i == j:
				a = i
				break
	if a == 9999:
		print('No')
	else:
		print('Yes')
		print(1, a)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = [0] * 1001
	d = [0] * 1001
	for x in a:
		c[x] = 1
	for x in b:
		d[x] = 1
	for i in range(1000 + 1):
		if c[i] & d[i]:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


def commonSeq(a, b):
	for i in a:
		for j in b:
			if i == j:
				print('YES')
				print(str(1) + ' ' + str(i))
				return
	print('NO')
	return
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	commonSeq(a, b)


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n
avl = AvlTree()

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] <= key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	(n, m) = map(int, input().split())
	l = set(map(int, input().split()))
	l1 = set(map(int, input().split()))
	l2 = set()
	for j in l:
		if j in l1:
			l2.add(j)
	if len(l2) == 0:
		print('NO')
	else:
		print('YES', 1, min(l2))


input = __import__('sys').stdin.readline
for _ in range(int(input())):
	input()
	ans = set(map(int, input().split())) & set(map(int, input().split()))
	if ans:
		print('YES')
		print(1, ans.pop())
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = []
	b = []
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arr = []
	if n >= m:
		for i in a:
			if i in b:
				if i not in arr:
					arr.append(i)
					if len(arr) >= 1:
						break
	else:
		for i in b:
			if i in a:
				if i not in arr:
					arr.append(i)
					if len(arr) >= 1:
						break
	if len(arr) == 0:
		print('NO')
	else:
		print('YES')
		ans = map(str, arr)
		print(str(len(arr)) + ' ' + ' '.join(ans))


def ans():
	set_a = set(a)
	set_b = set(b)
	if set_a & set_b:
		print('YES')
		f = list(set_a & set_b)
		print(1, f[0])
	else:
		print('NO')
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()))
	ans()


import sys, math, cmath, time
start_time = time.time()

def solve():
	(n, m) = invr()
	a = inlt()
	b = inlt()
	if set(a) & set(b):
		print('YES')
		print(1, list(set(a) & set(b))[0])
	else:
		print('NO')

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


t = int(input())
while t > 0:
	t = t - 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	k = 0
	l = []
	for i in range(len(a)):
		if a[i] in b[:]:
			c = b.index(a[i])
			b = b[c:]
			k += 1
			l.append(a[i])
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(1, min(l))


def intersection(lst1, lst2):
	return list(set(lst1) & set(lst2))
t = int(input())
while t != 0:
	(n, m) = map(int, input().split(' '))
	arr1 = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	res = intersection(arr1, arr2)
	if len(res) > 0:
		print('YES')
		print(1, res[0])
	else:
		print('NO')
	t -= 1


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	x = [i for i in input().split()]
	z = [i for i in input().split()]
	a = set(x)
	b = set(z)
	d = list(a & b)
	if d:
		print('YES')
		print('1', ' ', d[0])
	else:
		print('NO')


import collections
t = int(input())
for q in range(0, t):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	d1 = collections.Counter(a)
	d2 = collections.Counter(b)
	flag = 'NO'
	index = -1
	for i in d1:
		if d2[i] != 0:
			flag = 'YES'
			index = i
	print(flag)
	if index != -1:
		print(1, index)


tc = int(input())
while tc:
	tc -= 1
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	mark = [False for i in range(1001)]
	for x in a:
		mark[x] = True
	b = list(map(int, input().strip().split()))
	found = False
	for x in b:
		if mark[x]:
			print('YES\n1 ' + str(x))
			found = True
			break
	if not found:
		print('No\n')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = set([int(i) for i in input().split()])
	b = [int(i) for i in input().split()]
	found = False
	for b_i in b:
		if b_i in a:
			print('YES')
			print(1, b_i)
			found = True
			break
	if not found:
		print('NO')


t = int(input())
for p in range(t):
	(n, m) = map(int, input().strip().split())
	ara1 = list(map(int, input().strip().split()))
	ara2 = list(map(int, input().strip().split()))
	flag = 0
	ans = 0
	for i in range(n):
		for j in range(m):
			if ara1[i] == ara2[j]:
				flag = 1
				ans = ara2[j]
				break
	if flag == 1:
		print('YES')
		print('1 ' + str(ans))
	else:
		print('NO')


t = int(input())
for u in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				print('YES')
				print(1, a[i])
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	flag = 0
	a.sort()
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for q in range(t):
	(m, n) = map(int, input().strip().split()[:2])
	l1 = list(map(int, input().strip().split()[:m]))
	l2 = list(map(int, input().strip().split()[:n]))
	l1.sort()
	m = 0
	f = 0
	for i in l1:
		if i in l2:
			m = i
			f = 1
			break
	if f == 1:
		print('YES')
		print(1, m)
	else:
		print('NO')


from collections import deque
import sys

def inp():
	return sys.stdin.readline().strip()
for _ in range(int(inp())):
	(n, m) = map(int, inp().split())
	a = set(sorted(map(int, inp().split())))
	b = set(sorted(map(int, inp().split())))
	s = a & b
	s = sorted(s)
	if s:
		print('YES')
		print(1, s[0])
	else:
		print('NO')


from math import ceil
from sys import stdin, stdout, setrecursionlimit
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	c = True
	for x in a:
		if x in b:
			print('YES')
			print(1, x)
			c = False
			break
	if c:
		print('NO')


for _ in range(int(input())):
	y = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	flag = 0
	for i in arr1:
		if i in arr2:
			flag = 1
			print('YES')
			print(1, i)
			break
	if flag == 0:
		print('NO')


for cases in range(int(input())):
	(n, m) = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	count = 0
	for i in range(n - 1, -1, -1):
		if lst1[i] in lst2:
			count = lst1[i]
			print('YES')
			print('1', count)
			break
		elif i == 0:
			print('NO')
			break
		else:
			continue


def main():
	t = int(input())
	for __ in range(t):
		n = input()
		a = set(map(int, input().split()))
		b = set(map(int, input().split()))
		c = a.intersection(b)
		if len(c) >= 1:
			print('YES')
			print(1, list(c)[0])
		else:
			print('NO')
main()


import math
t = int(input())
while t > 0:
	t -= 1
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def solution():
	for i in range(Int()):
		(n, m) = Mint()
		a = List()
		b = List()
		p = 0
		for i in range(m):
			if b[i] in a:
				ans = b[i]
				p = 1
				break
		if p == 1:
			print('YES')
			print(1, ans)
		else:
			print('NO')
solution()


for t in range(int(input())):
	(n, m) = map(int, input().split())
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	flag = False
	for a in A:
		if a in B:
			print('YES')
			print(1, a)
			flag = True
			break
	if flag:
		continue
	print('NO')


import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def get_str():
	return input().decode().strip()

def rint():
	return map(int, input().split())

def oint():
	return int(input())
t = oint()
for _ in range(t):
	(n, m) = rint()
	a = set(rint())
	b = set(rint())
	c = a & b
	if c:
		print('YES')
		print(1, list(c)[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = True
	for i in a:
		if i in set(b):
			print('YES')
			print(1, i)
			ans = False
			break
	if ans:
		print('NO')


t = input()
t = int(t)
while t > 0:
	(n, m) = input().split()
	(n, m) = (int(n), int(m))
	a = list(map(int, input().strip().split()))[:n]
	b = list(map(int, input().strip().split()))[:m]
	common = set(a)
	intersection = common.intersection(b)
	ans = list(intersection)
	if len(ans) > 0:
		print('YES')
		print('1' + ' ' + str(ans[0]))
	else:
		print('NO')
	t -= 1


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = True
	for i in a:
		if i in b:
			print('YES', '\n1', i)
			x = False
			break
	if x == True:
		print('NO')


q = int(input())
for i in range(q):
	d = []
	(a, b) = input().split(' ')
	m = list(map(int, input().split()))
	z = list(map(int, input().split()))
	for j in range(len(m)):
		for k in range(len(z)):
			if m[j] == z[k]:
				d.append(m[j])
	if len(d) == 0:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(d[0])


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	count = 0
	for i in range(len(arr1)):
		for j in range(len(arr2)):
			if arr1[i] == arr2[j]:
				count = 1
				a = arr1[i]
				break
	if count >= 1:
		print('YES')
		print(count, a)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = list(map(int, input().split()))
	a1 = list(map(int, input().split()))
	f = 0
	for i in range(0, k):
		if a1[i] in a:
			j = a1[i]
			f = 1
	if f == 0:
		print('NO')
	else:
		print('YES')
		print(1, j)


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, m) = map(int, stdin.readline().split())
	a = set(map(int, stdin.readline().split()))
	b = set(map(int, stdin.readline().split()))
	x = a.intersection(b)
	if len(x):
		print('YES')
		print(1, x.pop())
	else:
		print('NO')


def main(n, m, a, b):
	index = 0
	l = [1]
	while index < n:
		if a[index] in b:
			l.append(a[index])
			print('YES')
			print(*l)
			return
		index = index + 1
	print('NO')
t = int(input())
for t_itr in range(t):
	nm = list(map(int, input().rstrip().split()))
	n = nm[0]
	m = nm[1]
	a = list(map(int, input().rstrip().split()))
	b = list(map(int, input().rstrip().split()))
	res = main(n, m, a, b)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	ans = -1
	for i in range(len(l1)):
		for j in range(len(l2)):
			if l1[i] == l2[j]:
				ans = l1[i]
				break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	str1 = [int(x) for x in input().split()]
	str2 = [int(x) for x in input().split()]
	flag = True
	for num in str1:
		if num in str2:
			print('YES')
			print(1, num)
			flag = False
			break
	if flag:
		print('NO')


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(N, M) = map(int, input().split())
		A = set(map(int, input().split()))
		B = set(map(int, input().split()))
		ans = list(A & B)
		if ans:
			print('YES')
			print(1, ans[0])
		else:
			print('NO')
main()


test = int(input())
for _ in range(test):
	(n, m) = map(int, input().split())
	f = 0
	l = [int(n) for n in input().split()]
	z = [int(n) for n in input().split()]
	ans = l + z
	for i in z:
		if i in l and i in z:
			print('YES')
			print(1, i)
			f = 1
			break
	if f == 0:
		print('NO')


for _ in range(int(input())):
	count = 0
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a_set = set(a)
	b_set = set(b)
	if a_set & b_set:
		count += 1
	else:
		print('NO')
	lst3 = [value for value in a if value in b]
	if len(lst3) > 1:
		print('YES')
		print('1', lst3[0])
	elif len(lst3) == 1:
		print('YES')
		print(len(lst3), *lst3)


t = int(input())
for _ in range(t):
	ip = list(map(int, input().split()))
	n = ip[0]
	m = ip[1]
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	f = 0
	for i in l1:
		if i in l2:
			f = 1
			print('YES')
			print('1', end=' ')
			print(i)
			break
	if f == 0:
		print('NO')


t = int(input())
for z in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	temp = -1
	for i in range(n):
		for j in range(m):
			if arr1[i] == arr2[j]:
				temp = arr1[i]
				break
	if temp > 0:
		print('YES')
		print('1', temp)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for j in range(len(a)):
		if a[j] in b:
			c.append(a[j])
			break
	if c == []:
		print('NO')
	else:
		print('YES')
		print(len(c), *c)


t = int(input())
for _ in range(t):
	(n, m) = list(map(lambda x: int(x), input().split()))
	a = list(map(lambda x: int(x), input().split()))
	b = list(map(lambda x: int(x), input().split()))
	a_set = set()
	for i in a:
		a_set.add(i)
	flag = 0
	for i in b:
		if i in a_set:
			print('YES')
			print(1, i)
			flag = 1
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	sa = set()
	sb = set()
	for i in range(0, n):
		sa.add(a[i])
	for j in range(0, m):
		sb.add(b[j])
	if len(sa & sb) != 0:
		print('YES')
		print('1', end=' ')
		for i in sa & sb:
			print(i)
			break
	elif len(sa & sb) == 0:
		print('NO')


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, n1) = map(int, stdin.readline().split())
	a = set(map(int, stdin.readline().split()))
	b = set(map(int, stdin.readline().split()))
	ans = sorted(a & b)
	if not ans:
		print('NO')
	else:
		print('YES')
		print(1, ans[0])


for t in range(int(input())):
	(m, n) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	dic = dict()
	for xx in x:
		dic[xx] = 0
	f = False
	for yy in y:
		if yy in dic:
			f = True
			print('YES')
			print(1, yy)
			break
	if not f:
		print('NO')


for _ in range(int(input())):
	input()
	d1 = set(map(int, input().split()))
	d2 = set(map(int, input().split()))
	d = d1 & d2
	if d:
		print('YES')
		print('1', list(d)[0])
	else:
		print('NO')


def intersection(lst1, lst2):
	return list(set(lst1) & set(lst2))
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	x = intersection(lst1, lst2)
	if len(x) == 0:
		print('NO')
	else:
		print('YES')
		print('1', x[0])


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))[:n]
	b = list(map(int, input().split()))[:m]
	c = 0
	f = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				c = a[i]
				f = 1
				break
	if f == 1:
		print('YES')
		print(1, c)
	else:
		print('NO')


import math

def sumofno(n):
	summ = 0
	while n > 0:
		summ += n % 10
		n //= 10
	return summ

def get_key(val, lis):
	for (key, value) in lis.items():
		if value == val:
			return key
try:
	t = int(input())
	ans = []
	for i in range(t):
		(n, m) = input().split()
		n = int(n)
		m = int(m)
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		aset = set(a)
		bset = set(b)
		if len(aset.intersection(bset)):
			c = aset.intersection(bset)
			c = list(c)
			ans.append('YES')
			ans.append(str(1) + ' ' + str(c[0]))
		else:
			ans.append('NO')
	for an in ans:
		print(an)
except:
	pass


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def solve():
	(n, m) = li()
	a = li()
	b = li()
	c = Counter(a)
	d = Counter(b)
	for i in c:
		if i in d:
			print('YES')
			print(1, i)
			return
	print('NO')
for _ in range(I()):
	solve()


t = int(input())
for _ in range(t):
	input()
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	p = False
	for i in a:
		if i in b:
			p = True
			print('YES\n1 ' + str(i))
			break
	if not p:
		print('NO')


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	(N, M) = neo()
	A = Neo()
	B = Neo()
	f = 0
	Ans = 0
	for i in A:
		for j in B:
			if i == j:
				f = 1
				Ans = i
				break
		if f == 1:
			break
	if f == 1:
		print('YES')
		print(1, Ans)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	count = 0
	c = []
	for i in arr1[:]:
		if i in arr2:
			c.append(i)
			count += 1
	if count > 0:
		print('YES')
		print('1', min(c))
	else:
		print('NO')


def solve(a_array, b_array):
	for a_element in a_array:
		for b_element in b_array:
			if a_element == b_element:
				print('YES\n' + '1 ' + a_element)
				return
	print('NO')
test_cases = int(input())
for case in range(test_cases):
	input()
	a_array = input().split(' ')
	b_array = input().split(' ')
	solve(a_array, b_array)


t = int(input())

def fun(n, a, b):
	ans = 0
	for i in range(n):
		if b.count(a[i]) != 0:
			ans = a[i]
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)
while t:
	t -= 1
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	fun(n, a, b)


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split(' '))
	List_1 = [int(j) for j in input().split(' ')]
	List_2 = [int(j) for j in input().split(' ')]
	c = 0
	for i in range(n):
		if List_1[i] in List_2:
			c += 1
			k = i
			break
	if c == 0:
		print('NO')
	else:
		print('YES')
		print('1', end=' ')
		print(List_1[k])


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = set(a)
	d = set(b)
	e = list(c & d)
	if len(e) > 0:
		print('YES')
		print(1, e[0])
	else:
		print('NO')


def call():
	(n, m) = map(int, input().split())
	l = [int(x) for x in input().split()]
	k = [int(x) for x in input().split()]
	for i in l:
		if i in k:
			print('YES')
			print(1, i)
			return
	print('NO')
for _ in range(int(input())):
	call()


def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l3 = intersection(l1, l2)
	if len(l3) == 0:
		print('NO')
	else:
		print('YES')
		print(1, l3[0])


def f(a, b):
	for i in a:
		if i in b:
			return i
	return 0
t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	r = f(a, b)
	if r:
		print('YES')
		print(1, r)
	else:
		print('NO')


for _ in range(int(input())):
	input()
	c = set(map(int, input().split())).intersection(set(map(int, input().split())))
	print('YES\n' + '1 ' + str(c.pop()) if len(c) else 'NO')


inp_test = int(input())

def intersection(lst1, lst2):
	lst3 = [value for value in lst1 if value in lst2]
	return lst3
for i in range(inp_test):
	(n, m) = map(int, input().split(' '))
	list_n = list(map(int, input().split(' ')))
	list_m = list(map(int, input().split(' ')))
	list1 = intersection(list_n, list_m)
	if len(list1) != 0:
		print('YES')
		print(1, min(list1))
	else:
		print('NO')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = False
	num1 = list(map(int, input().split()))
	num2 = list(map(int, input().split()))
	for i in range(n):
		if num1[i] in num2:
			a = True
			print('YES')
			print(1, num1[i])
			break
	if not a:
		print('NO')


for abcd in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	for i in a:
		if i in b:
			ans = i
			break
	if ans != 0:
		print('YES')
		print(1, ans, end=' ')
		print()
	else:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	nelements = list(map(int, input().split()))
	melements = list(map(int, input().split()))
	ok = False
	for i in nelements:
		if i in melements:
			print('YES')
			print(1, i)
			ok = True
			break
	if ok == False:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = list(map(int, input().split()))
	vetor1 = list(map(int, input().split()))
	vetor2 = list(map(int, input().split()))
	flag = False
	for a in range(n):
		if vetor1[a] in vetor2:
			flag = True
			break
	if flag:
		print('YES')
		print(1, vetor1[a])
	else:
		print('NO')


T_ON = 1
DEBUG_ON = 0
MOD = 998244353

def solve():
	(n, m) = read_ints()
	A = set(read_ints())
	B = set(read_ints())
	C = A & B
	if C:
		YES()
		print('%d %d' % (1, list(C)[0]))
	else:
		NO()

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split()))

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


from sys import stdin
input = stdin.readline
lines = int(input())
for i in range(lines):
	(a, b) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	didprint = False
	if len(x) == 1 and len(y) == 1 and (x[0] != y[0]):
		print('NO')
		didprint = True
	else:
		for j in range(a):
			if x[j] in y:
				print('YES')
				print('1', x[j])
				didprint = True
				break
	if didprint == False:
		print('NO')


T = int(input())
for _ in range(T):
	(n, m) = list(map(int, input().strip().split()))
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	maps = dict()
	for i in range(len(a)):
		maps[a[i]] = '1'
	flag = 0
	for i in range(len(b)):
		if maps.get(b[i], 0) != 0:
			print('YES')
			print(1, b[i])
			flag = 1
			break
	if flag == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	liA = list(map(int, input().split()))
	liB = list(map(int, input().split()))
	liA.sort()
	liB.sort()
	f = 0
	for i in range(n):
		for j in range(m):
			if liA[i] == liB[j]:
				f = 1
				ans = liA[i]
			if f == 1:
				break
		if f == 1:
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


t = int(input())
while t:
	la = input()
	c = 1
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	for i in a:
		for j in b:
			if i == j:
				print('YES')
				print('1 ', i)
				c = 0
				break
		if c == 0:
			break
	if c == 1:
		print('NO')
	t = t - 1


t = int(input())
for i in range(t):
	c = 0
	n = list(map(int, input().split()))
	l = list(map(int, input().split()))
	m = list(map(int, input().split()))
	for j in range(n[0]):
		if m.count(l[j]) >= 1:
			print('YES')
			print(1, l[j])
			c = c + 1
			break
	if c == 0:
		print('NO')


import math
for w in range(int(input())):
	(x, y) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = 0
	if x < y:
		for i in a:
			if i in b:
				print('YES')
				print(1, i)
				flag = 1
				break
	else:
		for i in b:
			if i in a:
				print('YES')
				print(1, i)
				flag = 1
				break
	if flag == 0:
		print('NO')


from sys import stdout
from collections import defaultdict
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = list(set(a) & set(b))
	if len(c) > 0:
		print('YES')
		print(1, c[0])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	input()
	A = set(map(int, input().split()))
	B = set(map(int, input().split()))
	found = False
	for a in A:
		if not found and a in B:
			print('YES')
			print(1, a)
			found = True
	if not found:
		for b in B:
			if b in A:
				print('YES')
				print(1, b)
				found = True
	if not found:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	v = list(map(int, input().split()))
	f = 0
	for i in l:
		for j in v:
			if i == j and f == 0:
				print('YES')
				print(1, i)
				f = 1
	if f == 0:
		print('NO')


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	input()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	c = [x for x in a if x in b]
	if len(c):
		print('YES\n1', c[0])
	else:
		print('NO')


v = []
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(set(map(int, input().split())))
	b = list(set(map(int, input().split())))
	for i in a:
		for j in b:
			if i == j:
				v.append(i)
				continue
	for i in range(len(v)):
		if len(v) > 0:
			print('YES')
			print('1', v[i], end='')
			print()
			v.clear()
		break
	else:
		print('NO')
		v.clear()


import sys
max_int = 1000000001
min_int = -max_int
t = int(input())
for _t in range(t):
	(m, n) = map(int, sys.stdin.readline().split())
	a = set(map(int, sys.stdin.readline().split()))
	b = map(int, sys.stdin.readline().split())
	for one in b:
		if one in a:
			print('YES')
			print('1', one)
			break
	else:
		print('NO')


for _ in range(int(input())):
	(n1, n2) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	l = list(a.intersection(b))
	if len(l):
		print('YES\n1', l[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	p = list(map(int, input().split()))
	s = []
	for i in l:
		if i in p:
			s.append(i)
			break
	if len(s):
		print('YES')
		print(1, end=' ')
		for i in s:
			print(i, end=' ')
		print()
	else:
		print('NO')


import sys
import bisect as bi
import math
from collections import defaultdict as dd
input = sys.stdin.readline

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())
for _ in range(inin()):
	(n, m) = cin()
	d = dd(int)
	a = ain()
	b = ain()
	f = 0
	for i in a:
		d[i] = 1
	for i in b:
		if d[i] == 1:
			print('YES')
			print(1, i)
			f = 1
			break
	if f == 0:
		print('NO')


def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = len(li) - 1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def mex(li):
	check = [0] * 1001
	for i in li:
		check[i] += 1
	for i in range(len(check)):
		if check[i] == 0:
			return i

def sumdigits(n):
	ans = 0
	while n != 0:
		ans += n % 10
		n //= 10
	return ans

def product(li):
	ans = 1
	for i in li:
		ans *= i
	return ans

def maxpower(n, k):
	cnt = 0
	while n > 1:
		cnt += 1
		n //= k
	return cnt
from math import *
from collections import deque
max_steps = 100005
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = 0
	for i in a:
		if i in b:
			ans = i
			break
	if ans == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	ptd = False
	for i in A:
		if i in B:
			print('YES')
			print('1', i)
			ptd = True
			break
	if not ptd:
		print('NO')


t = int(input())
while t:
	t -= 1
	inp = input()
	n = input()
	n = n.split()
	n = map(int, n)
	m = input()
	m = m.split()
	m = map(int, m)
	inter = list(set(m) & set(n))
	if len(inter) == 0:
		print('NO')
	else:
		print('YES')
		print('1 ' + str(inter[0]))


t = int(input())
from sys import *
from math import *

def f(arr, k, x):
	count = 0
	for il in arr:
		count += il // x
	if count >= k:
		return True
	else:
		return False
for ip in range(t):
	(n, m) = [int(x) for x in input().strip().split()]
	arr = set([int(x) for x in input().strip().split()])
	brr = [int(x) for x in input().strip().split()]
	lx = True
	for it in brr:
		if it in arr:
			print('YES')
			print(1, it)
			lx = False
			break
	if lx:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	arr1 = [int(j) for j in input().split()]
	arr2 = [int(j) for j in input().split()]
	flag = -1
	for x in arr1:
		if x in arr2:
			flag = x
			break
	if flag == -1:
		print('NO')
	else:
		print('YES')
		print(1, flag)


def func(a, b):
	c = set(a)
	d = set(b)
	e = c.intersection(d)
	e = list(e)
	if len(e) > 0:
		return ('YES', 1, e[0])
	else:
		return 'NO'
res = []
for t in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	res.append(func(a, b))
for i in res:
	if i != 'NO':
		print(i[0])
		print(i[1], i[2])
	else:
		print(i)


def common():
	for i in range(int(input())):
		x = input()
		a = set(list(map(int, input().split())))
		b = set(map(int, input().split()))
		vault = a.intersection(b)
		if len(vault) < 1:
			print('NO')
		else:
			print('YES')
			print(f'1 {vault.pop()}')
common()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	(n, m) = Ri()
	a = Ri()
	b = Ri()
	s = set(a)
	flag = False
	for i in b:
		if i in s:
			YES()
			print(1, i)
			flag = True
			break
	if not flag:
		NO()


def solve():
	(n, m) = map(int, input().split())
	(*a,) = map(int, input().split())
	(*b,) = map(int, input().split())
	sa = set(a)
	sb = set(b)
	if sa & sb:
		print('YES')
		for c in sa & sb:
			print(1, c)
			break
	else:
		print('NO')
t = int(input())
for _ in range(t):
	solve()


from collections import Counter
for i in range(int(input())):
	(n, m) = map(int, input().split())
	l = [int(i) for i in input().split()]
	m = [int(i) for i in input().split()]
	c = Counter(l)
	for i in m:
		if c.get(i, 0):
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


import math
from decimal import Decimal
import heapq
import copy
import heapq
from collections import deque

def na():
	n = int(input())
	b = [int(x) for x in input().split()]
	return (n, b)

def nab():
	n = int(input())
	b = [int(x) for x in input().split()]
	c = [int(x) for x in input().split()]
	return (n, b, c)

def dv():
	(n, m) = map(int, input().split())
	return (n, m)

def da():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	return (n, m, a)

def dva():
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	return (n, m, b)

def eratosthenes(n):
	sieve = list(range(n + 1))
	for i in sieve:
		if i > 1:
			for j in range(i + i, len(sieve), i):
				sieve[j] = 0
	return sorted(set(sieve))

def lol(lst, k):
	k = k % len(lst)
	ret = [0] * len(lst)
	for i in range(len(lst)):
		if i + k < len(lst) and i + k >= 0:
			ret[i] = lst[i + k]
		if i + k >= len(lst):
			ret[i] = lst[i + k - len(lst)]
		if i + k < 0:
			ret[i] = lst[i + k + len(lst)]
	return ret

def nm():
	n = int(input())
	b = [int(x) for x in input().split()]
	m = int(input())
	c = [int(x) for x in input().split()]
	return (n, b, m, c)

def dvs():
	n = int(input())
	m = int(input())
	return (n, m)

def fact(n):
	tc = []
	ans = {}
	d = 2
	while d * d <= n:
		if n % d == 0:
			tc.append(d)
			n //= d
		else:
			d += 1
	if n > 1:
		tc.append(n)
	for i in tc:
		ans[i] = ans.get(i, 0) + 1
	return ans

def how_many(l, r, c):
	m = (l + r) // 2
	if r - l == 1:
		if s[l] == c:
			return 0
		else:
			return 1
	d = s[l:m]
	k1 = (r - l) // 2 - s[l:m].count(c) + how_many(m, r, chr(ord(c) + 1))
	k2 = (r - l) // 2 - s[m:r].count(c) + how_many(l, m, chr(ord(c) + 1))
	return min(k1, k2)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = -1
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ans = a[i]
				break
		if ans != -1:
			break
	if ans != -1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


T = int(input())
while T:
	(n, m) = map(int, input().strip().split())
	a = list(map(int, input().strip().split()))
	b = list(map(int, input().strip().split()))
	set_a = set(a)
	set_b = set(b)
	set_result = set_a.intersection(set_b)
	if len(set_result) == 0:
		print('NO')
	else:
		print('YES')
		print(1, set_result.pop())
	T -= 1


import sys
ii = lambda : sys.stdin.readline().strip()
idata = lambda : [int(x) for x in ii().split()]

def solve():
	(n, m) = idata()
	a = idata()
	b = idata()
	slov = {}
	flag = True
	for i in range(n):
		slov[a[i]] = 0
	for i in range(m):
		slov[b[i]] = 0
	for i in range(n):
		slov[a[i]] += 1
	for i in range(m):
		if slov[b[i]] > 0:
			print('Yes')
			print(1, b[i])
			flag = False
			break
	if flag:
		print('No')
	return
for t in range(int(ii())):
	solve()


t = int(input())
for j in range(0, t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	aa = [0] * 1001
	bb = [0] * 1001
	for i in a:
		aa[i] = aa[i] + 1
	for i in b:
		bb[i] = bb[i] + 1
	l = 0
	ans = 0
	for i in a:
		if bb[i] > 0:
			ans = i
			l = 1
			break
	if l == 1:
		print('YES')
		print('1 ', end='')
		print(ans)
	else:
		print('NO')


T = int(input())
for _ in range(T):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a = set(a)
	ans = None
	for x in b:
		if x in a:
			ans = x
			break
	if ans is None:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	s = set()
	for i in arr1:
		if i not in s:
			s.add(i)
	ans = []
	flag = 0
	for i in arr2:
		if i in s:
			ans.append(i)
			flag = 1
			break
	if flag == 1:
		print('YES')
		print(len(ans), ' '.join(map(str, ans)))
	else:
		print('NO')


n = int(input())
for i in range(n):
	(n1, n2) = input().split(' ')
	arr1 = input().split(' ')
	arr2 = input().split(' ')
	out = []
	for item in arr1:
		if item in arr2:
			out.append(item)
	if len(out) > 0:
		print('YES')
		print('1', out[0], end=' ')
		print()
	else:
		print('NO')


for T in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if n < m:
		(n, m) = (m, n)
		(a, b) = (b, a)
	k = []
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				k.append(a[i])
	if len(k) > 0:
		print('YES')
		k = sorted(list(set(k)))
		print(1, k[0])
	else:
		print('NO')


def cs():
	for i in range(int(input())):
		success = 0
		hasha = [0 for x in range(1001)]
		hashb = [0 for x in range(1001)]
		s1 = input().split()
		(n, m) = (int(s1[0]), int(s1[1]))
		a = [int(x) for x in input().split()]
		b = [int(x) for x in input().split()]
		for j in range(n):
			hasha[a[j]] = hashb[a[j]] + 1
		for r in range(m):
			hashb[b[r]] = hashb[b[r]] + 1
		for k in range(1001):
			if hasha[k] >= 1 and hashb[k] >= 1:
				print('YES')
				print(1, k)
				success = 1
				break
		if success == 0:
			print('NO')
cs()


for nt in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(list(map(int, input().split())))
	b = set(list(map(int, input().split())))
	flag = 0
	for i in a:
		if i in b:
			flag = i
			break
	if flag:
		print('YES')
		print(1, i)
		continue
	print('NO')


for tests in range(int(input())):
	found = 0
	z = input()
	first = [i for i in map(int, input().split())]
	second = [i for i in map(int, input().split())]
	for i in second:
		if i in first:
			found = i
			break
	if found:
		print('YES \n1 {}'.format(found))
	else:
		print('NO')


import sys
input = sys.stdin.readline

def main(n, m, a, b):
	dictA = {}
	for i in a:
		dictA[i] = 1
	for i in b:
		if dictA.get(i):
			print('YES')
			return str(1) + ' ' + str(i)
	return 'NO'
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	print(main(n, m, a, b))


def task_A():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		a = set(map(int, input().split()))
		b = set(map(int, input().split()))
		intersec = a & b
		if len(intersec) == 0:
			print('NO')
		else:
			print('YES')
			print(1, list(intersec)[0])

def main():
	task_A()
main()


n = int(input())
k = []
for x in range(n):
	(n, m) = map(int, input().strip().split()[:2])
	l1 = list(map(int, input().strip().split()[:n]))
	l2 = list(map(int, input().strip().split()[:m]))
	for x in l1:
		if x in l2:
			k.append(x)
			break
	if k == []:
		print('NO')
	else:
		print('YES')
		print(len(k), min(k))
	k = []


for _ in range(int(input())):
	(n, m) = map(int, input().strip().split())
	N = list(map(int, input().strip().split()))
	M = list(map(int, input().strip().split()))
	s1 = set(N)
	s2 = set(M)
	mins = -1
	n_d = {x: 0 for x in s1}
	m_d = {y: 0 for y in s2}
	for f in n_d:
		n_d[f] += 1
	for g in m_d:
		m_d[g] += 1
	count = 0
	for key in n_d.keys():
		if key in m_d:
			print('YES')
			print('1', key)
			count = 1
			break
	if count == 0:
		print('NO')


t = int(input())
for i in range(t):
	(m, n) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = set(a)
	d = set(b)
	if len(c.intersection(d)) == 0:
		print('NO')
	else:
		com = 0
		for i in a:
			if i in b:
				com = i
				break
		print('YES')
		print('1 ' + str(com))


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ai = list(map(int, input().split()))
	bi = list(map(int, input().split()))
	ai2 = [0] * 1001
	num = 0
	for i in range(n):
		ai2[ai[i]] = 1
	for i in range(m):
		if ai2[bi[i]] == 1:
			num = bi[i]
			break
	if num != 0:
		print('YES')
		print(1, num)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	a = [int(i) for i in input().split()]
	b = [int(i) for i in input().split()]
	s = set()
	for i in a:
		s.add(i)
	check = True
	for i in b:
		if i in s:
			print('YES')
			print('1', i)
			check = False
			break
	if check:
		print('NO')


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = tuple(map(int, input().split()))
	b = tuple(map(int, input().split()))
	ans = float('inf')
	for i in a:
		if i in b:
			print('YES')
			ans = i
			print(1, i)
			break
	if ans == float('inf'):
		print('NO')


t = int(input())
while t:
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	flag = 0
	if n < m:
		for num in a:
			if num in b:
				print('YES')
				print(1, num)
				flag = 1
				break
		if not flag:
			print('NO')
	else:
		for num in b:
			if num in a:
				print('YES')
				print(1, num)
				flag = 1
				break
		if not flag:
			print('NO')
	t -= 1


import math
from sys import stdin, stdout
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	l1 = list(set(map(int, input().split())))
	l2 = list(set(map(int, input().split())))
	f = 0
	for i in l1:
		f = 0
		if i in l2:
			print('YES')
			print(1, i)
			f = 1
			break
		if f == 1:
			break
	if f == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s1 = set(a)
	s2 = set(b)
	for i in s1:
		if i in s2:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


def shortestSubsq(n, m, a, b):
	a = list(set(a))
	b = list(set(b))
	count = {}
	a.extend(b)
	for i in a:
		count[i] = count.get(i, 0) + 1
		if count[i] == 2:
			print('YES')
			return print(1, i)
	return print('NO')
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()))
	shortestSubsq(n, m, a, b)


for i in range(int(input())):
	(l, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	z = a.intersection(b)
	if z:
		print('YES')
		print(1, list(z)[0])
	else:
		print('NO')


x = int(input())
for z in range(x):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = list(a & b)
	if len(c) > 0:
		print('Yes')
		print(1, c[0])
	else:
		print('No')


def check(a, b):
	ans = []
	for i in range(len(b)):
		for j in range(len(a)):
			if b[i] == a[j]:
				ans.append(a[j])
				return ans
	return ans
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()))
	f = check(a, b)
	if len(f) > 0:
		print('YES')
		print(1, *f, sep=' ')
	else:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	la = list(map(int, input().split()))
	lb = list(map(int, input().split()))
	c = 0
	for i in range(a):
		if la[i] in lb:
			c = la[i]
			break
	if c != 0:
		print('YES')
		print(1, c)
	else:
		print('NO')


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
from collections import defaultdict

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	(n, m) = sep()
	a = set(lis())
	b = set(lis())
	c = list(a.intersection(b))
	if c:
		print('YES')
		print(1, c[0])
	else:
		print('NO')
testcase(int(inp()))


from sys import stdin
input = lambda : stdin.readline().strip()
for _ in range(int(input())):
	(n, m) = [int(i) for i in input().split()]
	lst1 = [int(i) for i in input().split()]
	lst2 = [int(i) for i in input().split()]
	nk = 0
	lst1 = set(lst1)
	lst2 = set(lst2)
	for i in lst1:
		if i in lst2:
			print('YES')
			print(1, i)
			nk = 1
			break
	if nk == 0:
		print('NO')


from bisect import bisect_left
t = int(input())
for o in range(0, t):
	(n, m) = map(int, input().split(' '))
	arr1 = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	arr1.sort()
	arr2.sort()
	flag = 0
	for i in range(0, n):
		res = bisect_left(arr2, arr1[i])
		if res != m and arr2[res] == arr1[i]:
			print('YES')
			flag = 1
			print('1 {}'.format(arr1[i]))
			break
	if flag == 0:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = input().split(' ')
	a = input().split(' ')
	b = input().split(' ')
	check = False
	for j in a:
		for k in b:
			if j == k:
				print('YES')
				print('1', j)
				check = True
				break
		if check:
			break
	if not check:
		print('NO')


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
(t,) = mp()
for _ in range(t):
	(n, m) = mp()
	a = mp()
	b = mp()
	l1 = [0] * 10001
	l2 = [0] * 10001
	for i in range(n):
		l1[a[i]] = 1
	for i in range(m):
		l2[b[i]] = 1
		if l2[b[i]] + l1[b[i]] > 1:
			cout('YES\n')
			cout('1 ' + str(b[i]) + '\n')
			break
	else:
		cout('NO\n')


def comm_subseq(a, b):
	com = list(set(a) & set(b))
	l = []
	if com:
		l.append(1)
		l.append(com[0])
		print('YES')
		return l
	else:
		print('NO')
		return []
t = int(input())
for _ in range(t):
	nm = input().split()
	n = int(nm[0])
	m = int(nm[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	result = comm_subseq(a, b)
	if result:
		print(*result, sep=' ')


n = int(input())
a = []
b = []
c = []
for i in range(n):
	m = list(map(int, input().split()))
	p = list(map(int, input().split()))
	q = list(map(int, input().split()))
	a.append(p)
	b.append(q)
for i in range(n):
	for j in a[i]:
		if j in b[i]:
			c.append(j)
	if len(c) > 0:
		print('YES')
		print(1, end=' ')
		print(c[0])
		c.clear()
	else:
		print('NO')


i = lambda : input().split()
for _ in range(int(input())):
	(n, m) = i()
	a = set(i()) & set(i())
	print('YES 1 ' + [*a][0] if a else 'NO')


def countFreq(arr):
	n = len(arr)
	mp = dict()
	for i in range(n):
		if arr[i] in mp.keys():
			mp[arr[i]] += 1
		else:
			mp[arr[i]] = 1
	return mp
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	l = []
	an = countFreq(a)
	bm = countFreq(b)
	for key in an.keys():
		if key in bm:
			l.append(key)
			break
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(len(l), *l)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li1 = [int(z) for z in input().split()]
	li2 = [int(z) for z in input().split()]
	li1 = list(set(li1))
	li2 = list(set(li2))
	n = len(li1)
	m = len(li2)
	f = 0
	if n > m:
		for i in li2:
			if i in li1:
				print('YES')
				print(1, i)
				f = 1
				break
		if f == 0:
			print('NO')
	else:
		for i in li1:
			if i in li2:
				print('YES')
				print(1, i)
				f = 1
				break
		if f == 0:
			print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	adict = {}
	bdict = {}
	for val in a:
		try:
			adict[val] += 1
		except:
			adict[val] = 1
	for val in b:
		try:
			bdict[val] += 1
		except:
			bdict[val] = 1
	flag = 0
	for key in adict:
		try:
			bdict[key] = bdict[key]
			ans = key
			flag = 1
			break
		except:
			continue
	if flag:
		print('YES')
		print(1, ans)
	else:
		print('NO')


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


def solve(A, B, n, m):
	hashmap = dict()
	for key in A:
		hashmap[key] = 1
	for key in B:
		if key in hashmap:
			print('YES')
			print(1, key)
			break
	else:
		print('NO')
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	A = [int(i) for i in input().split()]
	B = [int(i) for i in input().split()]
	solve(A, B, n, m)


for i in range(int(input())):
	(x, y) = (int(p) for p in input().split())
	l = [int(p) for p in input().split()]
	m = [int(p) for p in input().split()]
	l = set(l)
	m = set(m)
	o = l.intersection(m)
	o = list(o)
	if len(o) > 0:
		print('YES')
		print(1, end=' ')
		print(o[0])
	else:
		print('NO')


T = int(input())
for t in range(T):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = {}
	chk = False
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = True
	for i in range(m):
		if b[i] in d:
			x = b[i]
			chk = True
			break
	if chk:
		print('YES')
		print(1, end=' ')
		print(x)
	else:
		print('NO')


Number_Of_Arrays = int(input())

def func():
	size_of_array = input().split()
	array1 = input().split()
	array2 = input().split()
	for k in array1:
		for j in array2:
			if k == j:
				print('YES')
				print('1', j)
				return
	print('NO')
for i in range(Number_Of_Arrays):
	func()


def binarySearch(arr, l, r, x):
	if r >= l:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return True
		elif arr[mid] > x:
			return binarySearch(arr, l, mid - 1, x)
		else:
			return binarySearch(arr, mid + 1, r, x)
	else:
		return False
a = int(input())
for i in range(a):
	a1 = list(map(int, input().split()))
	ar1 = list(map(int, input().split()))
	ar2 = list(map(int, input().split()))
	ar1.sort()
	ar2.sort()
	num = 0
	flag = 0
	for i in ar1:
		if binarySearch(ar2, 0, len(ar2) - 1, i) == True:
			flag = 1
			num = i
			break
	if flag == 1:
		print('YES')
		print('1', num)
	else:
		print('NO')


def common(A, B):
	for i in A:
		if i in B:
			print('YES')
			print('1' + ' ' + str(i))
			return
	print('NO')
	return
t = int(input())
for t in range(t):
	lens = input()
	A = input()
	B = input()
	A = [int(i) for i in A.split() if i.isdigit()]
	B = [int(i) for i in B.split() if i.isdigit()]
	common(A, B)


t = int(input())
while t > 0:
	(n, m) = map(int, input().strip().split(' '))
	a = set(map(int, input().strip().split(' ')))
	b = set(map(int, input().strip().split(' ')))
	s = a & b
	if len(s) > 0:
		print('YES')
		print(f'1 {s.pop()}')
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	p = list(map(int, input().split()))
	(n, m) = (p[0], p[1])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	key = 0
	for i in a:
		for j in b:
			if i == j:
				print('YES')
				print(1, i)
				key = 1
				break
		if key == 1:
			break
	if key == 0:
		print('NO')


n = int(input())
for i1 in range(n):
	(a, b) = [int(x) for x in input().split()]
	lst1 = set([int(x) for x in input().split()])
	lst2 = set([int(x) for x in input().split()])
	lst3 = lst1.intersection(lst1, lst2)
	if len(lst3) >= 1:
		print('YES')
		for x in lst3:
			print(1, x, sep=' ')
			break
	else:
		print('NO')


t = int(input())
cnt = 0
while cnt < t:
	cnt += 1
	(n, m) = [int(i) for i in input().split()]
	a = set((int(i) for i in input().split()))
	b = set((int(i) for i in input().split()))
	a &= b
	if a:
		print('YES')
		print(1, end=' ')
		for elem in a:
			print(elem)
			break
	else:
		print('NO')


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()))
	a.sort()
	b.sort()
	found = 0
	j = 0
	while j < n and found == 0:
		for k in range(m):
			if a[j] == b[k]:
				print('YES')
				print('1 ', a[j])
				found = 1
				break
			elif b[k] > a[j]:
				break
		j += 1
	if found == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ans = []
	prev = -1
	for i in range(n):
		for j in range(prev + 1, m):
			if a[i] == b[j]:
				ans.append(a[i])
				prev = j
				break
	if len(ans) != 0:
		print('YES')
		print('1', ans[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(map(int, input().split()))
	valid = False
	ans = 0
	for ele in a:
		if ele in b:
			valid = True
			ans = ele
			break
	if valid:
		print('YES')
		print(1, ans)
	else:
		print('NO')


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	t = inp()
	for _ in range(t):
		(n, m) = invr()
		a = inlist()
		b = inlist()
		da = defaultdict(lambda : 0)
		res = -1
		for i in a:
			da[i] += 1
		for i in b:
			if da[i] > 0:
				res = i
				break
		if res != -1:
			print('YES')
			print(1, res)
		else:
			print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


import sys
input = sys.stdin.buffer.readline

def I():
	return list(map(int, input().split()))

def sieve(n):
	a = [1] * n
	for i in range(2, n):
		if a[i]:
			for j in range(i * i, n, i):
				a[j] = 0
	return a
for __ in range(int(input())):
	(n, m) = I()
	a = set(I())
	b = set(I())
	c = a.intersection(b)
	if c:
		print('YES')
		for i in c:
			print(1, i)
			break
	else:
		print('NO')


import os
from sys import stdin, stdout

def solve(tc):
	(n, m) = map(int, stdin.readline().split())
	sa = list(map(int, stdin.readline().split()))
	sb = list(map(int, stdin.readline().split()))
	mapA = [False for i in range(1001)]
	for i in range(n):
		mapA[sa[i]] = True
	for i in range(m):
		if mapA[sb[i]]:
			print('YES')
			print(1, sb[i])
			return
	print('NO')
tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


def algo(a, b):
	s = list(set(a))
	for i in s:
		if i in b:
			return i
	return 'NO'
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	if algo(a, b) == 'NO':
		print('NO')
	else:
		print('YES')
		print(1, algo(a, b))


import sys
import math
input = sys.stdin.readline
T = int(input())
for t in range(T):
	(n, m) = map(int, input().split(' '))
	A = map(int, input().split(' '))
	B = map(int, input().split(' '))
	inter = set(A) & set(B)
	if inter:
		print('YES')
		print(1, next(iter(inter)))
	else:
		print('NO')


n_sets = int(input())
for i in range(n_sets):
	_ = input()
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	for x in a:
		if x in b:
			print('YES')
			print(1, x)
			break
	else:
		print('NO')


from collections import defaultdict, Counter
from math import log, ceil, floor

def solve():
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = set(a)
	for i in b:
		if i in a:
			print('YES')
			print(1, i)
			return
	print('NO')
t = 1
t = int(input())
for _ in range(t):
	solve()


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
M = 10 ** 9 + 7

def countlen(s, val):
	cnt = 0
	for i in range(len(s) - 6):
		x = s[i:i + 7]
		if x == val:
			cnt += 1
	return cnt

def solve():
	(n, m) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d1 = {}
	d2 = {}
	for i in a:
		if i not in d1:
			d1[i] = 1
	for i in b:
		if i not in d2:
			d2[i] = 1
	for i in a:
		if i in d2:
			print('YES')
			print('1 ', i)
			return
	for i in b:
		if i in d1:
			print('YES')
			print('1 ', i)
			return
	print('NO')
t = 1
t = int(stdin.readline())
for _ in range(t):
	solve()


t = int(input())
while t != 0:
	(n, m) = list(map(int, input().split()))
	l1 = [int(i) for i in input().split()]
	l2 = [int(i) for i in input().split()]
	l1 = set(l1)
	l2 = set(l2)
	res = l1.intersection(l2)
	if res:
		print('YES')
		print('1', res.pop())
	else:
		print('NO')
	t -= 1


from sys import stdin, setrecursionlimit, stdout
setrecursionlimit(100)
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin
from heapq import heapify, heappop, heappush, heapreplace, heappushpop
from bisect import bisect_right, bisect_left

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def si():
	return stdin.readline().rstrip()

def lsi():
	return list(si())
mod = 1000000007
res = ['NO', 'YES']

def solve():
	(n, m) = mi()
	a = set(li())
	b = set(li())
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			return
	print('NO')
test = 1
test_case = ii()
while test <= test_case:
	test += 1
	solve()


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, m) = R()
	v = list(set(R()).intersection(set(R())))
	if v:
		print('YES')
		print(1, v[0])
	else:
		print('NO')


import io
import os
from sys import stdin, stdout
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

def solve():
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = set(map(int, input().split()))
	flag = 0
	for i in a:
		if i in b:
			flag = 1
			print('YES')
			print(1, i)
			break
	if flag == 0:
		print('NO')

def main():
	for t in range(int(input())):
		solve()
main()


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	an = set(map(int, stdin.readline().split()))
	am = set(map(int, stdin.readline().split()))
	if len(an & am) == 0:
		print('NO')
	else:
		print(f'YES\n 1 {list(an & am)[0]}')


import sys
input = lambda : sys.stdin.readline().strip()
char = [chr(i) for i in range(97, 123)]
CHAR = [chr(i) for i in range(65, 91)]
mp = lambda : list(map(int, input().split()))
INT = lambda : int(input())
rn = lambda : range(INT())
from math import ceil, sqrt, factorial, gcd
for _ in rn():
	(n, m) = mp()
	a = mp()
	b = set(mp())
	k = 1
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			k = 0
			break
	if k == 1:
		print('NO')


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	N = sorted(list(map(int, input().split())))
	M = sorted(list(map(int, input().split())))
	if N[0] < M[0]:
		(N, M) = (M, N)
	if N[0] > M[-1]:
		print('NO')
		continue
	l = 1
	for j in N:
		if j in M:
			print('YES')
			print(1, j)
			l = 0
			break
	if l:
		print('NO')


def intersection(alist: list, blist: list) -> int:
	for ele in alist:
		if ele in blist:
			return ele
	return -1
t = int(input())
AList = list(list())
BList = list(list())
for _ in range(t):
	__ = input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	AList.append(a)
	BList.append(b)
for i in range(len(AList)):
	k = intersection(AList[i], BList[i])
	if k != -1:
		print('Yes')
		print(1, k)
	else:
		print('No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	set_a = set(a)
	set_b = set(b)
	set_union = set_a & set_b
	for q in set_union:
		ans = q
		break
	if len(set_union) == 0:
		print('NO')
	else:
		print('YES')
		print('1', ans)


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for i in range(len(a)):
		if a[i] in b:
			print('YES')
			print(1, a[i])
			break
		elif i == len(a) - 1:
			print('NO')


def find(l1, l2):
	l3 = []
	start = -1
	count = 0
	for i in range(len(l1)):
		for j in range(start + 1, len(l2)):
			if l1[i] == l2[j]:
				start = j
				l3.append(l1[i])
				break
	if len(l3) > 0:
		print('YES')
		print(1, l3[0])
	else:
		print('NO')
t = int(input())
while t:
	(n, m) = input().split()
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	find(l1, l2)
	t -= 1


for i in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	dic = {}
	for i in arr1:
		dic[i] = 1
	c = 1
	ans = 0
	for j in arr2:
		if dic.get(j, -1) != -1:
			c = 0
			ans = j
			break
	if c == 1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


for i in range(int(input())):
	(n, m) = list(map(int, input().split()))
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	r = 0
	for i in a:
		if i in b:
			print('YES')
			print('%d %d' % (1, i))
			r += 1
			break
	if r == 0:
		print('NO')


from collections import defaultdict as dd
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	d = dd(int)
	for i in range(0, n):
		if a[i] not in d:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
	fg = 0
	no = 0
	for i in range(0, m):
		if d[b[i]] > 0:
			fg = 1
			no = b[i]
			break
	if fg == 0:
		print('NO')
	else:
		print('YES')
		print(1, no)


t = int(input())
while t:
	t -= 1
	(n, m) = input().split(' ')
	a = []
	b = []
	c = []
	a = [int(i) for i in input().split(' ')]
	b = [int(i) for i in input().split(' ')]
	for i in a:
		if i in b:
			c.append(i)
	if len(c) == 0:
		print('NO')
	else:
		print('YES')
		print('1', c[0])


def search(a, k, lo, hi):
	while lo <= hi:
		mid = lo + (hi - lo) // 2
		if a[mid] == k:
			return True
		elif a[mid] > k:
			hi = mid - 1
		else:
			lo = mid + 1
	return False
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	b.sort()
	f = True
	for i in range(n):
		if search(b, a[i], 0, m - 1):
			print('Yes')
			print(1, a[i])
			f = False
			break
	if f:
		print('No')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	li1 = list(map(int, input().split()))
	li2 = list(map(int, input().split()))
	fg = 0
	for i in range(n):
		if li1[i] in li2:
			print('YES')
			print('1 {0}'.format(li1[i]))
			fg = 1
			break
	if fg == 0:
		print('NO')


t = int(input())
for k in range(t):
	ab = list(map(int, input().split()))
	a = ab[0]
	b = ab[1]
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	mp1 = {}
	mp2 = {}
	flag = 0
	for i in arr1:
		mp1[i] = 1
	for i in arr2:
		mp2[i] = 1
	for i in mp1:
		if i in mp2:
			flag = 1
			print('YES')
			print(1, i)
			break
	if not flag:
		print('NO')


t = int(input())
for i in range(t):
	(a, b) = input().split()
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	f = []
	for i in c:
		if i in d:
			f.append(i)
			break
	if len(f) == 1:
		print('YES')
		print('1', f[0])
	else:
		print('NO')


for testcases in range(int(input())):
	length = list(map(int, input().split()))
	str1 = list(map(int, input().split()))
	str2 = list(map(int, input().split()))
	flag = 0
	if length[0] > length[1]:
		for i in range(len(str1)):
			if (str1[i] in str2) != 0:
				print('YES')
				print('1', str1[i])
				flag = 1
				break
	else:
		for i in range(len(str2)):
			if (str2[i] in str1) != 0:
				print('YES')
				print('1', str2[i])
				flag = 1
				break
	if flag == 0:
		print('NO')


def main():
	t = int(input())
	for i in range(t):
		[m, n] = list(map(int, input().split()))
		x = set(map(int, input().split()))
		y = list(map(int, input().split()))
		r = -1
		for i in y:
			if i in x:
				r = i
		if r != -1:
			print('YES')
			print(1, r)
		else:
			print('NO')
main()


for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	d = -1
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				d = a[i]
	if d == -1:
		print('NO')
	else:
		print('YES')
		print(1, d)


for t in range(int(input())):
	(n, m) = map(int, input().split())
	A = set(map(int, input().split()))
	B = list(map(int, input().split()))
	found = False
	for i in B:
		if i in A:
			print('YES')
			print(1, i)
			found = True
			break
	if not found:
		print('NO')


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, m) = (L[0], L[1])
	ch = input()
	L1 = [int(i) for i in ch.split()]
	ch = input()
	L2 = [int(i) for i in ch.split()]
	test = False
	s = set()
	for i in range(n):
		s.add(L1[i])
	for i in range(m):
		if L2[i] in s:
			test = True
			print('YES')
			print(1, L2[i])
			break
	if test == False:
		print('NO')


def main():
	for _ in range(int(input())):
		n = input()
		arr1 = set(map(int, input().split()))
		arr2 = set(map(int, input().split()))
		ans = arr1.intersection(arr2)
		if len(ans) == 0:
			print('NO')
		else:
			print('YES')
			print(1, ans.pop())
main()


t = int(input())
while t:
	t -= 1
	(n, m) = input().split()
	a = input().split()
	b = input().split()
	y = False
	for x in a:
		if x in b:
			print('YES')
			print(1, x)
			y = True
			break
	if not y:
		print('NO')


p = int(input())
arr = []
for i in range(p):
	(m, n) = map(int, input().split())
	arr1 = [int(d) for d in input().split(' ')]
	arr2 = [int(d) for d in input().split(' ')]
	if len(arr1) >= len(arr2):
		for j in range(len(arr2)):
			if arr1.count(arr2[j]) > 0:
				arr.append(['YES', arr2[j]])
				break
			elif j == len(arr2) - 1:
				arr.append('NO')
	else:
		for t in range(len(arr1)):
			if arr2.count(arr1[t]) > 0:
				arr.append(['YES', arr1[t]])
				break
			elif t == len(arr1) - 1:
				arr.append('NO')
for j in range(len(arr)):
	if arr[j] == 'NO':
		print('NO')
	else:
		print('YES')
		print(1, arr[j][1])


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a1 = list(map(int, input().split()))
	b1 = list(map(int, input().split()))
	f = 0
	for i in a1:
		if i in b1:
			f = 1
			break
	if f == 0:
		print('NO')
	else:
		print('YES')
		print('1', i)


t = int(input())
for i in range(t):
	(n, m) = [int(j) for j in input().split()[:2]]
	x = [int(k) for k in input().split()[:n]]
	y = [int(l) for l in input().split()[:m]]
	f = 0
	for j in range(n):
		if x[j] in y:
			p = j
			f += 1
			break
		else:
			pass
	if f > 0:
		print('YES')
		print(1, x[p])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(al, bl) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp = []
	temp1 = []
	flag = 0
	if al < bl:
		temp = a
		temp1 = b
	else:
		temp = b
		temp1 = a
	for x in temp:
		if x in temp1:
			print('YES')
			print(1, x)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
pi = 3.1415
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	dict = {}
	for i in range(len(a)):
		dict[a[i]] = 1
	tag = 0
	for i in range(len(b)):
		if b[i] in dict.keys():
			print('YES')
			print(1, b[i])
			tag = 1
			break
	if tag == 0:
		print('NO')


import sys
import math
import collections
from sys import stdin, stdout, setrecursionlimit
import bisect as bs
setrecursionlimit(2 ** 20)
MOD = 998244353
T = int(stdin.readline())
for _ in range(T):
	(n, m) = list(map(int, stdin.readline().split()))
	a = list(map(int, stdin.readline().split()))
	b = list(map(int, stdin.readline().split()))
	d = {}
	for i in range(n):
		d[a[i]] = True
	res = False
	for i in range(m):
		if b[i] in d:
			res = True
			print('YES')
			print(1, b[i])
			break
	if not res:
		print('NO')


import math
for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(j) for j in input().split()]
	b = [int(j) for j in input().split()]
	a = list(set(a))
	b = list(set(b))
	a.sort()
	b.sort()
	z = 0
	for j in range(len(a)):
		if a[j] in b:
			print('YES')
			z = 1
			print(1, a[j])
			break
	if z == 0:
		print('NO')


t = int(input())
l = []
for i in range(5):
	l.append(i)
for _ in range(t):
	(n, m) = map(int, input().split())
	nL = list(map(int, input().split()))
	mL = list(map(int, input().split()))
	im = 0
	km = 0
	flag = False
	for i in nL:
		if i in mL:
			print('YES')
			print(1, i)
			flag = True
			im += 1
			break
	if flag == False:
		print('NO')
		km += 1


from collections import Counter

def scs(arr1, arr2, n, m):
	c = Counter(arr2)
	c = dict(sorted(c.items(), key=lambda x: x[1]))
	for i in arr1:
		if i in c:
			return (1, i)
	return (0, 0)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = input().split()
	arr2 = input().split()
	(l, el) = scs(arr1, arr2, n, m)
	if l == 0:
		print('NO')
	else:
		print('YES')
		print(1, el)


import collections
t = int(input())
for tc in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	A = collections.Counter(a)
	check = False
	for x in b:
		if A[x] > 0:
			print('YES')
			print('1 ', x)
			check = True
			break
	if not check:
		print('NO')


num = int(input())
for i in range(num):
	a = []
	b = []
	(n, m) = [int(x) for x in input().split(' ')]
	a = [int(x) for x in input().split(' ')]
	b = [int(x) for x in input().split(' ')]
	for j in range(len(a)):
		if a[j] in b:
			print('YES')
			print('1 ' + str(a[j]))
			break
		if j == len(a) - 1 and a[j] not in b:
			print('NO')


def solve():
	(a, b) = map(int, input().split())
	mas1 = list(map(int, input().split()))
	mas2 = list(map(int, input().split()))
	ans = None
	for i in mas1:
		for j in mas2:
			if i == j:
				ans = i
				break
	if ans == None:
		print('NO')
	else:
		print('YES')
		print(1, ans)

def main():
	t = int(input())
	for i in range(t):
		solve()
main()


from sys import stdin
for _ in range(int(stdin.readline())):
	(n, m) = [int(i) for i in stdin.readline().split(' ')]
	a = [int(i) for i in stdin.readline().split(' ')]
	b = [int(i) for i in stdin.readline().split(' ')]
	flag = 0
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			flag = 1
			break
	if flag == 0:
		print('NO')


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
inp = lambda : int(input())
strng = lambda : input().strip()
jn = lambda x, l: x.join(map(str, l))
strl = lambda : list(input().strip())
mul = lambda : map(int, input().strip().split())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
stdarr = lambda : map(int, stdstr().split())
mod = 1000000007
for _ in range(stdint()):
	(n, m) = mul()
	a = seq()
	b = seq()
	flag = 0
	for ele in a:
		if ele in b:
			flag = 1
			print('YES')
			print(1, end=' ')
			print(ele)
			break
	if flag == 0:
		print('NO')


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	(n, m) = [int(x) for x in input().split()]
	a = set([int(x) for x in input().split()])
	b = set([int(x) for x in input().split()])
	s = a & b
	if len(s):
		print('YES')
		print(1, s.pop())
	else:
		print('NO')
tt = int(input())
for test in range(tt):
	solve()


import sys
input = lambda : sys.stdin.readline().rstrip('\n\r')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s = set(map(int, input().split())) & set(map(int, input().split()))
	if s:
		print('YES')
		print(1, s.pop())
	else:
		print('NO')


t = int(input())
for test in range(t):
	(n, m) = input().split()
	a = input().split()
	b = input().split()
	found = False
	for i in a:
		if i in b:
			print('YES')
			print('1', i)
			found = True
			break
	if not found:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	for e in l1:
		if e in l2:
			print('YES')
			print('1 ' + str(e))
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	aS = set(a)
	ok = False
	for x in b:
		if x in aS:
			print('YES\n1 {}'.format(x))
			ok = True
			break
	if ok == False:
		print('NO')


t = int(input())
while t > 0:
	(tt, ttt) = input().split()
	n = int(tt)
	m = int(ttt)
	a1 = []
	b1 = []
	found = False
	v = 0
	a1 = list(map(int, input().split()))
	b1 = list(map(int, input().split()))
	for ii in a1:
		if ii in b1:
			v = ii
			found = True
	if found == True:
		print('YES\n')
		print(1, v)
	else:
		print('NO')
	t -= 1


n = int(input())
a1 = []
for i in range(n):
	(a, b) = map(int, input().split())
	c = list(map(int, input().split()))
	d = list(map(int, input().split()))
	f = False
	for k in range(0, len(c)):
		if c[k] in d:
			a1.append(['YES', 1, c[k]])
			f = True
			break
	if f == False:
		a1.append(['NO'])
for i in range(0, len(a1)):
	if a1[i][0] == 'YES':
		print('YES')
		print(a1[i][1], a1[i][2])
	else:
		print('NO')


t = int(input())
for i in range(t):
	(m, n) = map(int, input().strip().split(' '))
	a = list(map(int, input().strip().split(' ')))
	b = list(map(int, input().strip().split(' ')))
	f = 0
	if len(a) > len(b):
		for j in range(len(b)):
			if b[j] in a:
				f = 1
				print('YES')
				print(1, b[j], end=' ')
				print()
				break
	else:
		for j in range(len(a)):
			if a[j] in b:
				f = 1
				print('YES')
				print(1, a[j], end=' ')
				print()
				break
	if f == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(input().split())
	b = list(input().split())
	ans = []
	for number in a:
		if number in b:
			ans = number
			break
	if ans:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	s1 = set(l1)
	s2 = set(l2)
	s3 = s1 & s2
	if s3 == set():
		print('NO')
	else:
		print('YES')
		print(1, list(s3)[0])
	t = t - 1


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')


t = int(input())
for cases in range(t):
	s = input()
	L = [int(item) for item in s.split(' ')]
	a = input()
	b = input()
	a1 = [int(item) for item in a.split(' ')]
	b1 = [int(item) for item in b.split(' ')]
	flag = 0
	for num in a1:
		if num in b1:
			flag = 0
			print('YES')
			print(1, end=' ')
			print(num)
			break
		else:
			flag = 1
	if flag == 1:
		print('NO')


R = lambda : {*map(int, input().split())}
(t,) = R()
exec(t * "R();s=R()&R();print(f'YES 1 {s.pop()}'if s else'NO');")


for tt in range(int(input())):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	inter = a & b
	ll = len(inter)
	if ll:
		item = 0
		for i in inter:
			item = i
			break
		print('YES')
		print(1, item)
	else:
		print('NO')


def common_member(a, b):
	a_set = set(a)
	b_set = set(b)
	if a_set & b_set:
		return list(a_set & b_set)
	else:
		return None
t = int(input())
for t1 in range(t):
	(m, n) = [int(n1) for n1 in input().split()]
	a = [int(n1) for n1 in input().split()]
	b = [int(n1) for n1 in input().split()]
	c = common_member(a, b)
	if c != None:
		print('YES')
		print(1, end=' ')
		print(c[0])
	else:
		print('NO')


from sys import stdin
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, m) = [int(x) for x in inp().split()]
	a = [int(x) for x in inp().split()]
	b = [int(x) for x in inp().split()]
	elemA = [0] * 1001
	elemB = [0] * 1001
	for i in a:
		elemA[i] += 1
	for i in b:
		elemB[i] += 1
	for i in range(1001):
		if elemA[i] > 0 and elemB[i] > 0:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


from collections import Counter
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c1 = Counter(a)
	c2 = Counter(b)
	c = c1 & c2
	if bool(c):
		print('YES')
		print('1', c.most_common(1)[0][0])
	else:
		print('NO')


test_case = int(input())
for _ in range(test_case):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	temp_a = [i for i in a if i in b]
	temp_b = [i for i in b if i in a]
	if temp_b == [] or temp_a == []:
		print('NO')
		continue
	print('YES')
	print(1, temp_a[0])


n = int(input())
for i in range(0, n):
	(a, b) = map(int, input().split())
	l = list(map(int, input().split()))
	l1 = list(map(int, input().split()))
	a -= 1
	b -= 1
	l.sort()
	l1.sort()
	p = set(l)
	q = set(l1)
	c = min(a, b)
	f = 0
	if c == a:
		for j in p:
			if j in q:
				output = j
				f = 1
				break
	else:
		for j in q:
			if j in p:
				output = j
				f = 1
				break
	if f == 1:
		print('YES')
		print(f'{1} {output}')
	else:
		print('NO')


t = int(input())
for i in range(t):
	count = 0
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	arr = []
	for i in a:
		if i in b:
			count += 1
			arr.append(i)
			break
	if count > 0:
		print('YES')
		print(count, end=' ')
		print(*arr)
	else:
		print('NO')


for i in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(set(map(int, input().split())))
	b = list(set(map(int, input().split())))
	a.sort()
	b.sort()
	an = ''
	num = 'oops'
	if min(a) > max(b) or min(b) > max(a):
		an = 'NO'
	elif len(a) < len(b):
		for i in a:
			if i in b:
				num = i
				an = 'YES'
				break
			else:
				an = 'NO'
	else:
		for i in b:
			if i in a:
				num = i
				an = 'YES'
				break
			else:
				an = 'NO'
	if an == 'YES':
		print(an)
		print(1, num)
	else:
		print(an)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	h1 = {}
	h2 = {}
	ans = -1
	for i in range(len(arr1)):
		if arr1[i] not in h1:
			h1[arr1[i]] = 1
	for i in range(len(arr2)):
		if arr2[i] not in h2:
			h2[arr2[i]] = 1
	for i in range(len(arr1)):
		if arr1[i] in h2:
			ans = arr1[i]
			break
	if ans > 0:
		print('YES')
		print('1', ans)
	else:
		print('NO')


def solve():
	(n, m) = map(int, input().split())
	ln = [int(x) for x in input().split()]
	lm = [int(y) for y in input().split()]
	l = []
	for i in range(n):
		for j in range(m):
			if ln[i] == lm[j]:
				l.append(ln[i])
	if len(l) == 0:
		print('NO')
	else:
		print('YES')
		print(1, l[0])
for _ in range(int(input())):
	solve()


import sys
inputlist = sys.stdin.readlines()
number_of_testcases = int(inputlist[0])
for i in range(number_of_testcases):
	(n, m) = list(map(int, inputlist[3 * i + 1].strip().split(' ')))
	firstlist = list(map(int, inputlist[3 * i + 2].strip().split(' ')))
	secondlist = list(map(int, inputlist[3 * i + 3].strip().split(' ')))
	for j in firstlist:
		if j in secondlist:
			print('YES')
			print('1', j)
			break
	else:
		print('NO')


from sys import stdin, stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, m) = iia()
	arr1 = iia()
	arr2 = iia()
	k = set(arr1) & set(arr2)
	if len(k):
		print('YES')
		print(1, k.pop())
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s = set(a).intersection(set(b))
	if not s:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		for el in s:
			print(el)
			break


t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	ln = list(map(int, input().split()))
	lm = list(map(int, input().split()))
	ans = []
	if n == m:
		for j in range(m):
			if ln[j] in lm:
				print('YES')
				print(1, ln[j])
				break
		else:
			print('NO')
	elif m > n:
		for j in range(n):
			if ln[j] in lm:
				print('YES')
				print(1, ln[j])
				break
		else:
			print('NO')
	else:
		for j in range(m):
			if lm[j] in ln:
				print('YES')
				print(1, lm[j])
				break
		else:
			print('NO')


def main():
	_ = input()
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for a_el in a:
		for b_el in b:
			if a_el == b_el:
				print('YES')
				print(f'1 {a_el}')
				return
	print('NO')
t = int(input())
for _ in range(t):
	main()


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(m,) = I()
while m:
	(x, y) = I()
	a = I()
	b = I()
	flag = 0
	for i in a:
		for j in b:
			if i == j:
				print('YES')
				print(1, i)
				flag = 1
				break
		if flag == 1:
			break
	if flag == 0:
		print('NO')
	m -= 1


import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
t = int(input())
for _ in range(t):
	(n, m) = map(int, stdin.readline().split())
	a = set(map(int, stdin.readline().split()))
	b = set(map(int, stdin.readline().split()))
	temp = a.intersection(b)
	if len(temp) == 0:
		print('NO')
	else:
		print('YES')
		print(1, temp.pop())


for t in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	x = 'NO'
	for a in range(n):
		for b in range(m):
			if arr1[a] == arr2[b]:
				x = 'YES'
				ans = arr1[a]
				break
	print(x)
	if x == 'YES':
		print(1, ans)


t = int(input())
for i in range(t):
	(n, m) = input().split(' ')
	a = input().split(' ')
	b = input().split(' ')
	v = 0
	for i in range(int(n)):
		if v == 1:
			break
		for j in range(int(m)):
			if int(a[i]) == int(b[j]):
				print('YES')
				print('1 ', a[i])
				v = 1
				break
	if v == 0:
		print('NO')


def binary(i, l, h, arr2):
	mid = l + (h - l) // 2
	if arr2[mid] == i:
		return True
	elif l > h:
		return False
	elif arr2[mid] > i:
		return binary(i, l, mid - 1, arr2)
	else:
		return binary(i, mid + 1, h, arr2)
for i in range(int(input())):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	arr1.sort()
	arr2.sort()
	for i in arr1:
		if binary(i, 0, m - 1, arr2):
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


R = lambda : {*map(int, input().split())}
(t,) = R()
for _ in [0] * t:
	R()
	s = R() & R()
	print(f'YES 1 {s.pop()}' if s else 'NO')


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	A = Counter(list(map(int, input().split())))
	B = Counter(list(map(int, input().split())))
	ans = -1
	for i in A:
		if ans != -1:
			break
		if i in B:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


from sys import stdin, stdout
from collections import Counter
from math import ceil
from bisect import bisect_left
from bisect import bisect_right
import math

def ai():
	return list(map(int, stdin.readline().split()))

def ei():
	return map(int, stdin.readline().split())

def ip():
	return int(stdin.readline().strip())

def op(ans):
	return stdout.write(str(ans) + '\n')
for i in range(ip()):
	(n, m) = ei()
	a = ai()
	b = ai()
	a = set(a)
	b = set(b)
	x = list(a.intersection(b))
	if x:
		print('YES')
		print(1, x[0])
	else:
		print('NO')


import math
from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	c = []
	for i in range(m):
		if b[i] in a:
			c.append(b[i])
			break
	if len(c) > 0:
		print('YES')
		print(len(c), end=' ')
		print(*c)
	else:
		print('NO')


def find_seq(a, b):
	var = 0
	for i in a:
		if i in b:
			var = 1
			k = i
			break
		if var == 1:
			break
	if var == 0:
		print('NO')
	else:
		print('YES')
		print(1, k)
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	find_seq(a, b)


n = int(input())
while n > 0:
	n -= 1
	(l, m) = map(int, input().split())
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	ans = []
	i = 0
	k = 0
	while i < l:
		j = k
		while j < m:
			if arr1[i] == arr2[j]:
				ans.append(arr1[i])
				k = j + 1
				break
			j += 1
		i += 1
	if len(ans) > 0:
		print('YES')
		print(1, ' ', ans[-1])
	else:
		print('NO')


from bisect import bisect_left
from math import ceil
from math import radians
from heapq import heapify, heappush, heappop
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0 and i % 2 == 1:
			s.add(i)
			n = n // i
	if n > 2 and n % 2 == 1:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count

def cou(n):
	c = 0
	while n > 1:
		c += 1
		n //= 2
	return c

def sortsec(l):
	return sorted(l, key=lambda x: x[1])

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def subarray(A):
	r = set()
	p = {0}
	for x in A:
		p = {x | y for y in p} | {x}
		r |= p
	return len(r)
for _ in range(ii()):
	(n, k) = mi()
	l = li1()
	m = li1()
	for i in l:
		if i in m:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')


def main():
	for _ in range(int(input())):
		(sizea, sizeb) = map(int, input().split())
		a = [int(i) for i in input().split()]
		b = [int(i) for i in input().split()]
		c = set(a) & set(b)
		if c:
			print('YES')
			print(1, c.pop())
		else:
			print('NO')
main()


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	d = set(a)
	e = set(b)
	st = d & e
	if len(st) == 0:
		print('NO')
		continue
	print('YES')
	print(1, st.pop())


t = int(input())
for i in range(t):
	input()
	elements_1 = [int(x) for x in input().split()]
	elements_2 = [int(x) for x in input().split()]
	found = False
	for el in elements_1:
		if el in elements_2:
			found = True
			print('YES')
			print(1, el)
			break
	if not found:
		print('No')


import math
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(input().split())
	b = list(input().split())
	x = -1
	for el in a:
		if el in b:
			x = el
			break
	if x == -1:
		print('NO')
	else:
		print('YES')
		print(1, x)


from sys import stdin, stdout
input = stdin.readline

def write(n, sep='\n'):
	stdout.write(str(n))
	stdout.write(sep)

def gil():
	return list(map(int, input().split()))
for _t in range(int(input())):
	(n, m) = gil()
	a = gil()
	b = gil()
	a.sort()
	b.sort()
	c = None
	(i, j) = (0, 0)
	while i < n and j < m:
		x1 = a[i]
		x2 = b[j]
		if x1 == x2:
			c = x1
			break
			i += 1
			j += 1
		elif x1 > x2:
			j += 1
		else:
			i += 1
	if c:
		print('YES')
		print(1, c)
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	flag = 0
	for item in brr:
		if item in arr:
			print('YES', 1, item)
			flag = 1
			break
	if flag == 0:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split(' '))
	A = list(map(int, input().split(' ')))
	B = list(map(int, input().split(' ')))
	x = set(A).intersection(set(B))
	if x:
		print('YES')
		print(1, end=' ')
		for i in x:
			print(i)
			break
	else:
		print('NO')


def f(arr1, arr2):
	p = []
	for i in arr1:
		if i in arr2:
			p.append(i)
			return p
	return p
t = int(input())
for i in range(t):
	(n, m) = map(int, input().split())
	arr1 = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	ans = f(arr1, arr2)
	if len(ans) != 0:
		print('YES')
		print(len(ans), *ans, sep=' ')
	else:
		print('NO')


n = int(input())
for i in range(n):
	(size_x, size_y) = map(int, input().split())
	x = list(map(int, input().split()))
	y = list(map(int, input().split()))
	cmn = 0
	for i in x:
		if i in y:
			cmn = 1
			ans = i
			break
	if cmn == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)


n = int(input())
for i in range(n):
	(a, b) = [int(i) for i in input().split()]
	c = [int(i) for i in input().split()]
	d = [int(i) for i in input().split()]
	e = 0
	flag = 0
	for j in range(0, len(c)):
		if c[j] in d:
			e = c[j]
			flag = 1
			break
	if flag == 0:
		print('NO')
	else:
		print('YES')
		print(1, e)


def find(a, b):
	for i in a:
		if i in b:
			return (True, i)
	return (False, -1)
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	(f, p) = find(a, b)
	if not f:
		print('NO')
	else:
		print('YES')
		print(1, p)


t = int(input())
for test in range(t):
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	li = list(map(int, input().split()))
	l.sort()
	li.sort()
	flag = 0
	ls = []
	for i in range(len(l)):
		for j in range(len(li)):
			if l[i] == li[j]:
				flag = 1
				ls.append(l[i])
				break
	if flag == 1:
		print('YES')
		print(1, ls[0])
	if flag == 0:
		print('NO')


import sys
import math
from functools import reduce
import bisect

def getN():
	return int(input())

def getNM():
	return map(int, input().split())

def getList():
	return list(map(int, input().split()))

def input():
	return sys.stdin.readline().rstrip()

def index(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return -1
	return i
for _ in range(int(input())):
	(n, m) = getNM()
	a = getList()
	b = getList()
	ans = []
	for x in a:
		if x in b:
			ans.append(x)
			break
	if ans:
		print('YES')
		print(len(ans), *ans)
	else:
		print('NO')


t = int(input())
while t > 0:
	(n, m) = [int(x) for x in input().split()]
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	i = 0
	j = 0
	flag = 0
	while i < n and j < m:
		if l1[i] == l2[j]:
			print('YES')
			print('1', l1[i])
			flag = 1
			break
		elif l1[i] < l2[j]:
			i += 1
		else:
			j += 1
	if flag == 0:
		print('NO')
	t -= 1


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
MOD = 1000000007
I = lambda : int(input())
M = lambda : map(int, input().split())
Ms = lambda : map(str, input().split())
ARR = lambda : list(map(int, input().split()))

def main():
	(n, m) = M()
	a = ARR()
	b = ARR()
	possible = False
	ans = 0
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				possible = True
				ans = a[i]
				break
		if possible:
			break
	if possible:
		print('YES')
		print(1, ans)
	else:
		print('NO')
tc = I()
for _ in range(tc):
	main()


for cases in range(int(input())):
	(n, m) = map(int, input().split())
	p1 = list(map(int, input().split()))
	p2 = list(map(int, input().split()))
	p1 = set(p1)
	p2 = set(p2)
	a = p1.intersection(p2)
	a = list(a)
	if a == []:
		print('NO')
	else:
		print('YES')
		print(1, a[0])


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	(n, m) = MI()
	a = LI()
	b = LI()
	ans = 0
	boo = False
	for i in range(n):
		for j in range(m):
			if a[i] == b[j]:
				ans = a[i]
				boo = True
				break
		if boo:
			break
	if boo:
		print('YES')
		print(1, ans)
	else:
		print('NO')


a = int(input())
for i in range(0, a):
	(n, m) = input().split()
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	ans = []
	for i in arr:
		if i in brr:
			ans.append(i)
	d = dict()
	for i in brr:
		d[i] = []
	for i in range(0, len(brr)):
		d[brr[i]].append(i)
	k = 0
	if len(ans) > 0:
		print('YES')
		print(1, ans[0])
	else:
		print('NO')


import sys
(_ord, inp, num, neg, _Index) = (lambda x: x, [], 0, False, 0)
(i, s) = (0, sys.stdin.buffer.read())
try:
	while True:
		if s[i] >= b'0'[0]:
			num = 10 * num + _ord(s[i]) - 48
		elif s[i] == b'-'[0]:
			neg = True
		elif s[i] != b'\r'[0]:
			inp.append(-num if neg else num)
			(num, neg) = (0, False)
		i += 1
except IndexError:
	pass
if s and s[-1] >= b'0'[0]:
	inp.append(-num if neg else num)

def fin(size=None):
	global _Index
	if size == None:
		ni = _Index
		_Index += 1
		return inp[ni]
	else:
		ni = _Index
		_Index += size
		return inp[ni:ni + size]
from types import GeneratorType

def recursive(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
t = fin()
for _ in range(t):
	(n, m) = fin(2)
	a = set(fin(n))
	b = set(fin(m))
	if a.intersection(b):
		print('YES', '\n1', list(a.intersection(b))[0])
	else:
		print('NO')


t = int(input())
while t:
	t -= 1
	(n, m) = [int(x) for x in input().split()]
	arr = [int(x) for x in input().split()]
	brr = [int(x) for x in input().split()]
	s1 = set(arr)
	s2 = set(brr)
	s = s1.intersection(s2)
	if not s:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(s.pop())


import sys
import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
input_all = io.BytesIO(os.read(0, os.fstat(0).st_size)).read

def read_int():
	return map(int, input().split())

def read_list():
	return list(map(int, input().split()))

def print_list(l):
	print(' '.join(map(str, l)))
N = int(input())
for i in range(N):
	(l1, l2) = read_int()
	a = set(read_list())
	b = set(read_list())
	tmp = a & b
	if not tmp:
		print('NO')
	else:
		print('YES')
		print('1 %d' % tmp.pop())


import sys

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def rinput():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1000000000.0) + 7
for _ in range(iinput()):
	(n, m) = rinput()
	a = get_list()
	b = get_list()
	ans = []
	flag = False
	for i in range(n):
		if a[i] in b:
			flag = True
			ans = a[i]
			break
	if flag:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	flag = False
	for i in a:
		if flag:
			continue
		if i in b:
			print('YES')
			print(1, i)
			flag = True
	if flag == False:
		print('NO')


from sys import stdin, gettrace
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	(n, m) = map(int, inputi().split())
	aa = {int(a) for a in inputi().split()}
	bb = {int(a) for a in inputi().split()}
	cc = aa & bb
	if cc:
		print('YES')
		print(1, cc.pop())
	else:
		print('NO')

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


import heapq
from collections import deque
from collections import defaultdict
import sys
sys.setrecursionlimit(100000)
I = lambda : list(map(int, input().split(' ')))
for _ in range(int(input())):
	(n, m) = I()
	a = I()
	b = I()
	as_ = set(a)
	bs_ = set(b)
	flag = 0
	ans = None
	for ele in a + b:
		if ele in as_ and ele in bs_:
			ans = ele
			flag = 1
			break
	if flag:
		print('YES')
		print(1, end=' ')
		print(ele)
	else:
		print('NO')


def solve(l1, l2):
	for i in range(len(l1)):
		if l1[i] in l2:
			return l1[i]
	return -1
for _ in range(int(input())):
	(n, m) = [int(x) for x in input().split()]
	l1 = [int(x) for x in input().split()]
	l2 = [int(x) for x in input().split()]
	l1 = sorted(list(set(l1)))
	l2 = sorted(list(set(l2)))
	if len(l1) > len(l2):
		x = solve(l1, l2)
	else:
		x = solve(l2, l1)
	if x == -1:
		print('NO')
	else:
		print('YES')
		print(1, x)


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor, inf
from heapq import *
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc
farr = [1]
ifa = []

def fact(x, mod=0):
	if mod:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr) % mod)
	else:
		while x >= len(farr):
			farr.append(farr[-1] * len(farr))
	return farr[x]

def ifact(x, mod):
	global ifa
	ifa.append(pow(farr[-1], mod - 2, mod))
	for i in range(x, 0, -1):
		ifa.append(ifa[-1] * i % mod)
	ifa = ifa[::-1]

def per(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return fact(i) // fact(i - j)
	return farr[i] * ifa[i - j] % mod

def com(i, j, mod=0):
	if i < j:
		return 0
	if not mod:
		return per(i, j) // fact(j)
	return per(i, j, mod) * ifa[j] % mod

def catalan(n):
	return com(2 * n, n) // (n + 1)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

def inverse(a, m):
	a %= m
	if a <= 1:
		return a
	return (1 - inverse(m, a) * m) // a % m

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class DSU:

	def __init__(self, n):
		self.c = [-1] * n

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def find(self, x):
		if self.c[x] < 0:
			return x
		self.c[x] = self.find(self.c[x])
		return self.c[x]

	def union(self, u, v):
		(u, v) = (self.find(u), self.find(v))
		if u == v:
			return False
		if self.c[u] < self.c[v]:
			(u, v) = (v, u)
		self.c[u] += self.c[v]
		self.c[v] = u
		return True

	def size(self, x):
		return -self.c[self.find(x)]

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def GP(it):
	return [(ch, len(list(g))) for (ch, g) in groupby(it)]

class DLN:

	def __init__(self, val):
		self.val = val
		self.pre = None
		self.next = None

class Trie:

	def __init__(self, d):
		if d >= 0:
			self.left = Trie(d - 1)
		else:
			self.right = Trie(d - 1)
		self.c = 0

	def put(self, x, i):
		if i == -1:
			self.c = 1
			return
		if x & 1 << i:
			self.left.put(x, i - 1)
		else:
			self.right.put(x, i - 1)
t = N()
for i in range(t):
	(n, m) = RLL()
	a = RLL()
	b = RLL()
	s = set(a)
	flag = False
	for x in b:
		if x in a:
			print('YES')
			print(1, x)
			flag = True
			break
	if not flag:
		print('NO')


from collections import Counter
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()))
	if len(set(a) & set(b)) == 0:
		print('NO')
	else:
		print('YES')
		print(1, list(set(a) & set(b))[0])


import math

def mi():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return input().split()
t = ii()
for _ in range(t):
	(n, m) = mi()
	a = li()
	b = li()
	dic_a = {}
	for i in range(n):
		if dic_a.get(a[i]):
			dic_a[a[i]] += 1
		else:
			dic_a[a[i]] = 1
	for i in range(m):
		if dic_a.get(b[i]):
			print('YES')
			print(1, b[i])
			break
	else:
		print('NO')


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()))
	c = 0
	F = [0] * 1001
	for i in range(n):
		F[a[i]] += 1
	for i in range(m):
		if F[b[i]] > 0:
			print('YES')
			print(1, b[i])
			break
	else:
		print('NO')


t = int(input())
for ii in range(t):
	(n, m) = map(int, input().split())
	A = set([])
	B = set([])
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	for x in a:
		A.add(x)
	for x in b:
		B.add(x)
	v = [0] * 1010
	for x in A:
		v[x] += 1
	for x in B:
		v[x] += 1
	ans = -1
	for i in range(1010):
		if v[i] == 2:
			ans = i
			break
	if ans == -1:
		print('NO')
	else:
		print('YES')
		print(1, ans)


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	A = list(map(int, input().split()))
	B = list(map(int, input().split()))
	A.sort()
	flag = 0
	for i in A:
		if i in B:
			flag = 1
			temp = i
			break
	if flag == 1:
		print('YES')
		print(1, temp)
	else:
		print('NO')


ll = lambda : list(map(int, input().split()))
st = lambda : input()
v = lambda : map(int, input().split())
ii = lambda : int(input())
from collections import *
from math import *
from datetime import datetime
from sys import stdin, stdout
for h in range(int(input())):
	(n, m) = v()
	l = set(ll())
	y = set(ll())
	ans = list(l & y)
	if ans:
		print('YES')
		print(1, ans[0])
	else:
		print('NO')


from collections import Counter
for _ in range(int(input())):
	(n, m) = map(int, input().split())
	s1 = set([int(x) for x in input().split()])
	s2 = set([int(x) for x in input().split()])
	s3 = s1.intersection(s2)
	if len(s3):
		print('YES')
		print(1, list(s3)[0])
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ctr = 0
	if n > m:
		l1 = a
		l2 = b
	else:
		l1 = b
		l2 = a
	for i in l1:
		if i in l2:
			print('YES')
			print(1, i)
			ctr = 1
			break
	if ctr == 0:
		print('NO')


t = input()
for i in range(int(t)):
	(n, m) = map(int, input().split())
	a = [int(aa) for aa in input().split()]
	b = [int(aa) for aa in input().split()]
	f = 0
	ans = 0
	for i in a:
		if i in b:
			f = 1
			ans = i
			break
	if f == 1:
		print('YES')
		print('1 %d' % ans)
	else:
		print('NO')


from collections import defaultdict
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	l1.sort()
	l2.sort()
	l1 = list(set(l1))
	l2 = list(set(l2))
	d = defaultdict(lambda : 0)
	for i in range(len(l1)):
		d[l1[i]] += 1
	for i in range(len(l2)):
		d[l2[i]] += 1
	f = 0
	ans = -1
	for (i, j) in d.items():
		if j > 1:
			f = 1
			ans = i
			break
	if f == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


from __future__ import division, print_function
MOD = 998244353
mod = 10 ** 9 + 7

def prepare_factorial():
	fact = [1]
	for i in range(1, 100005):
		fact.append(fact[-1] * i % mod)
	ifact = [0] * 100005
	ifact[100004] = pow(fact[100004], mod - 2, mod)
	for i in range(100004, 0, -1):
		ifact[i - 1] = i * ifact[i] % mod
	return (fact, ifact)
import sys
from bisect import bisect_left, bisect_right, insort
from math import floor, ceil, sqrt, degrees, atan, pi, log, sin, radians
from heapq import heappop, heapify, heappush
from collections import Counter, defaultdict, deque

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, fact, ifact):
	t = fact[n] * (ifact[r] * ifact[n - r]) % mod % mod
	return t

def intarray():
	return map(int, sys.stdin.readline().strip().split())

def array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // GCD(x, y)

def get_xor(n):
	return [n, 1, n + 1, 0][n % 4]

def fast_expo(a, b):
	res = 1
	while b:
		if b & 1:
			res = res * a
			res %= MOD
			b -= 1
		else:
			a = a * a
			a %= MOD
			b >>= 1
	res %= MOD
	return res

def get_n(P):
	ans = (-1 + sqrt(1 + 8 * P)) // 2
	return ans

def solve():
	(n, m) = intarray()
	a = array()
	b = array()
	s1 = set(a)
	s2 = set(b)
	s = s1.intersection(s2)
	if s:
		for i in s:
			print('YES')
			print(1, i)
			break
	else:
		print('NO')
	return

def main():
	T = int(input())
	while T:
		solve()
		T -= 1
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	f = 0
	for i in range(0, len(a)):
		if a[i] in b:
			print('YES')
			print(1, a[i])
			f = 1
			break
	if f == 0:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = sorted(list(map(int, input().split())))
	b = sorted(list(map(int, input().split())))
	A = []
	for i in range(n):
		if a[i] in b:
			A.append(a[i])
			break
	if len(A) > 0:
		print('YES')
		print(1, *A)
	else:
		print('NO')


t = int(input(''))
for l in range(t):
	s = input('')
	st = s.split(' ')
	n = int(st[0])
	m = int(st[1])
	li1 = list(map(int, input().split()))[:n]
	li2 = list(map(int, input().split()))[:m]
	dic1 = dict()
	dic2 = dict()
	flag = True
	for i in li1:
		if i in dic1:
			dic1[i] += 1
		else:
			dic1[i] = 1
	for i in li2:
		if i in dic2:
			dic2[i] += 1
		else:
			dic2[i] = 1
	for i in dic1:
		if i in dic2:
			print('YES')
			print(1, i)
			flag = False
			break
	if flag:
		print('NO')


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(r1, r2) = [set(map(int, input().split())) for _ in range(2)]
	for u in r1:
		if u in r2:
			print('YES')
			print(1, u)
			break
	else:
		print('NO')


for _ in range(int(input())):
	l = input().split()
	a = input().split()
	b = input().split()
	k = 0
	for i in a:
		if i in b:
			k = i
			break
	if k != 0:
		print('YES')
		print(1, k)
	else:
		print('NO')


def binarySearch(arr, l, r, x):
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	a.sort()
	b.sort()
	ans = -1
	for i in range(n):
		temp = binarySearch(b, 0, m - 1, a[i])
		if temp != -1:
			ans = a[i]
			break
	if ans != -1:
		print('YES')
		print(f'1 {ans}')
	else:
		print('NO')


t = int(input())
for k in range(t):
	nm = list(map(int, input().split()))
	n = nm[0]
	m = nm[1]
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))

	def common(list1, list2):
		result = 0
		for x in list1:
			for y in list2:
				if x == y:
					result = x
		return result
	if common(a, b) == 0:
		print('NO')
	else:
		del a[0:a.index(common(a, b))]
		del b[0:b.index(common(a, b))]
		print('YES')
		print(1, a[0])


for t in range(int(input())):
	(_, _) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	a = a.intersection(b)
	if len(a) == 0:
		print('NO')
	else:
		print('YES')
		for i in a:
			print(1, i)
			break


t = int(input())
for hh in range(0, t):
	(n, m) = [int(x) for x in input().split()]
	a = [int(x) for x in input().split()]
	b = [int(x) for x in input().split()]
	d = dict()
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	flag = 0
	for i in range(0, len(b)):
		val = b[i]
		if val in d:
			flag = 1
			ans = val
			break
	if flag == 1:
		print('YES')
		print(1, ans)
	else:
		print('NO')


t = int(input())
for j in range(t):
	(n, m) = map(int, input().split(' '))
	list1 = list(map(int, input().split(' ')))
	list2 = list(map(int, input().split(' ')))
	k = 0
	if n > m:
		for j in list1:
			if j in list2:
				print('YES')
				print(1, j)
				k += 1
				break
	else:
		for j in list1:
			if j in list2:
				print('YES')
				print(1, j)
				k += 1
				break
	if not k:
		print('NO')


def binarySearchAppr(arr, start, end, x):
	if end >= start:
		mid = start + (end - start) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] > x:
			return binarySearchAppr(arr, start, mid - 1, x)
		else:
			return binarySearchAppr(arr, mid + 1, end, x)
	else:
		return -1
t = int(input(''))
aa = []
bb = []
for i in range(t):
	input('')
	aa.append(list(map(int, input().split())))
	bb.append(list(map(int, input().split())))
for i in range(t):
	a = aa[i]
	b = bb[i]
	a = sorted(a)
	b = sorted(b)
	sign = 0
	for i in range(len(a)):
		x = binarySearchAppr(b, 0, len(b) - 1, a[i])
		if x != -1:
			sign = 1
			sol = a[i]
			break
	if sign == 0:
		print('NO')
	else:
		print('YES')
		print(1, sol)


t = int(input())
while t:
	t -= 1
	(x, y) = map(int, input().split())
	m = list(map(int, input().split()))
	n = list(map(int, input().split()))
	c = set()
	s = []
	for i in m:
		if i not in s:
			c.add(i)
	for i in c:
		if i in n:
			s.append([i])
	if s:
		if s[-1]:
			print('Yes')
			print(len(s[-1]), *s[0])
		else:
			print('No')
	else:
		print('No')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
Read = lambda : list(map(int, input().split()))
Num = lambda : int(input())
exec("try:sys.stdin=open('in.txt','r');sys.stdout=open('out.txt','w')\nexcept:pass")

def solve():
	(n, m) = Read()
	a = Read()
	b = Read()
	for i in a:
		if i in b:
			print('YES')
			print(1, i)
			return
	print('NO')
for _ in range(Num()):
	solve()


def intersection(lst1, lst2):
	return list(set(lst1) & set(lst2))
t = int(input())
for _ in range(t):
	(n, m) = list(map(int, input().split()))
	lst1 = list(map(int, input().split()))
	lst2 = list(map(int, input().split()))
	ans = intersection(lst1, lst2)
	if len(ans) > 0:
		print('YES')
		print(1, end=' ')
		(print(ans[0]),)
	else:
		print('NO')


t = int(input())
for f in range(t):
	(n, m) = map(int, input().split())
	n_arr = list(map(int, input().strip().split()))
	m_arr = list(map(int, input().strip().split()))
	a = -1
	for i in range(n):
		for j in range(m):
			if n_arr[i] == m_arr[j]:
				a = n_arr[i]
				break
	if a != -1:
		print('YES')
		print(1, a)
	else:
		print('NO')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	arr = list(map(int, input().split()))
	arr2 = list(map(int, input().split()))
	var = -1
	if n > k:
		for j in range(n):
			if arr[j] in arr2:
				var = arr[j]
				break
		if var != -1:
			print('YES')
			print(1, var)
		else:
			print('NO')
	else:
		for j in range(k):
			if arr2[j] in arr:
				var = arr2[j]
				break
		if var != -1:
			print('YES')
			print(1, var)
		else:
			print('NO')


for _ in range(int(input())):
	(n1, n2) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	x = []
	for i in a:
		if i in b:
			print('YES\n1', i)
			break
	else:
		print('NO')


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()))
	rs = -1
	for e in range(len(a)):
		if rs == -1:
			for j in range(len(b)):
				if a[e] == b[j]:
					rs = a[e]
					break
		else:
			break
	if rs != -1:
		print('YES')
		print(1, rs)
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(list(map(int, input().split())))
	b = set(list(map(int, input().split())))
	if a.intersection(b):
		for num in a:
			if num in b:
				print('YES')
				print(f'{1} {num}')
				break
	else:
		print('NO')


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
Read = lambda : list(map(int, input().split()))
Num = lambda : int(input())

def solve():
	(n, m) = Read()
	a = Read()
	b = Read()
	for i in range(n):
		if a[i] in b:
			print('YES')
			print(1, a[i])
			return
	print('NO')
for _ in range(Num()):
	solve()


ls = lambda : list(map(int, input().split()))
ip = lambda : int(input())
r = lambda a: range(a)
t = ip()
for _ in r(t):
	(m, n) = ls()
	arr_m = ls()
	arr_n = ls()
	sm = set(arr_m)
	sn = set(arr_n)
	p = False
	for i in sm:
		if i in sn:
			p = True
			print('YES')
			print('1 ' + str(i))
			break
	if not p:
		print('NO')


from collections import defaultdict

def intersection(l1, l2):
	return list(set(l1) & set(l2))
t = int(input())
while t:
	t -= 1
	(n, m) = map(int, input().split())
	l = list(map(int, input().split()))
	ll = list(map(int, input().split()))
	ans = intersection(l, ll)
	if len(ans) == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans[0])


t = int(input())
for case in range(t):
	(n, m) = map(int, input().split())
	a = input().split()
	b = input().split()
	yes = False
	for i in range(n):
		if a[i] in b:
			yes = True
			print('YES')
			print('1 ' + a[i])
			break
	if yes == False:
		print('NO')


def R():
	return map(int, input().split())
for _ in range(int(input())):
	(n, m) = R()
	a = list(R())
	b = list(R())
	pos = False
	for i in a:
		if i in b:
			pos = True
			ans = i
			break
	if pos:
		print('YES')
		print(1, ans)
	else:
		print('NO')


from sys import stdin, stdout
import math
from collections import Counter, deque
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
IN = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()
mod = 1000000007

def s(a):
	print(''.join(list(map(str, a))))

def solve():
	(n, m) = M()
	a = L()
	b = L()
	c = set(a).intersection(set(b))
	c = list(c)
	if c:
		print('YES')
		print(1, c[0])
	else:
		print('NO')
for _ in range(I()):
	solve()


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	arr = list(map(int, input().split()))
	brr = list(map(int, input().split()))
	p = 0
	v = []
	for i in arr:
		if i in brr:
			z = brr.count(i)
			for j in range(z):
				v.append(i)
				p = 1
	if p:
		print('YES')
		print(1, v[0])
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	s_a = set(a)
	s_b = set(b)
	res = s_a & s_b
	res = list(res)
	if len(res) > 0:
		print('YES')
		print(1, res[0])
	else:
		print('NO')


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()))
	ans = 0
	yep = False
	for i in range(len(a)):
		if a[i] in b:
			ans = a[i]
			yep = True
			break
	if yep:
		print('YES')
		print(1, a[i])
	else:
		print('NO')


def main(a, b):
	d = {}
	for i in a:
		d[i] = True
	for i in b:
		if i in d:
			return i
	return None
t = int(input())
for case in range(t):
	(n, m) = map(int, input().split())
	a = input().split()
	b = input().split()
	r = main(a, b)
	if r:
		print('YES')
		print(1, r)
	else:
		print('NO')


for t in range(int(input())):
	(n, m) = map(int, input().strip().split())
	arr = list(map(int, input().strip().split()))
	brr = list(map(int, input().strip().split()))
	flag = True
	for i in arr:
		if i in brr:
			print('YES')
			print(1, i)
			flag = False
			break
	if flag:
		print('NO')


from collections import defaultdict as dd
import sys
input = sys.stdin.readline
t = int(input())
while t:
	d = dd(int)
	(n, m) = map(int, input().split())
	l1 = list(map(int, input().split()))
	l2 = list(map(int, input().split()))
	ans = -1
	lol = 0
	for i in l1:
		d[i] = 1
	for i in l2:
		if d[i]:
			ans = i
			lol = 1
	if lol == 0:
		print('NO')
	else:
		print('YES')
		print(1, ans)
	t -= 1


t = int(input())
for _ in range(0, t):
	(n, m) = map(int, input().split())
	a = list(map(int, input().split()))
	b = list(map(int, input().split()))
	ok = False
	for i in range(0, n):
		if b.count(a[i]) != 0:
			print('YES')
			print(1, a[i])
			ok = True
			break
	if not ok:
		print('NO')


def solve(f, g):
	found = False
	for item in f:
		if item in g:
			l = 1
			item = item
			found = True
			break
	if found:
		print('YES')
		print('{} {}'.format(1, item))
	else:
		print('NO')

def main():
	for i in range(int(input())):
		(n, h) = map(int, input().split())
		f = [int(x) for x in input().split()]
		g = [int(x) for x in input().split()]
		solve(f, g)
main()


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n, m) = I()
	a = I()
	b = I()
	an = -1
	x = [0] * 1009
	for i in a:
		x[i] = 1
	for i in b:
		if x[i]:
			an = i
			break
	if an != -1:
		print('YES')
		print(1, an)
	else:
		print('NO')


import sys
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	a = set(map(int, input().split()))
	b = set(map(int, input().split()))
	c = a.intersection(b)
	if c:
		print('YES')
		print('1 {}'.format(c.pop()))
	else:
		print('NO')


for _ in range(int(input())):
	(n, m) = map(int, input('').split())
	A = list(map(int, input('').split()))
	B = list(map(int, input('').split()))
	count = dict()
	for i in A:
		count[i] = True
	flag = 0
	for i in B:
		if i in count.keys():
			flag = 1
			break
	if flag == 1:
		print('YES')
		print(1, i)
	else:
		print('NO')


count = int(input())
for i in range(count):
	(n, m) = map(int, input().split(' '))
	list_n = list(map(int, input().split(' ')))
	list_m = list(map(int, input().split(' ')))
	for j in range(n):
		if list_n[j] in list_m:
			print('YES')
			print(1, list_n[j])
			break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	(n, m) = map(int, input().split())
	al = list(map(int, input().split()))
	bl = list(map(int, input().split()))
	num = -1
	found = 0
	for i in range(n):
		for j in range(m):
			if al[i] == bl[j]:
				num = al[i]
				found = 1
				break
		if found == 1:
			break
	if found == 1:
		print('YES')
		print(1, num)
	else:
		print('NO')


from sys import stdin
input = lambda : stdin.readline().rstrip('\r\n')
from collections import deque as que, defaultdict as vector
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
Testcase = inin()
for _ in range(Testcase):
	(n, m) = inar()
	a = set(inar())
	b = set(inar())
	x = a.intersection(b)
	x = list(x)
	if x == []:
		print('NO')
	else:
		print('YES')
		print(1, x[0])


from __future__ import division, print_function
from collections import *
from math import *
from itertools import *
import os
import sys
from io import BytesIO, IOBase
import math
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	arr = []
	d = False
	for L in range(t):
		(n, m) = map(int, input().split())
		a = list(map(int, input().split()))
		b = list(map(int, input().split()))
		f = True
		if min(n, m) == n:
			for t in a:
				if t in b:
					print('YES')
					print('1 ' + str(t))
					f = False
					break
			if f:
				print('NO')
		else:
			for t in b:
				if t in a:
					print('YES')
					print('1 ' + str(t))
					f = False
					break
			if f:
				print('NO')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
while t != 0:
	(n1, n2) = map(int, input().split())
	arr = [int(x) for x in input().split()]
	arr1 = [int(y) for y in input().split()]
	res = 0
	y_n = 'NO'
	for i in range(len(arr)):
		for j in range(len(arr1)):
			if arr[i] == arr1[j]:
				res = arr[i]
				y_n = 'YES'
	if y_n == 'YES':
		print(y_n)
		print('1', res)
	else:
		print(y_n)
	t -= 1


from sys import stdin, stdout
import math
import heapq
t = 1

def aint():
	return int(input().strip())

def lint():
	return list(map(int, input().split()))

def fint():
	return list(map(int, stdin.readline().split()))

def main():
	(a, b) = lint()
	l1 = lint()
	l2 = lint()
	for i in l1:
		if i in l2:
			print('YES')
			print('1', i)
			return
	print('NO')
	return
t = int(input())
for i in range(t):
	main()


n = int(input())
result = []
for i in range(n):
	(l1, l2) = map(int, input().split())
	list1 = input().split()
	list2 = input().split()
	set1 = set(list1)
	set2 = set(list2)
	set1 = set1.intersection(set2)
	if set1:
		result.append(list(set1))
	else:
		result.append(0)
for i in result:
	if i == 0:
		print('NO')
	else:
		print('YES')
		print(1, end=' ')
		print(i[0], end=' ')
		print()


t = int(input())
for i in range(t):
	mn = input()
	mn = mn.split(' ')
	m = int(mn[0])
	n = int(mn[1])
	a = input()
	a = a.split(' ')
	b = input()
	b = b.split(' ')
	if a == b:
		print('YES')
		print(1, min(a))
	elif len(a) == 1 and len(b) == 1 and (a != b):
		print('NO')
	elif len(a) < len(b):
		ans = []
		for j in a:
			if j in b:
				ans.append(j)
		if len(ans) != 0:
			print('YES')
			print(1, min(ans))
		else:
			print('NO')
	else:
		ans = []
		for j in b:
			if j in a:
				ans.append(j)
		if len(ans) != 0:
			print('YES')
			print(1, min(ans))
		else:
			print('NO')


import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline

def solve(a, b):
	for aa in a:
		if aa in b:
			return aa
	else:
		return None

def main():
	t = int(input())
	arr = []
	for _ in range(t):
		input()
		a = list(map(int, input().split(' ')))
		b = list(map(int, input().split(' ')))
		arr.append([a, b])
	for i in range(t):
		(a, b) = arr[i]
		ans = solve(a, b)
		if ans:
			print('YES')
			print(f'1 {ans}')
		else:
			print('NO')
main()


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	arr1 = [int(x) for x in input().split()]
	arr2 = [int(x) for x in input().split()]
	flag = False
	for i in arr1:
		for j in arr2:
			if i == j:
				print('YES')
				print('1', i)
				flag = True
				break
		if flag == True:
			break
	if flag == False:
		print('NO')


def hello():
	from collections import Counter
	(a, b) = map(int, input().split(' '))
	arr1 = list(map(int, input().split(' ')))
	arr2 = list(map(int, input().split(' ')))
	arr1.sort()
	f = set(arr1)
	g = set(arr2)
	arr2.sort()
	flag = False
	ans = []
	first = Counter(f)
	second = Counter(g)
	for i in first:
		if i in second:
			ans.append(first[i])
			ans.append(i)
			return ans
		else:
			continue
	return ans
for _ in range(int(input())):
	s = hello()
	if len(s) != 0:
		print('YES')
		print(*s)
	else:
		print('NO')


for i in range(int(input())):
	z = input().split()
	n = input().split()
	m = input().split()
	bol = False
	for i in n:
		if i in m:
			print('YES\n1', i)
			bol = True
			break
	if not bol:
		print('NO')


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import Counter
for _ in range(ii()):
	(n, m) = f()
	a = il()
	b = il()
	c = 0
	for i in range(0, n):
		if a[i] in b and c == 0:
			print('YES')
			print(1, a[i])
			c = c + 1
			break
	if c == 0:
		print('NO')


from math import log2, ceil, floor
from collections import defaultdict, OrderedDict, Counter, deque
from heapq import heappush, heappop, heapify
import re

def inp():
	return input()

def list_inp():
	return list(map(int, input().split()))

def map_inp():
	return map(int, input().split())

def int_inp():
	return int(input())

def float_int():
	return float(input())

def isprime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for _ in range(int_inp()):
	(n, m) = map_inp()
	a = list_inp()
	b = list_inp()
	c = -1
	if n <= m:
		l = 0
		ran = n
	else:
		l = 1
		ran = m
	for i in range(ran):
		if l == 0:
			if a[i] in b:
				c = a[i]
				break
		elif b[i] in a:
			c = b[i]
			break
	if c == -1:
		print('No')
	else:
		print('Yes')
		print(1, c)