description: You are given an array a of length n.
  
  Let's define the eversion operation. Let x = a_n. Then array a is partitioned into two parts: left and right. The left part contains the elements of a that are not greater than x (≤ x). The right part contains the elements of a that are strictly greater than x (> x). The order of elements in each part is kept the same as before the operation, i. e. the partition is stable. Then the array is replaced with the concatenation of the left and the right parts.
  
  For example, if the array a is [2, 4, 1, 5, 3], the eversion goes like this: [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5].
  
  We start with the array a and perform eversions on this array. We can prove that after several eversions the array a stops changing. Output the minimum number k such that the array stops changing after k eversions.
  
  Input
  
  Each test contains multiple test cases. The first line contains the number of test cases t (1 ≤ t ≤ 100). Description of the test cases follows.
  
  The first line contains a single integer n (1 ≤ n ≤ 2 ⋅ 10^5).
  
  The second line contains n integers a_1, a_2, ..., a_n (1 ≤ a_i ≤ 10^9).
  
  It is guaranteed that the sum of n over all test cases does not exceed 2 ⋅ 10^5.
  
  Output
  
  For each test case print a single integer k — the number of eversions after which the array stops changing.
  
  Example
  
  Input
  
  
  3
  5
  2 4 1 5 3
  5
  5 3 2 4 1
  4
  1 1 1 1
  
  
  Output
  
  
  1
  2
  0
  
  Note
  
  Consider the fist example.
  
    * The first eversion: a = [1, 4, 2, 5, 3], x = 3. [2, 4, 1, 5, 3] → [2, 1, 3], [4, 5] → [2, 1, 3, 4, 5]. 
    * The second and following eversions: a = [2, 1, 3, 4, 5], x = 5. [2, 1, 3, 4, 5] → [2, 1, 3, 4, 5], [] → [2, 1, 3, 4, 5]. This eversion does not change the array, so the answer is 1. 
  
  
  
  Consider the second example. 
  
    * The first eversion: a = [5, 3, 2, 4, 1], x = 1. [5, 3, 2, 4, 1] → [1], [5, 3, 2, 4] → [1, 5, 3, 2, 4]. 
    * The second eversion: a = [1, 5, 3, 2, 4], x = 4. [1, 5, 3, 2, 4] → [1, 3, 2, 4], [5] → [1, 3, 2, 4, 5]. 
    * The third and following eversions: a = [1, 3, 2, 4, 5], x = 5. [1, 3, 2, 4, 5] → [1, 3, 2, 4, 5], [] → [1, 3, 2, 4, 5]. This eversion does not change the array, so the answer is 2. 
solution: /*
  
  Sample Input 1
  
  3
  5
  2 4 1 5 3
  5
  5 3 2 4 1
  4
  1 1 1 1
  
  Sample Output 1
  
  1
  2
  0
  
  */
  import java.io.*;
  import java.util.*;
    
  public class R1591B
  {
      static int MAX(int x, int y){return ((x > y) ? x : y );}
      static int MIN(int x, int y){return ((x < y) ? x : y );}
      static int sum(int[] A){int sum = 0;for(int i=0; i<A.length; i++)sum+=A[i];return (sum);}
      static int gcd(int a, int b){if (b == 0)return a;return gcd(b, a % b);}
      static boolean isPowerOfTwo(int n){if(n==0)return false;return (int)(Math.ceil((Math.log(n) / Math.log(2)))) ==(int)(Math.floor(((Math.log(n) / Math.log(2)))));}
      static void swap(int[] a, int idx1, int idx2){if (a[idx1] == a[idx2])return;a[idx1] ^= a[idx2];a[idx2] ^= a[idx1];a[idx1] ^= a[idx2];}
      static int countDigits(long l)
      {
              if (l >= 1000000000000000000L) return 19;
              if (l >= 100000000000000000L) return 18;
              if (l >= 10000000000000000L) return 17;
              if (l >= 1000000000000000L) return 16;
              if (l >= 100000000000000L) return 15;
              if (l >= 10000000000000L) return 14;
              if (l >= 1000000000000L) return 13;
              if (l >= 100000000000L) return 12;
              if (l >= 10000000000L) return 11;
              if (l >= 1000000000L) return 10;
              if (l >= 100000000L) return 9;
              if (l >= 10000000L) return 8;
              if (l >= 1000000L) return 7;
              if (l >= 100000L) return 6;
              if (l >= 10000L) return 5;
              if (l >= 1000L) return 4;
              if (l >= 100L) return 3;
              if (l >= 10L) return 2;
              return 1;
      }
      static void sort2D(int[][] Arr){Arrays.sort(Arr, (a, b) -> Double.compare(a[0], b[0]));}
      public static void main(String[] args) throws IOException
      {
          BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
          if (System.getProperty("ONLINE_JUDGE") == null)
          {
              try 
              {
                  in = new BufferedReader(new FileReader("input.txt"));
                  System.setOut(new PrintStream(new FileOutputStream("output.txt")));
              }
              catch (Exception e) {
                  //System.out.println("Exception");
              }
          }
          int T = Integer.parseInt(in.readLine());
          while( T -- > 0)
          {
              int N = Integer.parseInt(in.readLine());
              String lines = in.readLine();
              String[] strs = lines.trim().split("\\s+");
              int[] ar = new int[N];
              int max = Integer.MIN_VALUE;
              for(int i = 0; i < N; i++)
              {
                  ar[N-i-1] = Integer.parseInt(strs[i]);
                  max = MAX(max,ar[N-i-1]);
              }
              int last = Integer.MIN_VALUE;
              int ret = 0;
              for(int i : ar)
              {
                  if(i == max)
                      break;
                  else if(i < max && i > last)
                  {
                      ret++;
                      last = i;
                  }
                  else if(i > last)
                      last = i;
              }
              // for(int i : ar)
              //     System.out.print(i+" ");
              System.out.println(ret);
          }
      }
      private static int lengthOfLIS(int[] nums)
      {
          int N = nums.length;
          int[] dp = new int[N];
          Arrays.fill(dp,1);
          int max = 1;
          for(int i = 0; i < N; i++)
          {
              for(int j = i-1; j >= 0; j--)
              {
                  if(nums[i] > nums[j] && dp[j] + 1 > dp[i])
                      dp[i] = dp[j] + 1;
                  max = Math.max(dp[i],max);
              }
          }
          return max;
      }
  }