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.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

/**
 *
 * @author bd340
 */
public class Mon {
    
    
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
       int n=sc.nextInt();
       
       for(int i=0;i<n;i++)
       {
           int[] a=new int[1001];
           int z=sc.nextInt();
           int x=sc.nextInt();
           int w=0;
           int[] b=new int[z];
           int[] v=new int[x];
           
           for(int j=0;j<z;j++)
           {
               int y=sc.nextInt();
              // b[i]=y;
               a[y]=1;
           }
           
           for(int k=0;k<x;k++)
           {
               int u=sc.nextInt();
               v[k]=u;
               
               if(a[u]==1)
               {
                   w=v[k];
               }
           }
           
           if(w>0)
           {
               System.out.println("YES");
           
               System.out.println(1+" "+w);
           }
           else
               System.out.println("NO");
           
           
       }
       
       
       
       
       
       
             }
} 
           
      
     
    