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;
vector<int> graph[200001];
vector<int> visit;
long long int power(int n) {
  if (n == 0) return 1;
  if (n == 1) return 2;
  if (n % 2)
    return ((((power(n / 2)) % 1000000007) * (power(n / 2) % 1000000007) %
             1000000007) *
            2) %
           1000000007;
  return (((power(n / 2)) % 1000000007) * (power(n / 2) % 1000000007) %
          1000000007);
}
void solve() {
  int i, n, m;
  cin >> n >> m;
  int a[1001], b[1001];
  cin >> n >> m;
  int arr;
  for (i = 0; i < n; i++) {
    cin >> arr;
    a[arr] = 1;
  }
  for (i = 0; i < m; i++) {
    cin >> arr;
    b[arr] = 1;
  }
  for (i = 1; i <= 1000; i++)
    if (a[i] == b[i] && a[i] == 1) {
      cout << "YES"
           << " " << 1 << " " << i << endl;
      return;
    }
  cout << "NO" << endl;
}
int main() {
  int t;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
