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

Solution 1 (runtime: 343 ms):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#define read(a)       \
    for (auto &i : a) \
    cin >> i
#define print(a)          \
    for (auto &i : a)     \
        cout << i << " "; \
    cout << "\n"
#define read2(a, n, m)                \
    for (int i = 0; i < (n); ++i)     \
        for (int j = 0; j < (m); ++j) \
    cin >> (a)[i][j]
#define print2(a, n, m)               \
    for (int i = 0; i < (n); ++i)     \
    {                                 \
        for (int j = 0; j < (m); ++j) \
            cout << (a)[i][j] << " "; \
        cout << endl;                 \
    }
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

const int INF = 1e9;
const ll M = 1e9 + 7;
const ll LLINF = 1e18;

ll mod_exp(ll base, ll exp, ll mod = M)
{
    ll result = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            result = (result * base) % mod;
        base = (base * base) % mod;
        exp /= 2;
    }
    return result;
}
ll mod_add(ll a, ll b, ll m = M) { return (a % m + b % m) % m; }
ll mod_sub(ll a, ll b, ll m = M) { return ((a % m - b % m) + m) % m; }
ll mod_mul(ll a, ll b, ll m = M) { return ((a % m) * (b % m)) % m; }
ll mod_inv(ll a, ll m = M) { return mod_exp(a, m - 2, m); }
ll mod_div(ll a, ll b, ll m = M) { return mod_mul(a, mod_inv(b, m), m); }

bool isPowerOfTwo(int n) { return n && !(n & (n - 1)); }
int getBit(int n, int i) { return (n >> i) & 1; }
int setBit(int n, int i) { return n | (1 << i); }
int clearBit(int n, int i) { return n & ~(1 << i); }
int toggleBit(int n, int i) { return n ^ (1 << i); }

void solve()
{
    int n, m;
    cin >> n >> m;
    map<int,int> a;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        a[x]++;
    }
    priority_queue<int> q;
    for(int i=0;i<m;i++) {
        int x;
        cin>>x;
        q.push(x);
    }
    int ct =0,sz=a.size();
    while(ct<=n-m && !q.empty()){
        int t = q.top();
        q.pop();
        if(a[t]){
            a[t]--;
            if(a[t]==0) sz--;
        }
        else{
            q.push(t/2);
            q.push((t+1)/2);
            ct++;
        }
    }
    // cout<<a.size()<<endl;
    if(q.empty() && !sz)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}    

int main()
{
    fastio;
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Solution 2 (runtime: 656 ms):
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0), cin.tie(0)
#define int long long
#define endl '\n'
#define lowbit(x) (x & -x)
#define all(s) s.begin(), s.end()
#define pii pair<int,int>
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define here system("pause")
using namespace std;
template <class T>
inline void read(T &x){
	x = 0;
	char c = getchar();
	bool f = 0;
	for (; !isdigit(c); c = getchar()) f ^= (c == '-');
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	x = f ? -x : x;
}
template <class T>
inline void write(T x){
	if (x < 0) putchar('-'), x = -x;
	if (x < 10) putchar(x + 48);
	else write(x / 10), putchar(x % 10 + 48);
}
template<typename T> void chkmin(T& lhs, const T& rhs) { lhs = lhs > rhs ? rhs : lhs; }
template<typename T> void chkmax(T& lhs, const T& rhs) { lhs = lhs < rhs ? rhs : lhs; }

const int N = 3e5 + 4;
const int mod = 998244353;
const int INF = 8e18 + 9;
const double eps = 1e-9;
const double Pi = acos(-1);

int a[N], b[N];
inline void sol(){
	int n, m;
	cin >> n >> m;
	priority_queue<int> A, B;
	for(int i=1;i<=n;i++){
		cin >> a[i];
		A.push(a[i]);
	}
	for(int i=1;i<=m;i++){
		cin >> b[i];
		B.push(b[i]);
	}
	while(A.size() && B.size()){
		int at = A.top();
		int bt = B.top();
		if(at == bt){
			A.pop();
			B.pop();
			continue;
		}
		if(bt < at || B.size() > A.size()){
			return cout << "No\n", void();
		}
		if(bt > at){
			int x = bt >> 1;
			int y = bt + 1 >> 1;
			B.pop();
			B.push(x);
			B.push(y);
		}
	}

	if(A.size() || B.size()) cout << "No\n";
	else cout << "Yes\n";
}

signed main(){
	// IOS;
	int tc = 1;
	cin >> tc;
	cout << fixed << setprecision(10);
	while(tc--){
		sol();
	}
	return 0;
}