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>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = 1e9 + 7;
const int MX = (int)2e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

// #define WHITE 0
// #define GREY 1
// #define BLACK 2
// vector<int> color(MX);
// vector<int> g[MX];
// bool ok;

// void dfs(int x){
// 	assert(color[x] == WHITE);
// 	color[x] = GREY;
// 	for(auto &y : g[x]){
// 		if(color[y] == GREY){ // pending
// 			ok = false; // cycle found
// 			return;
// 		}
// 		if(color[y] == WHITE)
// 			dfs(y);
// 	}
// 	color[x] = BLACK;
// }

void solve(){
	int n, m;
	cin >> n >> m;
	vector<int> seen(1001);
	vector<int> a(n), b(m);
	for(auto &x : a){
		cin >> x;
		if(!seen[x]) seen[x]++;
	}
	for(auto &x : b){
		cin >> x;
		if(seen[x] <= 1) seen[x]++;
	}

	for(int i = 0; i <= 1000; ++i){
		if(seen[i] >= 2){
			cout << "YES\n";
			cout << "1 " << i << "\n";
			return;
		}
	}

	cout << "NO\n";
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int t;
	cin >> t;
	for(int i = 1; i <= t; ++i){
		solve();
	}

	return 0;
}
