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

import java.util.*;
public class subseq
{
	public static void main(String[] args) {
		int t,i,j,l=0,bc=0,m=0;
		Scanner sc = new Scanner(System.in);
		t=sc.nextInt();
		for(i=0;i<t;i++)
		{
			int l1=sc.nextInt();
			int l2= sc.nextInt();
			int a[]= new int[l1];
			int b[]= new int[l2];
			for(j=0;j<l1;j++)
			{
				a[j] = sc.nextInt();
			}
			for(j=0;j<l2;j++)
			{
				b[j] = sc.nextInt();
			}
			for(int k = 0;k<l2;k++)
			{

			for(j=0;j<l1;j++)
			{
             if(a[j]==b[k])
             {
             	l=1;
                m=a[j];
             	bc++;
             	
             }
			}
		}
		if(bc==0)
			System.out.println("NO");
		else
		{
			System.out.println("YES");
			System.out.println(l+" "+m);
		}
		bc=0;m=0;
	}
}
}