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 <bits/stdc++.h>
int main() {
  int t, m, n, k;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &n, &m);
    int arr1[n], arr2[m], i, max = 0;
    int freq[1000] = {0};
    for (i = 0; i < n; i++) {
      scanf("%d", &arr1[i]);
      if (arr1[i] > max) max = arr1[i];
      freq[arr1[i]]++;
    }
    for (i = 0; i < m; i++) {
      scanf("%d", &arr2[i]);
      if (arr2[i] > max) max = arr2[i];
      freq[arr2[i]]++;
    }
    k = 0;
    int ans[max];
    for (i = 1; i <= max; i++) {
      if (freq[i] != 0 && freq[i] % 2 == 0) {
        ans[k] = i;
        k++;
      }
    }
    if (k == 0)
      printf("NO\n");
    else {
      printf("YES\n");
      int min = ans[0];
      for (i = 1; i < k; i++) {
        if (ans[k] < min) min = ans[k];
      }
      printf("1 %d", min);
      printf("\n");
    }
  }
  return 0;
}
