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

/******HAPPY CODING******
Codechef: ritik_tanwar
*********WITH************
CodeForces:illuminatiiiii
*********RITIK**********/
#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 fi                                         first
#define se                                         second
#define pb                                         push_back
#define int                                        long long int
#define mp                                         make_pair
#define pii                                        pair<int,int>
#define vi                                         vector<int>
#define mii                                        map<int,int>
#define umii                                       unordered_map<int,int>
#define pqmax                                      priority_queue<int>
#define pqmin                                      priority_queue<int,vi,greater<int>>
#define setbits(x)                                 __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                        1000000007
#define inf                                        1e18
#define ps(x,y)                                    fixed<<setprecision(y)<<x
#define dec(arr,n,type)                             type *arr=new type[n]
#define test(t)                                    int t;cin>>t;while(t--)
#define for1(i,n)                                  for(int i=0;i<n;i++)
#define for2(i,n)                                  for(int i=1;i<=n;i++)
#define fio                                        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SIZE                                       1000001
#define btw(x)                                     (x).begin(),(x).end()
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
int powmod(int a,int b) {int res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}
int multiplymod(int a,int b){int res=0;while(b){if(b&1){res+=a;}a*=2;b/=2;res%=mod;a%=mod;}return res;}
int expomod(int a,int b,int  m){int res=1;while(b>0){if(b&1){res=(res*a)%m;}a=(a*a)%m;b = b>>1;}return res;}

int a[10000005];

void solve(){
    int n,m,k,x,y,z;
    cin>>n>>m;
    int a[n],b[m];
    unordered_set<int> s;
    for1(i,n){
        cin>>x;
        s.insert(x);
    }
    for1(i,m){
        cin>>b[i];
    }
   for1(i,m){
       if(s.find(b[i])!=s.end()){
           cout<<"YES\n";
           cout<<"1 ";
           cout<<b[i]<<"\n";
           return;
       }
       else cout<<"NO\n";
   }
    
}
int32_t main()
{
    fio;
    test(t){
        solve();
    }
}