#include "bits/stdc++.h"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
void solve(){
int n,k;
cin>>n>>k;
map<int,int> m;
for (int i = 0; i < n; ++i)
{
int v;
cin>>v;
m[v]++;
}
vector<pair<int,int>> p(k);
map<int,int> mm;
for (int i = 0; i < k; ++i)
{
cin>>p[i].first>>p[i].second;
mm[p[i].first]+= p[i].second;
}
for (int i = 1; i < k; ++i)
{
if(p[i].first < p[i-1].first){
cout<<"no\n";
return;
}
}
for(auto i : m){
if(mm[i.first] > i.second){
cout<<"no\n";
return;
}
}
cout<<"yes\n";
}
int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("out.txt", "w",stdout);
#endif
FAST;
int t = 1;
cin>>t;
while(t--)
solve();
}
Copy