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>
using namespace std;
int main() {
  int t, n, m;
  cin >> t;
  for (int i = 0; i < t; i++) {
    cin >> n >> m;
    int a[1001] = {}, b[1001] = {}, p;
    for (int j = 0; j < n; j++) {
      cin >> p;
      a[p]++;
    }
    for (int j = 0; j < m; j++) {
      cin >> p;
      b[p]++;
    }
    for (int j = 1; j <= 1000; j++) {
      int ma = (a[j] + b[j]) % 2;
      int ab = abs(a[j] - b[j]);
      int ac = abs(n - m);
      if (a[j] > 0 && b[j] > 0 && (ma == 0 || ab == ac)) {
        cout << "YES" << endl << 1 << " " << j << endl;
        break;
      }
      if (j == 1000) cout << "NO" << endl;
    }
  }
}
