#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>
using namespace std;
#define saleh \
ios_base::sync_with_stdio(false); \
cin.tie(nullptr);
#define ll long long
int main()
{
saleh;
int t;
cin >> t;
while (t--)
{
int n, m;
cin >> n >> m;
int m1[16]={0};
int m2[51]={0};
int c=0;
for(int x=0;x<n;x++)
{
int r;
cin>>r;
m1[r]++;
if(m1[r]==1)
c++;
}
for(int x=0;x<m;x++)
{
int r;
cin>>r;
m2[r]++;
}
int l=5,r=1;
for(int x=l;x<16;x++)
{
if(m1[x]==0)continue;
while(r<51&&m1[x]>m2[r])
{
r++;
}
if(r==51)
break;
r++;
c--;
}
if(c==0)
cout<<"YES\n";
else
cout<<"NO\n";
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8Yml0cy9zdGRjKysuaD4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgojZGVmaW5lIHNhbGVoICAgICAgICAgICAgICAgICAgICAgICAgIFwKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOyBcCiAgICBjaW4udGllKG51bGxwdHIpOwojZGVmaW5lIGxsIGxvbmcgbG9uZwoKaW50IG1haW4oKQp7CgogICAgc2FsZWg7CgogICAgaW50IHQ7CiAgICBjaW4gPj4gdDsKICAgIHdoaWxlICh0LS0pCiAgICB7CiAgICAgICAgaW50IG4sIG07CiAgICAgICAgY2luID4+IG4gPj4gbTsKCiAgICAgICAgaW50IG0xWzE2XT17MH07CiAgICAgICAgaW50IG0yWzUxXT17MH07CiAgICAgICAgCiAgICAgICAgaW50IGM9MDsKICAgICAgICBmb3IoaW50IHg9MDt4PG47eCsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpbnQgcjsKICAgICAgICAgICAgICAgIGNpbj4+cjsKCiAgICAgICAgICAgICAgICBtMVtyXSsrOwogICAgICAgICAgICAgICAgaWYobTFbcl09PTEpCiAgICAgICAgICAgICAgICAgICAgYysrOwogICAgICAgICAgICB9CiAgICAgICAgCiAgICAgICAgZm9yKGludCB4PTA7eDxtO3grKykKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgaW50IHI7CiAgICAgICAgICAgICAgICBjaW4+PnI7CgogICAgICAgICAgICAgICAgbTJbcl0rKzsKICAgICAgICAgICAgfQogICAgICAgIAogICAgICAgIGludCBsPTUscj0xOwogICAgICAgIGZvcihpbnQgeD1sO3g8MTY7eCsrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZihtMVt4XT09MCljb250aW51ZTsKICAgICAgICAgICAgICAgIHdoaWxlKHI8NTEmJm0xW3hdPm0yW3JdKQogICAgICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICAgICAgcisrOwogICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGlmKHI9PTUxKQogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgcisrOwogICAgICAgICAgICAgICAgYy0tOwogICAgICAgICAgICAgICAgCiAgICAgICAgICAgIH0KICAgICAgICBpZihjPT0wKQogICAgICAgICAgICBjb3V0PDwiWUVTXG4iOwogICAgICAgIGVsc2UKICAgICAgICAgICAgY291dDw8Ik5PXG4iOwogICAgICAgIAoKCiAgICB9Cn0=