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.*;
import java.util.*;

import static java.lang.Integer.parseInt;

public class Div2_A {
    public static void main(String[] args) throws IOException {
        StringTokenizer st;
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);

        int t = parseInt(read.readLine());

        for (int i = 0; i < t; i++) {
            st = new StringTokenizer(read.readLine());
            int n = parseInt(st.nextToken());
            int m = parseInt(st.nextToken());
            ArrayList<Integer> arr = new ArrayList<>();
            ArrayList<Integer> arr1 = new ArrayList<>();
            st = new StringTokenizer(read.readLine());
            for (int j = 0; j < n; j++) {
                arr.add(parseInt(st.nextToken()));
            }
            st = new StringTokenizer(read.readLine());
            for (int k = 0; k < m; k++) {
                arr1.add(parseInt(st.nextToken()));
            }
            int flag = 0;
            for (int it : arr) {
                if (arr1.contains(it)) {
                    if (arr1.indexOf(it) > 0) {
                        prnt.println("YES" + "\n" + 1 + " " + (arr1.indexOf(it) + 1));
                    } else {
                        prnt.println("YES" + "\n" + 1 + " " + (arr1.indexOf(it) + 2));
                    }
                    flag = 1;
                    break;
                }
            }
            if (flag == 0) {
                prnt.println("NO");
            }
        }
        prnt.close();
    }
}