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

Solution 1 (runtime: 796 ms):
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <ostream>
#include <sstream>
#include <set>
#include <stack>
#include <set>
#include <queue>
#include <deque>
#include <bits/stdc++.h>
#include <fstream>
#include <numeric>
#include <cstdio>
#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 ordered_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;


typedef long long ll;

ll MOD = 1e9 + 7;

/* long long fast_power(long long base, long long power) {
    long long result = 1;
    while(power > 0) {

        if(power % 2 == 1) { // Can also use (power & 1) to make code even faster
            result = (result*base) % MOD;
        }
        base = (base * base) % MOD;
        power = power / 2; // Can also use power >>= 1; to make code even faster
    }
    return result;
} */

/*ll UpSearch(vector<ll> &v , int low , int high , ll x) {
    int ans = -1;
    while(low <= high) {
        int mid = low + (high - low) / 2;
        if(v[mid] >= x) {
            ans = mid;
            high = mid - 1;
        }
        else low = mid + 1;
    }
    return ans;
}*/
/*ll LowSearch(vector<ll> &v , int low , int high , ll x) {
    int ans = -1;
    while(low <= high) {
        int mid = low + (high - low) / 2;
        if(v[mid] <= x) {
            ans = mid;
            low = mid + 1;
        }
        else high = mid - 1;
    }
    return ans;
}*/

/* ll search(vector<ll> &v , int low , int high , ll x) {
    int ans = -1;
    while(low <= high) {
        int mid = low + (high - low) / 2;
        if(v[mid] <= x) {
            ans = mid;
            low = mid + 1;
        }
        else high = mid - 1;
    }
    return ans;
} */

/* void findSubsets(vector<ll> nums, int n, vector<pair<ll , int>> &AllSubSets)
{
    // Loop through all possible subsets using bit manipulation
    for (int i = 0; i < (1 << n); i++) {

        ll sum = 0;
        int siz = 0;

        // Loop through all elements of the input array
        for (int j = 0; j < n; j++) {

            // Check if the jth bit is set in the current subset
            if ((i & (1 << j)) != 0) {

                // If the jth bit is set, add the jth element to the subset
                sum += nums[j];
                siz++;
            }
        }
        AllSubSets.push_back({sum , siz});
    }
} */

/* void findstrings(vector<string> &v , int n) {
    for (int i = 0; i < (1 << n); i++) {
        bitset<32> b(i);
        v.push_back(b.to_string().substr(32-n));
    }
} */


void solve() {
    int n , m;
    cin >> n >> m;
    queue<int> q;
    map<int , int> freq;

    for(int i = 0 ; i < n ; i++) {
        int a; cin >> a;
        freq[a]++;
    }
    int sz = m;
    for(int i = 0 ; i < m ; i++) {
        int a ; cin >> a;
        q.push(a);
        while(!q.empty() && q.size() <= n) {
            int test = q.front();
            q.pop();
            if(freq[test] > 0) {
                freq[test]--;
                continue;
            }
            if(test / 2 != 0) q.push(test / 2);
            if((test + 1) / 2 != 1) q.push((test + 1) / 2);
            sz++;
        }
    }
    if(sz == n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

int main(){

    int t;
    cin >> t;
    while(t--) {
        solve();
    }

    return 0;
}


Solution 2 (runtime: 686 ms):
#include <iostream>
#include <vector>
#include <queue>

#define ll long long
#define setbits(x) __builtin_popcountll(x)

using namespace std;
 
void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> a, b;
    
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push(x);
    }
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        b.push(x);
    }
    
    while (!a.empty()) {
        if (b.empty() || b.size() > a.size()) {
            cout << "No\n";
            return;
        }
        int x = b.top();
        b.pop();
        
        if (x < a.top()) {
            cout << "No\n";
            return;
        }
        if (x == a.top()) {
            a.pop();
        } else {
            b.push(x / 2);
            b.push((x + 1) / 2);
        }
    }
    
    if (!b.empty()) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
}
 
int main() {
    int t;
    cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}