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[])
        {
                Scanner in = new Scanner(System.in);
                int t;
                t=in.nextInt();
                while(t>0)
                {
                        int n,m,tempa,tempb;
                        n=in.nextInt();
                        m=in.nextInt();
                        ArrayList<Integer> a = new ArrayList<Integer>(n);
                        ArrayList<Integer> b = new ArrayList<Integer>(m);
                        ArrayList<Integer> c = new ArrayList<Integer>();
                        for(int i=0;i<n;i++)
                        {
                                tempa=in.nextInt();
                                a.add(tempa);
                        }
                        for(int j=0;j<m;j++)
                        {
                                tempb=in.nextInt();
                                b.add(tempb);
                                if(a.contains(tempb))
                                        c.add(tempb);
                        }

                        if(c.size()!=0)
                        {
                                System.out.println("YES");
                                System.out.print(c.size()+" ");
                                for (int k = 0; k < c.size(); k++)
                                        System.out.print(c.get(k) + " ");
                        }
                        else
                                System.out.println("NO");
                        System.out.println();
                        t-=1;
                }
        }
}
