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 Main {

    public static void main(String[] args) {
        // write your code here
        Scanner in = new Scanner(System.in);
        int t=in.nextInt();
        while(t-->0)
        {
            int n=in.nextInt();
            int m=in.nextInt();
            int arr[]=new int[n];
            int arr1[]=new int[m];
            Map<Integer,Integer> map=new LinkedHashMap<>();
            for(int i=0;i<n;i++)
            {
                arr[i]=in.nextInt();
                map.put(arr[i],1);
            }
            for(int i=0;i<m;i++)
            {
                arr1[i]=in.nextInt();
                try{
                    map.put(arr1[i],map.get(arr1[i])+1);
                }catch (Exception e)
                {
                    map.put(arr1[i],1);
                }
            }
            boolean b=false;
            for(Integer i:map.keySet())
            {
                if(map.get(i)!=1)
                {
                    System.out.println("YES"+" ");
                    System.out.println(1+" "+i);
                    b=true;
                    break;
                }
            }
            if(b==false)
                System.out.println("NO");
        }
    }
}
