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

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

# -*- coding: utf-8 -*-
"""
Created on Tue Jul 21 20:41:27 2020

@author: Dark Soul
"""
def binarySearchAppr (arr, start, end, x):
# check condition
    if end >= start:
        mid = start + (end- start)//2
      # If element is present at the middle
        if arr[mid] == x:
            return mid
      # If element is smaller than mid
        elif arr[mid] > x:
            return binarySearchAppr(arr, start, mid-1, x)
      # Else the element greator than mid
        else:
            return binarySearchAppr(arr, mid+1, end, x)
    else:
      # Element is not found in the array
        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)
        
        
        