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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Problem3 {
    public static void main (String [] args) throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        //--------------------------START CODING HERE-----------------------------


        int t = Integer.parseInt(f.readLine());

        while(t-- > 0)
        {
            StringTokenizer st = new StringTokenizer(f.readLine());

            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());

            st = new StringTokenizer(f.readLine());


            int[] aArr = new int[a];
            for(int i = 0; i < a; i++)
            {
                aArr[i] = Integer.parseInt(st.nextToken());
            }

            st = new StringTokenizer(f.readLine());
            int[] bArr = new int[b];
            for(int i = 0; i < b; i++)
            {
                bArr[i] = Integer.parseInt(st.nextToken());
            }

            boolean toBreak = false;

            for(int e: aArr)
            {
                for(int l: bArr)
                {
                    if(e==l)
                    {
                        out.println("YES");
                      toBreak=true;
                      out.println(1+" "+e);
                    }
                }
                if(toBreak)break;
            }
            if(!toBreak)out.print("NO");


        }
        out.close();
    }
}