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

Solution 1 (runtime: 421 ms):
// Allahu Akbar(الله أكبر)
/**
 *    author:  Rahul Islam
 *    created: 2025.01.20 17:34:08
 **/
#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;
template <typename T>
using pbds_set = tree<T, null_type, greater<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using pbds_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename Key, typename Value>
using ordered_map = tree<Key, Value, less<Key>, rb_tree_tag, tree_order_statistics_node_update>;
#ifndef ONLINE_JUDGE
#include "debug.h"
#include "debug_template.cpp"
#else
#define dbg(...) 42
#define debug(...)42
#endif
typedef long long ll;
#define nl '\n'
#define pb push_back
#define F first
#define S second
#define mx_int_prime 999999937
const ll infLL = 9000000000000000000;
using u32 = unsigned;
using u64 = unsigned long long;
#define MOD 1000000007
//Don't forget to check the constraints and consider edge cases!
//Don't get stuck on one problem for too long!

void solve() {
    ll n, m;
    cin >> n >> m;
    multiset<ll, greater<ll>>a, b;
    vector<ll>v(n);
    for (int i = 0;i < n;i++) {
        ll x;
        cin >> x;
        a.insert(x);
        v[i] = x;
    }
    for (int i = 0;i < m;i++) {
        ll x;
        cin >> x;
        b.insert(x);
    }

    while (!b.empty() && !a.empty() && b.size() <= a.size()) {
        auto it = b.begin();
        auto it1 = a.begin();
        ll vA = *it1;
        ll vB = *it;
        b.erase(it);
        // debug(vA, vB);
        bool flag = false;
        if (vA == vB) {
            a.erase(it1);
            continue;
        }

        if (vA > vB) {
            break;
        }
        ll x = (vB + 1) / 2;
        ll y = (vB) / 2;
        b.insert(x);
        b.insert(y);

    }
    if (a.empty() && b.empty()) {
        cout << "YES" << nl;
    }
    else {
        cout << "NO" << nl;
    }




}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll tc;
    cin >> tc;
    for (int i = 1; i <= tc; i++)
        solve();
    return 0;
}


Solution 2 (runtime: 343 ms):
#include<bits/stdc++.h>

using namespace std;



#define int long long

#define FASTIO ios_base::sync_with_stdio(false);cin.tie(nullptr);



int mod = 998244353;



// vector<int> parent;

// vector<int> size;

// void makeSet(int v) {

// 	parent[v] = v;

// 	size[v] = 1;

// }



// int findSet(int v) {

// 	if (parent[v] == v) return v;

// 	return parent[v] = findSet(parent[v]);

// }



// void unionSet(int a, int b) {

// 	a = findSet(a);

// 	b = findSet(b);

// 	if (a != b) {

// 		if (size[a] < size[b])

// 			swap(a, b);

// 		parent[b] = a;

// 		size[a] += size[b];

// 	}

// }



int gcd (int a, int b) {

    return b ? gcd (b, a % b) : a;

}



bool isPrime(int n) {

	for (int i = 2; i * i < n; i++) {

		if (n % i == 0) return false;

	}

	return true;

}



long long binpow(long long a, long long b, long long m) {

	a %= m;

	long long res = 1;

	while (b > 0) {

		if (b & 1)

			res = res * a % m;

		a = a * a % m;

		b >>= 1;

	}

	return res;

}



long long binpow(long long a, long long b) {

	if (b == 0)

		return 1;

	long long res = binpow(a, b / 2);

	if (b % 2)

		return res * res * a;

	else

		return res * res;

}



int ceil2(int a, int b) {

	return (a + b - 1) / b;

}



int C(int n, int k) {

    double res = 1;

    for (int i = 1; i <= k; ++i)

        res = res * (n - k + i) / i;

    return (int)(res + 0.01);

}



pair<int, int> searchRange(vector<int>& nums, int target) {

	auto it = lower_bound(nums.begin(), nums.end(), target);

	if (it == nums.end() || *it != target) return { -1, -1};

	auto it2 = upper_bound(nums.begin(), nums.end(), target);

	return {it - nums.begin(), it2 - nums.begin() - 1};

}



vector<int> prefixSum(vector<int> &a) {

	vector<int> pref(a.size());

	if(a.empty()) return pref;

	pref[0] = a[0];

	for(int i = 1;i<a.size();i++) {

		pref[i] = a[i] + pref[i - 1];

	}

	return pref;

}



bool comp(vector<int> a, vector<int> b) {

	return a[1] > b[1];

}



bool cmpPairDiff(std::pair<int, int>& a, std::pair<int, int>& b) {

    return abs(b.first - b.second) < abs(a.first - a.second);

}



int greaterElement(vector<int> &a, int x) {

    if (a.empty()) return -1;

    if (x >= a[0]) {

        return -1;

    }

    if (x < a.back()) {

        return a.back();

    }

    int low = 0, high = a.size() - 1;

    while(low < high - 1) {

        int mid = (low + high) / 2;

        if (a[mid] > x) {

            low = mid;

        }

        else {

            high = mid;

        }

    }

    return a[low];

}



vector<string> split(string &s, char c) {

	string temp;

	vector<string> ans;

	for (int i = 0;i<s.size();i++) {

		if (s[i] == c) {

			if (temp != "") {

				ans.push_back(temp);

				temp = "";

			}

		}

		else {

			temp.push_back(s[i]);

		}

	}

	return ans;

}



bool found(multiset<int> &a, int x, int level, int n) {

	if (x == 0) {

		return false;

	}

	if (a.empty()) {

		return false;

	}

	if (x == 1) {

		auto it = a.find(x);

		if (it == a.end()) {

			return false;

		}

		a.erase(it);

		return true;

	}

	// cout << x << endl;

	auto it = a.find(x);

	if (it != a.end()) {

		a.erase(it);

		// cout << "found x " << x << " erase and return" << endl;

		return true;

	}

	// if (pow(2, level + 1) - 1 > n * 10) return false;

	// cout << "finding " << (x + 1) / 2 << " and " << x / 2 << endl;

	return found(a, (x + 1) / 2, level + 1, n) && found(a, x / 2, level + 1, n);

}



void solve(int iter) {

	int n, m;

	cin >> n >> m;

	multiset<int> a;

	vector<int> b(m);

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

		int x;

		cin >> x;

		a.insert(x);

	}

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

		cin >> b[i];

	}

	sort(b.begin(), b.end());

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

		if (!found(a, b[i], 0, n)) {

			cout << "No\n";

			return;

		}

	}

	if (a.empty()) cout << "Yes\n";

	else {

		cout << "No\n";

	}

}



signed main() {

#ifndef ONLINE_JUDGE

	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);

#endif

	FASTIO

	int tt;

	cin >> tt;



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

		solve(i);

	}



}