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;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  long long t, i, j, a, b;
  cin >> t;
  for (int z = 1; z <= t; z++) {
    cin >> a >> b;
    int x[a], y[b];
    for (i = 0; i <= a - 1; i = i + 1) cin >> x[i];
    for (i = 0; i <= b - 1; i = i + 1) cin >> y[i];
    for (i = 0; i <= a - 1; i = i + 1) {
      for (j = 0; j <= b - 1; j = j + 1) {
        if (x[i] == y[j]) {
          cout << "YES"
               << "\n";
          cout << "1 " << x[i] << "\n";
          a = 0;
          goto A;
        }
      }
    }
  A:
    if (a)
      cout << "NO"
           << "\n";
  }
  return 0;
}
