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() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, i, j, k, l, m, t, sum, sum1, flag, max1, min1;
  cin >> t;
  while (t--) {
    cin >> n >> m;
    long long a[n + 1], b[n + 1];
    map<long long, long long> mp;
    vector<long long> v;
    for (i = 1; i <= n; i++) {
      cin >> a[i];
      mp[a[i]]++;
      v.push_back(a[i]);
    }
    for (i = 1; i <= m; i++) {
      cin >> b[i];
      mp[b[i]]++;
      v.push_back(b[i]);
    }
    flag = 0;
    for (i = 0; i < m + n; i++) {
      if (mp[v[i]] >= 2) {
        cout << "YES\n";
        cout << 1 << " ";
        cout << v[i] << endl;
        flag = 1;
        break;
      }
    }
    if (flag == 0) {
      cout << "NO\n";
    }
  }
}
