#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 19;
int t, n, m, big;
int pp[N];
struct node {
  int p, s;
} hero[N], thero[N];
bool cmp(node l1, node l2) {
  if (l1.p == l2.p) return l1.s > l2.s;
  return l1.p > l2.p;
}
void work() {
  if (big > hero[1].p) {
    printf("-1\n");
    return;
  }
  int tnum = 1, st = 1;
  node k = hero[1];
  for (int i = 2; i <= m; ++i) {
    if (hero[i].p >= big && hero[i].s > k.s) {
      k = hero[i];
      st = i;
    }
    if (hero[i].p < big) {
      break;
    }
  }
  thero[1] = k;
  for (int i = st + 1; i <= m; ++i) {
    if (hero[i].s > thero[tnum].s) {
      thero[++tnum] = hero[i];
    }
  }
  int day = 0, now = 1;
  while (now <= n) {
    int nbig = pp[now], hh = 1, can = 0, rest = thero[1].s;
    while (nbig <= thero[hh].p && hh <= tnum && rest) {
      for (int i = now; i - now < rest && i <= n; ++i) {
        nbig = max(nbig, pp[i]);
        if (nbig > thero[hh].p) break;
        can++;
      }
      hh++;
      rest = thero[hh].s - thero[hh - 1].s;
      now += can;
      can = 0;
    }
    day++;
  }
  printf("%d\n", day);
}
int main() {
  scanf("%d", &t);
  while (t--) {
    big = -1;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
      scanf("%d", &pp[i]);
      big = max(big, pp[i]);
    }
    scanf("%d", &m);
    for (int i = 1; i <= m; ++i) {
      scanf("%d %d", &hero[i].p, &hero[i].s);
    }
    sort(hero + 1, hero + m + 1, cmp);
    work();
  }
  return 0;
}
