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

Solution 1 (runtime: 358 ms):
#include<bits/stdc++.h>
#include<cmath>
#define SZ(x) ((int)x.size())
#include<vector>
#include<set>
#include<map>
#include <unordered_map>
#define pb push_back
#include<string>
#include<cmath>
#define ll long long
#define lli long long int
#define REP(i,n) for(ll i=1;i<=n;i++)
#include<cctype>
#include <sstream>
#define endl "\n"
#define pairs pair<int,int>
#define ld long double
#define mod 1000000009
#define Mod 998244353
const double PI = 3.141592653589793238460;
typedef std::complex<double> Complex;
typedef std::valarray<Complex> CArray;
using namespace std;
# pragma GCC optimize ("Ofast")
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());
ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;}
ll pows(ll a,ll n,ll m)
{
	a=a%m;
	ll res=1;
	while(n)
	{
	if(n%2!=0)
	{
		res=(res*a)%m;
		n--;
		}
		else
		{
			a=(a*a)%m;
			n=n/2;
			}	
	}
	return res%m;
}
ll gcd(ll a,ll b)
{
	
	if(b==0)
	return a;
	else 
	return gcd(b,a%b);
}
bool isprime(ll n)
{
	if(n==1||n==0)
	{
		return false;
	}
	for(ll i=2;i*i<=n;i++)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}
bool istrue(string s)
{
	int i=0;
	int j=s.size()-1;
	while(i<j)
	{
	if(s[i]==s[j])
	{
		i++;
		j--;
		}
		else
		{
		return false;
			}	
	}
	return true;
}
//D'N    G    UP
const int N = 300006;
ll n,m;
ll a[N];
ll b[N];
int main()
{ 
  auto begin = std::chrono::high_resolution_clock::now();
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin>>t;
//  t = 1;
  while(t--){
  	cin>>n>>m;
  	map<ll,ll>mp;
  	for(ll i=0;i<n;i++){
  		cin>>a[i];
  		mp[a[i]]++;
	  }
  	for(ll i=0;i<m;i++){
  		cin>>b[i];
	  }
	  
	  sort(b,b+m);
	  reverse(b,b+m);
	  ll flag = 1;
	  ll w = 0;
	  for(ll i=0;i<m;i++){
	  	if(flag == 0){
	  		break;
		}
	  	  queue<ll>val;
	  	  val.push(b[i]);
	  	  while(!val.empty()){
	  	  	if(val.size() > n){
	  	  		flag = 0;
	  	  		break;
			}
	  	  	ll v = val.front();
	  	  	val.pop();
	  	  	if(mp.find(v) != mp.end() && mp[v] > 0 ){
	  	  		mp[v]--;
				n--;
				continue;
			}
			if(v %2 != 0){
				val.push(v/2);
				val.push((v/2)+1);
			} else{
				val.push(v/2);
				val.push(v/2);				
			}	
	  }
  }
  for(pair<ll,ll>x:mp){
  	if(x.second != 0){
  		flag = 0;
	  }
  }
  if(flag == 0){
  	cout<<"No"<<endl;
  }else{
  	cout<<"Yes"<<endl;
  }
}
  auto end = std::chrono::high_resolution_clock::now();
  auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
  cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 

}



Solution 2 (runtime: 343 ms):
#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;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long

#pragma GCC optimize("O3")

#pragma GCC target("avx,avx2,sse,sse2,sse3,sse4,popcnt,fma")

#pragma GCC optimize("unroll-loops")

////--------- DEBUG START---------////

#define debug(x) cerr << #x <<" "; _print(x); cerr<< endl;

void _print(int a) {cerr << a;}

void _print(char a) {cerr << a;}

void _print(long long int a ) {cerr << a;}

void _print(string a) {cerr << a;}

void _print(bool a) {cerr << a;}

template<class T1 , class T2>void _print(pair<T1, T2>a) {cerr << "{ "; cerr << a.first << " " << a.second; cerr << " }";}

template<class T>void _print(vector<T>&a) {cerr << "[ "; for (T i : a) {_print(i); cerr << " ";} cerr << " ]";}

template<class T>void _print(set<T>&a) {cerr << "[ "; for (T i : a) {_print(i); cerr << " ";} cerr << " ]";}

template<class T>void _print(multiset<T>&a) {cerr << "[ "; for (T i : a) {_print(i); cerr << " ";} cerr << " ]";}

////------DEBUG END---------////

int mod = 1e9 + 7;

ll inv(ll a) {

  return a <= 1 ? a : mod - (long long)(mod / a) * inv(mod % a) % mod;

}

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;

}

std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());

//flags to use    g++ -std=c++17 -Wshadow -Wall -o check check.cpp -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g

/*



*/

bool possible(int num , map<int, int>&cnt) {

  if (num == 0) {

    return false;

  }

  if (cnt[num] > 0) {

    cnt[num]--;

    return true;

  }

  if (num % 2 == 0) {

    bool check = possible(num / 2 , cnt);

    if (check == false) {

      return false;

    }

    check = possible(num / 2 , cnt);

    return check;

  } else {

    bool check = possible(num / 2 , cnt);

    if (check == false) {

      return false;

    }

    check = possible(num / 2 + 1 , cnt);

    return check;

  }

}





void solve() {

  int n , m; cin >> n >> m;

  vector<int>arr(n);

  ll suma = 0 , sumb = 0;

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

    cin >> arr[i];

    suma += arr[i];

  }

  vector<int>brr(m);

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

    cin >> brr[i];

    sumb += brr[i];

  }

  if (suma != sumb) {

    cout << "No" << endl; return;

  }

  map<int, int>cnta , cntb;

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

    cnta[arr[i]]++;

  }

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

    if (!possible(brr[i] , cnta)) {

      cout << "No" << endl; return;

    }

  }





  cout << "Yes" << endl;



}

int main() {

  std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr);

  int t; cin >> t;

  while (t--) {

    solve();

  }

}