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 com{
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        List<Integer> l=new ArrayList<>();
        List<Integer> l1=new ArrayList<>();
        int t=sc.nextInt();
        while(t-- > 0){
            l.clear();
            l1.clear();
            int n=sc.nextInt();
            int m=sc.nextInt();
            int x=n;
            int y=m;
            int c=0;
            while(x-- > 0){
                l.add(sc.nextInt());
            }
            while(y-- > 0){
                l1.add(sc.nextInt());
            }
            if(m >= n){
                for(int i=0; i<l.size(); i++){
                    if(l1.contains(l.get(i))){
                        System.out.println("YES");
                        System.out.println("1 "+ l.get(i));
                        break;
                    }else{
                        c++;
                    }
                }
            }else{
              for(int i=0; i<l1.size(); i++) {
                    if(l.contains(l1.get(i))){
                        System.out.println("YES");
                        System.out.println("1 "+ l1.get(i));
                        break;
                    }else{
                        c++;
                    }
                } 
            }
            if(c == l.size() || c == l1.size()){
                System.out.println("NO");
            }
        }
    }
}