#include<bits/stdc++.h>
#define deb(a) cout<<#a<<" is: "<<a<<endl;
#define dl() cout<<"--------------\n";
#define at(i) cout<<"at"<<i<<endl;
#define print(arr, n) for(int i=0;i<n;i++) cout<<arr[i]<<" ";
#define nl() cout<<"\n";
#define f first
#define s second
typedef long long ll;
typedef long double ld;
using namespace std;
int cnt[100100];
main(){
int t; cin>>t;
while(t--){
memset(cnt,0, sizeof cnt);
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++){
int a; cin>>a;
cnt[a] ++;
}
int base = 0;
bool ok = true;
for(int i=0;i<k;i++){
int x, times; cin>>x>>times;
if(x >= base && cnt[x] >= times){
cnt[x] -= times;
base = x;
}
else{
ok = false;
continue;
}
}
if(ok){
cout<<"yes\n";
}
else{
cout<<"no\n";
}
}
}
Copy