#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 1;
int n, k;
int a[N];
pair<int, int> p[N];
void solve() {
scanf("%d%d", &n, &k);
for (int i = 0 ; i < n ; i++) {
scanf("%d" , a + i);
}
for (int i = 0 ; i < k ; i++) {
scanf("%d%d", &p[i].first, &p[i].second);
}
int j = 0;
int freq = 0;
for (int i = 0 ; i < n ; i++) {
if (a[i] == p[j].first)
freq++;
if (freq == p[j].second && j != k - 1)
j++,
freq = 0;
}
if (k - 1 == j && freq >= p[j].second) {
cout << "yes" << endl;
} else {
cout << "no" << endl;
}
}
int main() {
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
Copy