#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define endl '\n'
int main() {
fast
ll t;
cin >> t;
while(t--){
ll n, k, ok = 1;
cin >> n >> k;
ll a[n];
vector<pair<ll, ll>> v(k);
ll r[k], d = 0;
map<ll, ll> mp, mp2;
for(auto &it : a)
cin >> it, mp[it]++;
for(auto &[f, s] : v){
cin >> f >> s;
r[d++] = f;
mp[f] -= s;
if(mp[f] < 0)
ok = 0;
}
if(!is_sorted(r, r + k))
ok = 0;
cout << (ok ? "yes" : "no") << endl;
}
}
Copy