#include <bits/stdc++.h>
using namespace std;
struct Hero {
  int s, p;
} h[200001];
bool comp(Hero A, Hero B) { return A.s < B.s || (A.s == B.s && A.p < B.p); }
int Segment_Tree[200001 * 4];
void build(int index, int l, int r) {
  if (l == r) {
    Segment_Tree[index] = h[l].p;
    return;
  }
  int m = (l + r) / 2;
  build(index * 2, l, m);
  build(index * 2 + 1, m + 1, r);
  Segment_Tree[index] =
      max(Segment_Tree[index * 2], Segment_Tree[index * 2 + 1]);
}
int query(int index, int l, int r, int L, int R) {
  if (l > R || r < L) return -1;
  if (L <= l && r <= R) {
    return Segment_Tree[index];
  }
  int m = (l + r) / 2;
  int f = query(index * 2, l, m, L, R);
  int s = query(index * 2 + 1, m + 1, r, L, R);
  int res = max(f, s);
  return res;
}
int main() {
  int T = 1;
  scanf("%d", &T);
  while (T--) {
    int n, i, j, m;
    scanf("%d", &n);
    int a[n];
    int max_power_with_this_s[n + 1];
    for (i = 0; i < n; i++) {
      scanf("%d", &a[i]);
      max_power_with_this_s[i + 1] = -1;
    }
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf("%d %d", &h[i].p, &h[i].s);
    }
    sort(h, h + m, comp);
    build(1, 0, m - 1);
    j = 0;
    for (i = 1; i <= n; i++) {
      while (j < m && h[j].s < i) {
        j++;
      }
      if (j >= m) break;
      max_power_with_this_s[i] = query(1, 0, m - 1, j, m - 1);
    }
    j = 0;
    int days = 0;
    for (i = 0; i < n; i++) {
      int b = i;
      int max_so_far = a[i];
      if (max_power_with_this_s[1] < max_so_far) {
        break;
      }
      while (i + 1 < n) {
        max_so_far = max(max_so_far, a[i + 1]);
        if (max_so_far <= max_power_with_this_s[i + 1 - b + 1])
          i++;
        else
          break;
      }
      days++;
    }
    if (i < n) {
      printf("-1");
    } else {
      printf("%d", days);
    }
    printf("\n");
  }
  return 0;
}
