Problem: 2061D - Kevin and Numbers
Language: C++17 (GCC 7-32)


Submission (verdict: Time limit exceeded on test 7):
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
// #pragma GCC target("avx2,sse4.2,bmi,bmi2,popcnt,lzcnt")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long int
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define vi vector <int>
#define vl vector <long long int>
#define all(a) a.begin(),a.end()
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rev(i, a, b) for (ll i = a; i >= b; i--)
#define pi 3.141592653589793238462643383279
#define TEMP_SIZE 1000005
using namespace std;
using namespace __gnu_pbds;

const long long INF = (long long)1e15;
long double eps = 1e-6;
const ll MOD = 998244353;

// orderedset

template<class T> using ordered_set =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;

// vector <int> ad[TEMP_SIZE], newgraph[TEMP_SIZE];
// ll vis[TEMP_SIZE];


vector<ll> fact;
vector<ll> inv;

long long pow(long long a, long long b)
{

    long long res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
    }
    return res;
}

void factinit(ll MOD)
{
    fact.assign(TEMP_SIZE, 0);
    fact[0] = 1;
    for (ll i = 1; i < TEMP_SIZE; i++)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
    }
}

long long powm(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 /= 2;
    }

    return res;
}

void invinit()
{
    inv.assign(TEMP_SIZE, 0);
    inv[1] = 1;
    for (ll i = 2; i < TEMP_SIZE; i++)
    {
        inv[i] = powm(i, MOD - 2, MOD);
    }
}

ll nCr(ll n, ll r)
{
    return ((fact[n] * powm(fact[r], MOD - 2, MOD)) % MOD * powm(fact[n - r], MOD - 2, MOD)) % MOD;
}

bool compare(const pair<ll, ll> &i, const pair<ll, ll> &j)
{
    return i.second < j.second;
}

ll mex(vector<ll> &arr, ll N)
{
    sort(arr.begin(),arr.end());
    int mex = 0;
    for (int idx = 0; idx < N; idx++)
    {
        if (arr[idx] == mex)
        {
            mex += 1;
        }
    }

    return mex;
}

ll sod(ll n)
{
    ll sum = 0;
    while (n)
    {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

ll poss(ll a[], ll n, ll k, ll mid)
{
    map<ll, ll> f;
    rep(i, 0, n)
    {
        f[a[i]]++;
    }
    ll sum = 0, need = mid * k;
    for (auto i : f)
    {
        sum += min(mid, i.second);
    }
    if (sum >= need)
        return 1;
    else
        return 0;
}

double nthRoot(ll A, ll n)
{
    double val = round(exp(log(A) / n) * 1e9) / 1e9; 
    return val;
}

vector <bool> vis;
vector <ll> ans;
int component_index = 0;

void dfs(vector <vector <int> > &g, int node)
{
  
    vis[node] = true;
    for (auto p: g[node])
    {
        if (!vis[p])
        {
            dfs(g, p);
        }
    }
    return;
}



void solve()
{
    int n, m;
    cin>>n>>m;
    vi a(n), b(m);
    rep(i,0,n) cin>>a[i];
    rep(i,0,m) cin>>b[i];

    multiset <int> m1;

    sort(all(a));



    rep(i,0,m) m1.insert(b[i]);

    int cnt = n-m;

    int i = n-1;
    while (!m1.empty() && i>=0)
    {
        auto it = next(m1.begin(), m1.size()-1);
        int val = *it;
        m1.erase(it);
        if (val == a[i])
        {
            i--;
        }
        else if (val < a[i])
        {
            cout<<"No"<<endl;
            return;
        }
        else
        {
            if (cnt == 0)
            {
                cout<<"No"<<endl;
                return;
            }
            else
            {
                cnt--;
            }
            m1.insert(val/2);
            m1.insert((val+1)/2);
        }
    }
    

    if (m1.size()!=0 || i>=0)
    {
        cout<<"No"<<endl;
        return;
    }

    cout<<"Yes"<<endl;
    return;
}

int main()
{
    // factinit(MOD);
    // invinit();

    #ifndef ONLINE_JUDGE
                // freopen("Input.txt", "r", stdin);
                // freopen("Output.txt", "w", stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll t = 1;
    cin>>t;

    while (t--)
    {
        solve();
    }
}