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

#include<stdio.h>

void merge(int arr[], int start, int mid, int end){
  int i, j;
  int leftLen = mid - start ;
  int rightLen = end - mid;
  int totLen = leftLen + rightLen;

  int leftArr[leftLen], rightArr[rightLen];

  for( i = 0; i < leftLen; i++){
    leftArr[i] = arr[start + i];
  }

  for( i = 0; i < rightLen; i++){
    rightArr[i] = arr[mid + i];
  }


  i = 0;
  j = 0;
  int k = start;
  while(i < leftLen && j < rightLen)
  {
    if(leftArr[i] <= rightArr[j])
    {
      arr[k] = leftArr[i];
      i++;
    }
    else{
      arr[k] = rightArr[j];
      j++;
    }
    k++;
  }

  if(i < leftLen){
    while(i < leftLen){
      arr[k] = leftArr[i];
      i++;
      k++;
    }
  }

  if(j < rightLen){
    while(j < rightLen){
      arr[k] = rightArr[j];
      j++;
      k++;
    }
  }
}

void sort(int arr[], int start, int end){
  int len = end - start;
  if(len == 1){
    return;
  }
  int mid = start + (len / 2);
  sort(arr, start, mid);
  sort(arr, mid, end);

  merge(arr, start, mid, end);
}

int search(int arr[], int start,int end, int ele){
  if (start <= end) {
    int mid = start + (end - start) / 2;

    if(arr[mid] == ele){
      return 1;
    }

    if(arr[mid] > ele){
      return search(arr, start, mid - 1, ele);
    }

    return search(arr, mid + 1, end, ele);
  }

  return 0;
}

void main(void){
  int test, l1, l2, i, temp, found , ans;
  scanf("%d", &test);
  while (test--){
    found = 0;
    scanf("%d%d", &l1, &l2);
    int arr1[l1];
    for (i = 0; i < l1; i++){
      scanf("%d", &arr1[i]);
    }

    sort(arr1, 0, l1);
    for (i = 0; i < l2; i++){
      scanf("%d", &temp);
      if(found == 0){
        if(search(arr1, 0, l1, temp) == 1){
          found = 1;
          ans = temp;
        }
      }
    }
    if(found == 0){
      printf("NO\n");
    }
    else{
      printf("YES\n1 %d", ans);
    }
  }
}
