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, i, j, l = 0;
  cin >> t;
  int a[101], b[101];
  while (t--) {
    cin >> n >> m;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (j = 0; j < m; j++) {
      cin >> b[j];
    }
    vector<int> v;
    for (i = 0, j = 0; i < n, j < m; i++, j++) {
      if (a[i] == b[j]) {
        v.push_back(a[i]);
        break;
      }
      if (v.size() == 1) {
        break;
      }
    }
    if (v.size() == 0) {
      cout << "NO\n";
    } else {
      cout << "YES" << endl;
      cout << v.size() << " ";
      for (i = 0; i < v.size(); i++) {
        cout << v[i] << endl;
      }
    }
  }
}
