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

Solution 1 (runtime: 374 ms):
#include "bits/stdc++.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;

#define fst first
#define snd second
#define pb push_back
#define len(x) (int)x.size()
#define all(x) begin(x), end(x)
#define fore(i,a,b) for(auto i=a;i<b;i++)
#define forn(i, n) fore(i, 0, n)
#define dfor(i, n) for(auto i=n;i-->0;)
#define dbg(x) cerr << "LINE" $ __LINE__ <<":" $ #x << "=" << x << endl;
#define raya cerr << "\n-----------------------------------------------------------\n"
#define $ <<" "<<

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T,U> &p){
    os << '(' << p.first $ p.second << ')';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
    os << "[";
    forn(i, len(v)){
        if(i) os << ", ";
        os << v[i];
    }
    os << "]";
    return os;
}

typedef long long ll;

void solve(){
    int n, m;
    cin>>n>>m;
    vector<int> a(n), b(m);
    forn(i,n) cin>>a[i];
    forn(i,m) cin>>b[i];
    map<int,int> cnt;
    forn(i,n) cnt[a[i]]++;
    queue<int> q;
    forn(i,m) q.push(b[i]);
    while(!q.empty()){
        if(len(q) > n){
            cout<<"NO\n";
            return;
        }
        int x = q.front();
        q.pop();
        if(cnt.find(x) != cnt.end()){
            cnt[x]--, n--;
            if(cnt[x] == 0) cnt.erase(x);
            continue;
        }
        if(x == 1){
            cout<<"NO\n";
            return;
        }
        
        if(x/2 < cnt.begin()->fst){
            cout<<"NO\n";
            return;
        }
        if(x%2==0){
            q.push(x/2);
            q.push(x/2);
        }
        else{
            q.push((x-1)/2);
            q.push((x-1)/2 + 1);
        }
    }
    if(len(cnt)>0) cout<<"NO\n";
    else cout<<"YES\n";
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int tt;
    cin>>tt;
    while(tt--) solve();
    return 0;
}



Solution 2 (runtime: 312 ms):
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<long long, null_type,less<>, rb_tree_tag,tree_order_statistics_node_update>// set
typedef tree<long long,null_type,less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update>ordered_multiset;
#define orderedset tree<pair<long long,char>,null_type,less<pair<long long,char>>,rb_tree_tag,tree_order_statistics_node_update>
#define OMAR_JR ios::sync_with_stdio(false),cin.tie(0), cout.tie(0);
#define all(v) (v).begin(), (v).end()
#define endl '\n'
#define ll long long
#define double long double
#define cin(vec) for(auto& i : vec) cin >> i
#define cout(vec) for(auto& i : vec) cout << i << " ";
#define pi 3.141592653
#define dpp(arr,t)memset(arr,t,sizeof(arr))
#define numofone(n) __builtin_popcount(n)
#define numofonell(n) __builtin_popcountll(n)
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
//size - order_of_key (k) - mp[k] : Number of items strictly grater than k
//string alphabet = "abcdefghijklmnopqrstuvwxyz";
void myErase(ordered_multiset &t, ll v){
    ll rank = t.order_of_key(v);
    ordered_multiset::iterator it = t.find_by_order(rank);
    t.erase(it);
}//oredered_muliset erase
const ll mod = 1e9 + 7;
//priority_queue<ll,vector<ll>,greater<ll>>q;
ll add(ll a, ll b) {
    return ((a % mod + b % mod) % mod + mod) % mod;
}ll mul(ll a, ll b){
    return 1ll * a * b % mod;
}ll di[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll dj[] = { 0, 1, 0, -1, 1, -1, -1, 1 };
ll mins(ll a, ll b) {
    return ((a % mod) - (b % mod) + mod) % mod;
}ll powlog(ll base , ll power){
    if(power == 0ll)return 1ll;
    ll x = powlog(base , power / 2ll) ;
    x = mul(x , x) ;
    if(power & 1ll)x = mul(x , base) ;
    return x ;
}ll modinv(ll x){
    return powlog(x , mod-2ll) ;
}ll Div(ll x , ll y){
    return mul(x ,modinv(y)) ;
}void File() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}ll gcd(ll x, ll y) { return ((!y) ? x : gcd(y, x % y));}
ll lcm(ll x, ll y) { return ((x / gcd(x, y)) * y); }
ll setbit1(ll n, ll x) {
    return n | (1ll << x);
}ll cheak(ll num,ll idx) {
    num >>= idx;
    return num & 1ll;
}ll setbit0(ll num,ll idx) {
    return (~(1ll << idx) & num);
}ll fp(ll n, ll p){
    if (!p)return 1ll;
    ll temp = fp(n, p >> 1ll);
    temp = mul(temp, temp);
    if (p & 1ll)temp = mul(temp, n);
    return temp;
}//A % m = B % m
//A % m - B % m = 0
//(A - B) % m = 0;
// (100 / 5) % mod ==  100 * inverse(5) % mod
// inverse(5) = 5^-1 ----- 5^-1 = 5^mod-2
multiset<ll>s;
bool rec(ll val){
    if(!s.size())return 0;
    if(s.find(val) != s.end()){
        s.erase(s.find(val));
        return 1;
    }if(val == 1)return 0;
    return (rec(val/2) and rec(val/2+(val&1)));
}
void lol() {
    ll x,y;cin >> x >> y;
    vector<ll>v1(x),v2(y);
    cin(v1);cin(v2);
    s.clear();
    for(int i = 0 ; i < x ; i++){
        s.insert(v1[i]);
    }sort(all(v1)),sort(all(v2));
    for(int i = 0 ; i < y ; i++){
        if(!rec(v2[i]))return cout << "NO" << endl,void();
    }if(!s.size())cout << "YES" << endl;
    else cout << "NO" << endl;
}
signed main(){
    OMAR_JR
    int t = 1;
    cin >> t;
    while(t--) {
        lol();
    }
}