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: import com.sun.security.jgss.GSSUtil;
  
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.math.BigInteger;
  import java.util.*;
  
  
  public class javacp{
  
  
      static FastReader fs=new FastReader();
      static class FastReader{
          BufferedReader br;
          StringTokenizer st;
          public FastReader(){
              br = new BufferedReader(new InputStreamReader(System.in));
          }
          String next(){
              while (st == null || !st.hasMoreElements()){
                  try{
                      st = new StringTokenizer(br.readLine());
                  }catch (IOException e){
                      e.printStackTrace();
                  }
              }
              return st.nextToken();
          }
          int nextInt(){
              return Integer.parseInt(next());
          }
          long nextLong(){
              return Long.parseLong(next());
          }
          double nextDouble(){
              return Double.parseDouble(next());
          }
          String nextLine(){
              String str = "";
              try{
                  str = br.readLine();
              }catch (IOException e){
                  e.printStackTrace();
              }
              return str;
          }
  
          int[] inputIntArray(int n){
              int[] arr = new int[n];
              for(int i=0;i<n;i++)
                  arr[i] = fs.nextInt();
  
              return arr;
          }
      }
  
      static void sort(int[] arr){
          ArrayList<Integer> al = new ArrayList<>();
          for(int val : arr){
              al.add(val);
          }
  
          Collections.sort(al);
          for(int i=0;i<arr.length;i++){
              arr[i] = al.get(i);
          }
      }
  
      static class Pair implements Comparable<Pair>{
          int src;
          int dest;
          long wt;
  
          Pair(int src,int dest,long wt){
              this.src = src;
              this.dest = dest;
              this.wt = wt;
          }
  
          public int compareTo(Pair pair){
              if(this.wt > pair.wt)
                  return 1;
              else if(this.wt < pair.wt)
                  return -1;
              else
                  return 0;
          }
      }
  
  
      static int[] par1 , rank1 , size;
      static int[] par2;
      static int[] rank2;
  
      static boolean union1(int vt1 , int vt2){
          int parent1 = findParent1(vt1) , parent2 = findParent1(vt2);
          int r1 = rank1[parent1] , r2 =  rank1[parent2];
  
          if(parent1 == parent2) return false;
  
          if(r1 < r2) {
              par1[parent1] = parent2;
              size[parent2] += size[parent1];
          }
          else{
              par1[parent2] = parent1;
              size[parent1] += size[parent2];
          }
  
          if(r1 == r2) rank1[parent1]++;
  
          return true;
      }
  
      static void union2(int vt1 , int vt2){
          int parent1 = findParent2(vt1) , parent2 = findParent2(vt2);
          int r1 = rank2[parent1] , r2 =  rank2[parent2];
  
          if(parent1 == parent2) return;
  
          if(r1 < r2)
              par2[parent1] = parent2;
          else par2[parent2] = parent1;
  
          if(r1 == r2) rank2[parent1]++;
      }
  
      static int findParent1(int vt){
          if(par1[vt] == vt) return vt;
          par1[vt] = findParent1(par1[vt]);
  
          return par1[vt];
      }
  
      static int findParent2(int vt){
          if(par2[vt] == vt) return vt;
          par2[vt] = findParent2(par2[vt]);
  
          return par2[vt];
      }
  
      static void initialise1(int numOfVtces){
          par1 = new int[numOfVtces];
          rank1 = new int[numOfVtces];
          size = new int[numOfVtces];
  
          for(int i=0;i<numOfVtces;i++){
              par1[i] = i;
              rank1[i] = 1;
              size[i] = 1;
          }
      }
  
      static void initialise2(int numOfVtces){
          par2 = new int[numOfVtces];
          rank2 = new int[numOfVtces];
  
          for(int i=0;i<numOfVtces;i++){
              par2[i] = i;
              rank2[i] = 0;
          }
      }
  
  
  
      public static void main(String[] args) throws IOException{
  
          int t = 1;
          t = fs.nextInt();
  
          while (t-- > 0) {
              int n = fs.nextInt();
              int[] arr = fs.inputIntArray(n);
  
              int[] greaterElementInLeft = new int[n];
              Stack<Integer> stack = new Stack<>();
  
              for(int i=0; i<n; i++){
                  while (stack.size() != 0 && arr[stack.peek()] <= arr[i]){
                      stack.pop();
                  }
                  if(stack.size() == 0) greaterElementInLeft[i] = -1;
                  else greaterElementInLeft[i] = stack.peek();
  
                  stack.push(i);
              }
  
              int count = 0 , idx = n-1;
              while (greaterElementInLeft[idx] != -1){
                  count++;
                  idx = greaterElementInLeft[idx];
              }
  
              System.out.println(count);
          }
      }
  
      private static String generateABPattern(int a , int b){
          StringBuilder sb = new StringBuilder();
          while (a > 0 || b > 0){
              if(b-a >= 2){
                  sb.append("bb");
                  if(a != 0){
                      sb.append("a");
                      a--;
                  }
                  b -= 2;
              }
              else if(a-b >= 2){
                  sb.append("aa");
                  if(b != 0){
                      sb.append("b");
                      b--;
                  }
                  a -= 2;
              }
              else if(a >= b){
                  sb.append("a");
                  a--;
              }
              else{
                  sb.append("b");
                  b--;
              }
          }
  
          return sb.toString();
      }
      private static int binarySearch(int[] arr , int i , int  j , int val){
          while (i <= j){
              int mid = (i+j)/2;
              if(arr[mid] == val) return mid;
              else if(arr[mid] > val) j = mid-1;
              else i = mid+1;
          }
          return -1;
      }
  
      private static int lower_bound(int[] arr , int i, int j, int val){
          int min = -1;
          while (i <= j){
              int mid = (i+j)/2;
              if(arr[mid] > val) j = mid-1;
              else{
                  min = mid;
                  i = mid+1;
              }
          }
          return min;
      }
  
      private static int upper_bound(int[] arr, int i , int j , int val){
          int min = -1;
          while (i <= j){
              int mid = (i+j)/2;
              if(arr[mid] < val) i = mid+1;
              else{
                  min = mid;
                  j = mid-1;
              }
          }
          return min;
      }
  
      static int modInverse(int a, int m)
      {
          int m0 = m;
          int y = 0, x = 1;
  
          if (m == 1)
              return 0;
  
          while (a > 1) {
              // q is quotient
              int q = a / m;
  
              int t = m;
  
              // m is remainder now, process
              // same as Euclid's algo
              m = a % m;
              a = t;
              t = y;
  
              // Update x and y
              y = x - q * y;
              x = t;
          }
  
          // Make x positive
          if (x < 0)
              x += m0;
  
          return x;
      }
  
      static int mod = 1000000007;
      static long  power(long a,long b,long m) {
          a %= m;
          long res = 1;
          while (b > 0) {
              if ((b & 1) == 1)
                  res = res * a % m;
              a = a * a % m;
              b >>= 1;
          }
          return res;
      }
  
      static class CustomSort implements Comparator<int[]> {
  
          public int compare(int[] a, int[] b)
          {
              return a[0] - b[0];
          }
      }
  
      static void printArr(int[] arr){
          for(int i=0;i< arr.length;i++)
          {
              System.out.print(arr[i] + " ");
          }
          System.out.println();
      }
  
      private static int lcm(int a, int b) {
          int gcd = gcd(a,b);
          return (int)((long)a*(long)b)/gcd ;
      }
  
  
      private static int gcd(int a, int b) {
          if(b == 0) return a;
          else return gcd(b , a % b);
      }
  
  
      private static void swap(int[] arr, int start, int rand_pivot) {
          int temp = arr[start];
          arr[start] = arr[rand_pivot];
          arr[rand_pivot] = temp;
      }
  
  
  }