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

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		for(int i=0;i<t;i++) {
			int l1=sc.nextInt();
			int l2=sc.nextInt();
			int[] j1=new int[l1];
			int[] j2=new int[l2];
			List list=new ArrayList();
			for(int k=0;k<j1.length;k++) {
				j1[k]=sc.nextInt();
			}for(int m=0;m<j2.length;m++) {
				j2[m]=sc.nextInt();
			}
			for(int p:j1) {
				for(int q=0;q<j2.length;q++) {
					if(j2[q]==p) {
						list.add(p);
break;
					}
if(!list.isEmpty()){
break;}
					
					
				}
			if(!list.isEmpty()) {
				System.out.println("YES");
				System.out.print(list.size()+" ");
				for(Object d:list) {
					System.out.print(d);
				}}
				else {
					System.out.println("NO");
				}}
				
			}
			
		}
		
		
		
	
			
			
			
			
			
		
	
		
		
		
		
		
		
		

	}



		
		
		
	
			
			
			
			
			
		
	
		
		
		
		
		
		
		

