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 cnt[1005];
int main() {
  ios::sync_with_stdio(0);
  memset(cnt, 0, sizeof(cnt));
  int t, n, m;
  int a[1000];
  int b[1000];
  bool notthere = true;
  for (int i = 0; i < t; i++) {
    cin >> n;
    cin >> m;
    for (int j = 0; j < n; j++) {
      cin >> a[j];
      cnt[a[j]]++;
    }
    for (int k = 0; k < m; k++) {
      cin >> b[k];
      if (cnt[b[k]] != 0 && notthere) {
        cout << "YES" << endl;
        cout << "1 " << b[k] << endl;
        notthere = false;
        break;
      }
    }
    if (notthere) cout << "NO" << endl;
    memset(cnt, 0, sizeof(cnt));
    notthere = true;
  }
  return 0;
}
