You play a computer game. In this game, you lead a party of m heroes, and you have to clear a dungeon with n monsters. Each monster is characterized by its power a_i. Each hero is characterized by his power p_i and endurance s_i.

The heroes clear the dungeon day by day. In the beginning of each day, you choose a hero (exactly one) who is going to enter the dungeon this day.

When the hero enters the dungeon, he is challenged by the first monster which was not defeated during the previous days (so, if the heroes have already defeated k monsters, the hero fights with the monster k + 1). When the hero fights the monster, there are two possible outcomes:

  * if the monster's power is strictly greater than the hero's power, the hero retreats from the dungeon. The current day ends; 
  * otherwise, the monster is defeated. 



After defeating a monster, the hero either continues fighting with the next monster or leaves the dungeon. He leaves the dungeon either if he has already defeated the number of monsters equal to his endurance during this day (so, the i-th hero cannot defeat more than s_i monsters during each day), or if all monsters are defeated — otherwise, he fights with the next monster. When the hero leaves the dungeon, the current day ends.

Your goal is to defeat the last monster. What is the minimum number of days that you need to achieve your goal? Each day you have to use exactly one hero; it is possible that some heroes don't fight the monsters at all. Each hero can be used arbitrary number of times.

Input

The first line contains one integer t (1 ≤ t ≤ 10^5) — the number of test cases. Then the test cases follow.

The first line of each test case contains one integer n (1 ≤ n ≤ 2 ⋅ 10^5) — the number of monsters in the dungeon.

The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9), where a_i is the power of the i-th monster.

The third line contains one integer m (1 ≤ m ≤ 2 ⋅ 10^5) — the number of heroes in your party.

Then m lines follow, each describing a hero. Each line contains two integers p_i and s_i (1 ≤ p_i ≤ 10^9, 1 ≤ s_i ≤ n) — the power and the endurance of the i-th hero.

It is guaranteed that the sum of n + m over all test cases does not exceed 2 ⋅ 10^5.

Output

For each test case print one integer — the minimum number of days you have to spend to defeat all of the monsters (or -1 if it is impossible).

Example

Input


2
6
2 3 11 14 1 8
2
3 2
100 1
5
3 5 100 2 3
2
30 5
90 1


Output


5
-1
  //  package com.company;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.lang.reflect.Array;
    import java.sql.SQLOutput;
    import java.util.*;
    public class Main {

        public static void main(String[] args) throws IOException {
           Scanner s = new Scanner(System.in);
           //BufferedReader s=new BufferedReader(new InputStreamReader(System.in));
             StringBuilder sb = new StringBuilder();//int n=Integer.parseInt(s.readLine());
              int t=s.nextInt();
              while(t-->0){
                  int n=s.nextInt();int[] a=new int[n];
                  for(int i=0;i<n;i++)
                      a[i]=s.nextInt();
                  int m=s.nextInt();
                  Student[] st=new Student[m];
                  for(int i=0;i<m;i++){
                      st[i]=new Student(s.nextInt(),s.nextInt());
                  }
                    Arrays.sort(st,new Sortbyroll());int[] end=new int[n+1];int pre=0;
                  for(int i=m-1;i>=0;i--){
                      end[st[i].r]=Math.max(pre,st[i].l);
                      pre=Math.max(pre,st[i].l);
                  }int nm=-1;int ans=1;int x=0;
                  for(int i=n;i>=0;i--){
                      x=Math.max(x,end[i]);
                      end[i]=x;
                  }int flag=0;int hu=0;
                  for(int i=0;i<n;i++){
                      if(end[i-nm]>=Math.max(a[i],hu)){
                          hu=Math.max(a[i],hu);
                          continue;
                      }else if(end[1]>=a[i]){hu=a[i];
                          nm=i-1;ans++;
                      }else {
                          flag=1;break;
                      }
                  }if(flag==1) sb.append(-1+"\n");
                  else sb.append(ans+"\n");
              }
            System.out.println(sb.toString());
        }
        static boolean isPrime(int n)
        {
            // Corner cas
            if (n <= 1) return false;
            if (n <= 3) return true;

            // This is checked so that we can skip
            // middle five numbers in below loop
            if (n % 2 == 0 || n % 3 == 0) return false;

            for (int i = 5; i * i <= n; i = i + 6)
                if (n % i == 0 || n % (i + 2) == 0)
                    return false;

            return true;
        }
        static boolean isPrime(int n, int k)
        {
            // Corner cases
            if (n <= 1 || n == 4) return false;
            if (n <= 3) return true;

            // Try k times
            while (k > 0)
            {
                // Pick a random number in [2..n-2]
                // Above corner cases make sure that n > 4
                int a = 2 + (int)(Math.random() % (n - 4));

                // Fermat's little theorem
                if (power(a, n - 1, n) != 1)
                    return false;

                k--;
            }

            return true;
        }
        static double power(double x, long y, int p) {
            double res = 1;
            x = x % p;
            while (y > 0) {
                if ((y & 1) == 1)
                    res = (res * x) % p;
                y = y >> 1;
                x = (x * x) % p;
            }
            return res;
        }
        public static void fracion(double x) {
            String a = "" + x;
            String spilts[] = a.split("\\."); // split using decimal
            int b = spilts[1].length(); // find the decimal length
            int denominator = (int) Math.pow(10, b); // calculate the denominator
            int numerator = (int) (x * denominator); // calculate the nerumrator Ex
            // 1.2*10 = 12
            int gcd = gcd(numerator, denominator); // Find the greatest common
            // divisor bw them
            String fraction = "" + numerator / gcd + "/" + denominator / gcd;
            // System.out.println((denominator/gcd));
            long x1=modInverse(denominator / gcd,998244353  );
            //  System.out.println(x1);
            System.out.println((((numerator / gcd )%998244353 *(x1%998244353  ))%998244353  ) );
        }static int max=Integer.MIN_VALUE;
static int max1=Integer.MIN_VALUE;static int[] ans;static long[][] dp;static int[][] c;
        public static int dfs(int papa, int i, ArrayList<Integer>[] h, int[] vis) {

             vis[i] = 1;
               if(papa!=-1){
                   dp[i-1][0]=Math.min(dp[i-1][0],c[0][i-1]+Math.min(dp[papa-1][1],dp[papa-1][2]));
                   dp[i-1][1]=Math.min(dp[i-1][1],c[1][i-1]+Math.min(dp[papa-1][0],dp[papa-1][2]));
                   dp[i-1][2]=Math.min(dp[i-1][2],c[2][i-1]+Math.min(dp[papa-1][1],dp[papa-1][0]));

               }else{
                   dp[i-1][0]=c[i-1][0];
                   dp[i-1][1]=c[i-1][1];
                   dp[i-1][2]=c[i-1][2];

               }
             for(Integer j:h[i]){
                      if(vis[j]==0){
                          dfs(i,j,h,vis);
                      }
             }ans[i]+=1;if(ans[i]>max){
                 max=ans[i];max1=i;
            }
          return ans[i];
        }



        public static void bfs(int i, HashMap<Integer, Integer>[] h, int[] vis, int len, int papa) {
            Queue<Integer> q = new LinkedList<Integer>();
            q.add(i);

        }


        static int i(String a) {
            return Integer.parseInt(a);
        }

        static long l(String a) {
            return Long.parseLong(a);
        }

        static String[] inp() throws IOException {
            BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
            return s.readLine().trim().split("\\s+");
        }


        static int gcd(int a, int b) {
            if (b == 0)
                return a;
            return gcd(b, a % b);
        }
        static long modInverse(int a, int m)
        {


            {
                // If a and m are relatively prime, then modulo inverse
                // is a^(m-2) mode m
                return (power(a, m - 2, m));
            }
        }

        // To compute x^y under modulo m
        static long power(int x, int y, int m)
        {
            if (y == 0)
                return 1;

            long p = power(x, y / 2, m) % m;
            p = (p * p) % m;

            if (y % 2 == 0)
                return p;
            else
                return (x * p) % m;
        }

        // Function to return gcd of a and b

    }
    class Student
    {
        Integer l;Integer r;

        public Student(Integer l, Integer r) {
            this.l = l;
            this.r = r;

        }
    // Constructor


        // Used to print student details in main()
        public String toString()
        {
            return this.l+" ";
        }
    }

    class Sortbyroll implements Comparator<Student>
    {
        // Used for sorting in ascending order of
        // roll number
        public int compare(Student a, Student b){
            return a.r-b.r;
        }
    }