Problem: 2061D - Kevin and Numbers
Language: c++17 

Solution 1 (runtime: 358 ms):
#include <bits/stdc++.h>
using namespace std;
#define inf numeric_limits<int>::max()
#define rinf numeric_limits<int>::min()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ll long long
#define rep(i, s, e) for(int i=s; i<e; i++)
#define rrep(i, s, e) for(int i=e-1; i>=s; i--)
#define pb push_back
#define endl "\n";
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

void solve() {
    ll n, m; 
    cin >> n >> m ;
    multiset<ll, greater<ll>> a,b;
    rep(i,0,n) {
        ll in ; cin >> in;
        a.insert(in);
    }
    rep(i,0,m) {
        ll in ; cin >> in;
        auto it = a.find(in);
        if(it != a.end()) {
            a.erase(it);
        } else {
            b.insert(in);
        }
    }

    while(a.size() && b.size() && (a.size() >= b.size())) {
        // cout << "herr" << endl;
        if(*a.begin() == *b.begin()) {
            a.erase(a.begin());
            b.erase(b.begin());
        } else if(*a.begin() < *b.begin()) {
            ll y1 = floor((float)*b.begin() / 2);
            ll y2 = ceil((float)*b.begin() / 2);
            // cout << y1 << " " << y2 << endl;
            b.erase(b.begin());
            b.insert(y1);
            b.insert(y2);
        } else {
            break;
        }
    }
    if(a.size() || b.size()) {
        no;
    } else {
        yes;
    }
    
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout << fixed << setprecision(12);
    
    // freopen("f.in", "r", stdin);
	// freopen("f.out", "w", stdout);
    
    ll t = 1; 
    cin >> t;
    while(t--) solve();
}

Solution 2 (runtime: 359 ms):
#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;

//  

// // //   

// // // // ..Optimizations

// // // //  

 // #pragma GCC optimize ("Ofast")

     // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

    // #pragma GCC target ("sse,sse2,mmx")

    // #pragma GCC optimize ("-ffloat-store")

 // #pragma GCC optimize("O3,unroll-loops")

// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")

 // #pragma GCC optimize("Ofast,unroll-loops")

// #pragma GCC target("avx2,tune=native")

// #pragma GCC optimize ("O3")

// #pragma GCC optimize ("unroll-loops")

// #pragma GCC target ("avx2")

// #pragma GCC optimize ("Os")

// #pragma GCC optimize("Ofast")

// #pragma GCC optimize("fast-math")

// #define _FORTIFY_SOURCE 0 

// #pragma GCC optimize("no-stack-protector")  

#define MOD 1000000007

#define MOD1 998244353

#define INF 1e14

 #define nline "\n"

#define pb push_back

 #define ppb pop_back

 #define mp make_pair

 #define ff first

 #define ss second

 #define PI 3.141592653589793238462

 #define set_bits __builtin_popcountll

 #define sz(x) ((int)(x).size())

 #define all(x) (x).begin(), (x).end()

 

 typedef long long ll;

 typedef unsigned long long ull;

 typedef long double lld;

// //template <typename Type, typename ComparatorFn = less<Type>>

// // using oset = tree<Type, null_type, ComparatorFn, rb_tree_tag, tree_order_statistics_node_update>;

// //  

// // template<typename Type, typename ComparatorFn>

// // bool oset_erase(oset<Type, ComparatorFn> &st, Type val) {

	// // if (st.lower_bound(val) == st.upper_bound(val)) return false;

	// // st.erase(st.find_by_order(st.order_of_key(val)));

	// // return true;

// // }

typedef tree<long long, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds; // find_by_order, order_of_key

 // methods -> *find_by_order, order_of_key

// comparators -> less, less_equal, greater, greater_equal

#ifndef ONLINE_JUDGE

#define debug(x) cerr << #x <<" "; _print(x); cerr << endl;

#else

#define debug(x)

#endif

 

void _print(ll t) {cerr << t;}

void _print(int t) {cerr << t;}

void _print(string t) {cerr << t;}

void _print(char t) {cerr << t;}

void _print(lld t) {cerr << t;}

void _print(double t) {cerr << t;}

void _print(ull t) {cerr << t;}

  

#define f0r(a, b) for (long long a = 0; a < (b); a++)

#define f1r(a, b, c) for (long long a = (b); a < (c); a++)

#define f0rd(a, b) for (long long a = (b); a >= 0; a--)

#define f1rd(a, b, c) for (long long a = (b); a >= (c); a--)

template <class T, class V> void _print(pair <T, V> p);

template <class T> void _print(vector <T> v);

template <class T> void _print(set <T> v);

template <class T, class V> void _print(map <T, V> v);

template <class T> void _print(multiset <T> v);

template <class T, class V> void _print(pair <T, V> p) {cerr << "{"; _print(p.ff); cerr << ","; _print(p.ss); cerr << "}";}

template <class T> void _print(vector <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(set <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T> void _print(multiset <T> v) {cerr << "[ "; for (T i : v) {_print(i); cerr << " ";} cerr << "]";}

template <class T, class V> void _print(map <T, V> v) {cerr << "[ "; for (auto i : v) {_print(i); cerr << " ";} cerr << "]";}

#define int long long

#define ll long long

ll mod_add(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a + b) % m) + m) % m;}

ll mod_mul(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a * b) % m) + m) % m;}

ll mod_sub(ll a, ll b, ll m) {a = a % m; b = b % m; return (((a - b) % m) + m) % m;}

//ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return mod_add(arr[0], 0, b);} //for non prime b

//ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}

bool revsort(ll a, ll b) {return a > b;}

//ll mod_div(ll a, ll b, ll m) {a = a % m; b = b % m; return (mod_mul(a, mminvprime(b, m), m) + m) % m;}  //only for prime m

 #define endl "\n" 

//b,k, ointime ,outim,lca, kth parent, bfs, dfs, subtree ,lvl ,euler tour etc

// dp on trees , rerootinmg , precomputation   

//shortes path, bfs,0-1 bfs, dfs, mutisrc bfs, adding edges,

  const int M=1000000007; 

        long long mod(long long x){

            return ((x%M + M)%M);

        }

        long long add(long long a, long long b){

            return mod(mod(a)+mod(b));

        }

        long long mul(long long a, long long b){

            return mod(mod(a)*mod(b));

        }

                

 		bool cmp(pair<int,int>a,pair<int,int>b){

		if(a.ss!=b.ss)return a.ff<b.ff;

		return a.ss<b.ss;

		}

	

	

void solve(){

	int n;

	cin>>n;

	int m;

	cin>>m;

	vector<int>a,b;

	map<int,int>mp;

	multiset<int,greater<int>>a1,b1;

	for(int i=0;i<n;i++){

		int x;

		cin>>x;

		a.pb(x);

		a1.insert(x);

	}

for(int i=0;i<m;i++){

		int x;

		cin>>x;

		b.pb(x);

		b1.insert(x);

	}

	// for(int i=0;i<n;i++){

		// if(b1.find(a[i])!=b1.end()){

			// b1.erase(b1.find(a[i]));

			// a1.erase(a1.find(a[i]));

		// }

	// }

	while(a1.size() && b1.size()){

		if(b1.size()>a1.size() || *a1.begin()>*b1.begin()){

			cout<<"no"<<endl;

			return;

		}else if(*a1.begin()==*b1.begin()){

			a1.erase(a1.find(*a1.begin()));

			b1.erase(b1.find(*b1.begin()));

		}else{

			int z=*b1.begin();

			b1.erase(b1.find(*b1.begin()));

			b1.insert(z/2);

			b1.insert((z+1)/2);

		}

	}

	if(a1.size()==0 ){

		cout<<"yes"<<endl;

		return;

	}

	cout<<"No"<<endl;

}

		

signed main(){

	ios::sync_with_stdio(false);

	cin.tie(0);cout.tie(0);

	int t=1;

	cin>>t;

	while(t--){

		

	solve();

}



}