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.Scanner;

public class Main
{
	public static boolean binarySearch(int arr[], int l, int r, int x) 
    { 
        if (r >= l) { 
            int mid = l + (r - l) / 2; 
  
            if (arr[mid] == x) 
                return true; 
   
            if (arr[mid] > x) 
                return binarySearch(arr, l, mid - 1, x); 
  
            return binarySearch(arr, mid + 1, r, x); 
        } 
  
        return false; 
    } 
    
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner (System.in);
		int tCase = sc.nextInt();
		
		for(int t = 0; t<tCase; t++){
			int n = sc.nextInt();
			int m = sc.nextInt();
			
			int aN [] = new int[n];
			int aM [] = new int[m];
			
			for(int i = 0; i<n; i++)
				aN[i] = sc.nextInt();
				
			for(int i = 0; i<m; i++)
				aM[i] = sc.nextInt();
				
			if(m>n){
				boolean decision = true;
				for(int i = 0; i<n; i++){
					if(binarySearch(aM, 0, m - 1, aN[i])){
						System.out.println("Yes\n1 "+aN[i]);
						decision = false;
						break;
					}
				}
				if(decision)
					System.out.println("No");
					
			}else{
				boolean decision = true;
				for(int i = 0; i<m; i++){
					if(binarySearch(aN, 0, n - 1, aM[i])){
						System.out.println("Yes\n1 "+aM[i]);
						decision = false;
						break;
					}
					if(decision)
						System.out.println("No");	
				}
			}
		}
	}
}