import math
# import sys
from collections import Counter, defaultdict, deque

def f(n, p):
    # prevL = 1
    # currL = 0
    # i = 1
    # nL = True
    # height = 1
    # while i < n:
    #     #print(i, prevL, currL, nL, height)
    #     if nL:
    #         currL += 1
    #         nL = False
    #         i += 1
    #         continue
    #     if p[i] > p[i-1]:
    #         currL += 1
    #         i += 1
    #     else:
    #         if prevL > 1:
    #             prevL -= 1
    #             nL = True
    #             i += 1
    #             currL += 1
    #         else:
    #             prevL = currL
    #             height += 1
    #             nL = True
    #             #i += 1
    #             currL = 0
    height = 0
    q = []
    i = 1
    l = 1
    cl = 0
    while i < n:
        #print(i, height, q)
        if q == []:
            q.append(p[i])
            cl += 1
            i += 1
            continue
        if p[i] > q[-1]:
            q.append(p[i])
            cl += 1
            i+= 1
        else:
            l -= 1
            if l > 0:
                #cl += len(q)
                q = []
            else:
                l = cl
                height += 1
                cl = 0
                q = []
    #print(q, l)
    if q != [] and l > 0:
        height += 1

    return height

t = int(input())
result = []
for i in range(t):
    n = int(input())
    p = list(map(int,input().split()))
    result.append(f(n, p))
for i in range(t):
    print(result[i])


import math
# import sys
from collections import Counter, defaultdict, deque

def f(n, p):
    prevL = 1
    currL = 1
    i = 2
    height = 1
    while i < n:
        #print(prevL, currL, i)
        if p[i] > p[i-1]:
            i += 1
            currL += 1
        else:
            if prevL > 1:
                prevL -= 1
                i += 2
                currL += 1
            else:
                prevL = currL
                currL = 1
                height += 1
                i += 2
    return height

t = int(input())
result = []
for i in range(t):
    n = int(input())
    p = list(map(int,input().split()))
    result.append(f(n, p))
for i in range(t):
    print(result[i])


import math
# import sys
from collections import Counter, defaultdict, deque

def f(n, p):
    prevL = 1
    currL = 0
    i = 1
    nL = True
    height = 1
    while i < n:
        #print(i, prevL, currL, nL, height)
        if nL:
            currL += 1
            nL = False
            i += 1
            continue
        if p[i] > p[i-1]:
            currL += 1
            i += 1
        else:
            if prevL > 1:
                prevL -= 1
                nL = True
                i += 1
                currL += 1
            else:
                prevL = currL
                height += 1
                nL = True
                #i += 1
                currL = 0

    return height

t = int(input())
result = []
for i in range(t):
    n = int(input())
    p = list(map(int,input().split()))
    result.append(f(n, p))
for i in range(t):
    print(result[i])


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

A new level is only necessary when we cannot append the node anywhere else

"""

def solve():
    N = getInt()
    A = getInts()
    levels = [1]
    inc, dec = 0, 0
    for i in range(1,N):
        if A[i-1] < A[i] or i == 1:
            inc += 1
        else:
            dec += 1
            if dec >= levels[-1]:
                levels.append(inc+dec-1)
                inc = 0
                dec = 0
    levels.append(inc+dec)
    levels = levels[1:]
    return(len(levels))

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
inc tells us how many nodes higher than their neighbour we've had since the last level was introduced
dec tells us how many nodes lower than their neighbour we've had

each time a node is higher, we can just keep adding it to the same parent as the previous node
each time a node is lower, we must find a different parent

the number of available parents becomes

1 2 6 5 8 7 3 4 9 10
"""

def solve():
    N = getInt()
    A = getInts()
    levels = [1]
    inc, dec = 0, 0
    for i in range(1,N):
        if A[i-1] < A[i]:
            inc += 1
        else:
            dec += 1
            if dec >= levels[-1]:
                levels.append(inc+dec-1)
                inc = 1
                dec = 0
    return(len(levels))

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""

"""

def solve():
    N = getInt()
    A = getInts()
    levels = [1]
    inc, dec = 0, 0
    for i in range(1,N):
        if A[i-1] < A[i]:
            inc += 1
        else:
            dec += 1
            if dec >= levels[-1]:
                levels.append(inc+dec-1)
                inc = 1
                dec = 0
    levels.append(inc+dec)
    levels = levels[1:]
    return(len(levels))

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

A new level is only necessary when we cannot append the node anywhere else

"""

def solve():
    N = getInt()
    A = getInts()
    levels = [1]
    inc, dec = 0, 0
    for i in range(1,N):
        if A[i-1] < A[i] or not (inc+dec):
            inc += 1
        else:
            dec += 1
            if dec >= levels[-1]:
                levels.append(inc+dec-1)
                inc = 1
                dec = 0
    levels.append(inc+dec)
    levels = levels[1:]
    return(len(levels))

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

A new level is only necessary when we cannot append the node anywhere else

"""

def solve():
    N = getInt()
    A = getInts()
    levels = [1]
    inc, dec = 0, 0
    for i in range(1,N):
        if A[i-1] < A[i] or not (inc+dec):
            inc += 1
        else:
            dec += 1
            if dec >= levels[-1]:
                levels.append(inc+dec-1)
                inc = 0
                dec = 0
    levels.append(inc+dec)
    levels = levels[1:]
    return(len(levels))

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

"""

def prev_smaller(arr,N):
    stack = dq([])
    stack.append((arr[-1],N-1))
    res = dd(int)
    for i in range(N-2,-1,-1):
        if len(stack) == 0:
            stack.append((arr[i],i))
            continue
        while len(stack) > 0 and stack[-1][0] >= arr[i]: # change the inequalities here to strict if required
            res[stack[-1][1]] = i
            stack.pop()
        stack.append((arr[i],i))
    while stack:
        res[stack[-1][1]] = -1
        stack.pop()
    return res

def solve():
    N = getInt()
    A = getInts()
    prev = prev_smaller(A,N)
    ans = 0
    for i in range(N):
        if prev[i] < 1:
            ans += 1
    return ans-1

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

A new level is only necessary when we cannot append the node anywhere else

"""

def prev_smaller(arr,N):
    stack = dq([])
    stack.append((arr[-1],N-1))
    res = dd(int)
    for i in range(N-2,-1,-1):
        if len(stack) == 0:
            stack.append((arr[i],i))
            continue
        while len(stack) > 0 and stack[-1][0] > arr[i]: # change the inequalities here to strict if required
            res[stack[-1][1]] = i
            stack.pop()
        stack.append((arr[i],i))
    while stack:
        res[stack[-1][1]] = -1
        stack.pop()
    return res

def solve():
    N = getInt()
    A = getInts()
    prev = prev_smaller(A,N)
    #print(prev)
    ans = 1
    children = []
    h.heapify(children)
    levels = [0]*N
    h.heappush(children,0)
    for i in range(1,N):
        if prev[i] == 0:
            lev = h.heappop(children)
            levels[i] = lev + 1
            h.heappush(children,levels[i])
        else:
            h.heappush(children,levels[prev[i]])
            levels[i] = levels[prev[i]]

    return max(levels)

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

A new level is only necessary when we cannot append the node anywhere else

"""

def prev_smaller(arr,N):
    stack = dq([])
    stack.append((arr[-1],N-1))
    res = dd(int)
    for i in range(N-2,-1,-1):
        if len(stack) == 0:
            stack.append((arr[i],i))
            continue
        while len(stack) > 0 and stack[-1][0] > arr[i]: # change the inequalities here to strict if required
            res[stack[-1][1]] = i
            stack.pop()
        stack.append((arr[i],i))
    while stack:
        res[stack[-1][1]] = -1
        stack.pop()
    return res

def solve():
    N = getInt()
    A = getInts()
    prev = prev_smaller(A,N)
    #print(prev)
    ans = 1
    children = []
    h.heapify(children)
    levels = [0]*N
    levels[0] = 0
    for i in range(1,N):
        if prev[i] == 0:
            if children:
                lev = h.heappop(children)
                levels[i] = lev + 1
            else:
                h.heappush(children,2)
                levels[i] = 1
        else:
            h.heappush(children,levels[prev[i]])
            levels[i] = levels[prev[i]]

    return max(levels)

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

"""

def prev_smaller(arr,N):
    stack = dq([])
    stack.append((arr[-1],N-1))
    res = dd(int)
    for i in range(N-2,-1,-1):
        if len(stack) == 0:
            stack.append((arr[i],i))
            continue
        while len(stack) > 0 and stack[-1][0] > arr[i]: # change the inequalities here to strict if required
            res[stack[-1][1]] = i
            stack.pop()
        stack.append((arr[i],i))
    while stack:
        res[stack[-1][1]] = -1
        stack.pop()
    return res

def solve():
    N = getInt()
    A = getInts()
    prev = prev_smaller(A,N)
    #print(prev)
    ans = 1
    for i in range(2,N):
        if prev[i] < 1:
            ans += 1
    return ans

for _ in range(getInt()):

    print(solve())
    #solve()


"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""

import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right

from types import GeneratorType
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        import os
        self.os = os
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            self.os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

from collections import defaultdict as dd, deque as dq
import math, string

def getInts():
    return [int(s) for s in input().split()]

def getInt():
    return int(input())

def getStrs():
    return [s for s in input().split()]

def getStr():
    return input()

def listStr():
    return list(input())

MOD = 10**9+7

"""
always better to make it a child of the highest node possible
1 2 4 3

1 5 4

1 2 5 4

A new level is only necessary when we cannot append the node anywhere else

"""

def prev_smaller(arr,N):
    stack = dq([])
    stack.append((arr[-1],N-1))
    res = dd(int)
    for i in range(N-2,-1,-1):
        if len(stack) == 0:
            stack.append((arr[i],i))
            continue
        while len(stack) > 0 and stack[-1][0] > arr[i]: # change the inequalities here to strict if required
            res[stack[-1][1]] = i
            stack.pop()
        stack.append((arr[i],i))
    while stack:
        res[stack[-1][1]] = -1
        stack.pop()
    return res

def solve():
    N = getInt()
    A = getInts()
    prev = prev_smaller(A,N)
    #print(prev)
    ans = 1
    children = 0
    for i in range(2,N):
        if prev[i] == 0:
            if children < 2:
                ans += 1
            else:
                children -= 1
        else:
            children += 1
    return ans

for _ in range(getInt()):

    print(solve())
    #solve()


"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""

import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")

mod = pow(10, 9) + 7
# mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var)+"\n")
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

for _ in range(int(data())):
    n = int(data())
    arr = l()
    answer = 0
    stack = []
    for i in range(n):
        r = False
        while stack and stack[-1] > arr[i]:
            r = True
            stack.pop()
        answer += int(r)
        stack.append(arr[i])
    out(answer + 1)


"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""

import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
# sys.setrecursionlimit(pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")

mod = pow(10, 9) + 7
# mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var): sys.stdout.write(str(var)+"\n")
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

for _ in range(int(data())):
    n = int(data())
    arr = deque(l())
    stack = deque()
    answer = 0
    stack.append([arr.popleft(), 0])
    while arr:
        a, b = stack.popleft()
        answer = max(answer, b)
        if len(arr) == 1 or arr[0] > arr[1]:
            stack.append([arr.popleft(), b + 1])
            continue
        j = 0
        for i in range(1, len(arr)):
            if arr[i] > arr[i-1]:
                j = i
                continue
            break
        for i in range(j + 1):
            stack.append([arr.popleft(), b + 1])
    while stack:
        answer = max(answer, stack.popleft()[1])
    out(answer)


from queue import Queue

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    q = Queue()
    q.put((a[1], 1))
    pos, res = 2, 1
    while not q.empty():
        node, height = q.get()
        while pos < n:
            if a[pos] < a[pos - 1]:
                q.put((a[pos], height + 1))
                res = height + 1
                pos += 1
                break
            else:
                q.put((a[pos], height))
                pos += 1
    print(res)


from queue import Queue

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    q = Queue()
    q.put((a[1], 1))
    pos, res = 2, 1
    while not q.empty():
        node, height = q.get()
        while pos < n:
            if a[pos] < a[pos - 1]:
                q.put((a[pos], height + 1))
                res += 1
                pos += 1
                break
            else:
                q.put((a[pos], height))
                pos += 1
    print(res)


from queue import Queue

t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    q = Queue()
    q.put((a[1], 1))
    pos, res = 2, 1
    while not q.empty():
        node, height = q.get()
        while pos < n:
            if a[pos] < a[pos - 1]:
                q.put((a[pos], height + 1))
                res = max(res, height + 1)
                pos += 1
                break
            else:
                q.put((a[pos], height))
                pos += 1
    print(res)


"""T=int(input())
for _ in range(0,T):
    n=int(input())
    a,b=map(int,input().split())
    s=input()
    s=[int(x) for x in input().split()]
    for i in range(0,len(s)):
        a,b=map(int,input().split())"""

T=int(input())
for _ in range(0,T):
    n=int(input())
    s=[int(x) for x in input().split()]
    c=1
    k=0
    ans=1
    for i in range(2,len(s)):
        if(s[i]<s[i-1]):
            k+=1
        if(k==c):
            ans+=1
            c=k
            k=0

    print(ans)


T=int(input())
for _ in range(0,T):
    n=int(input())
    s=[int(x) for x in input().split()]
    c=1
    L=[]
    for i in range(2,len(s)):
        if(s[i]>s[i-1]):
            c+=1
        else:
            L.append(c)
            c=1

    L.append(c)

    ans=0
    c=1
    ptr=0
    while(ptr<len(L)):
        k=0
        for i in range(ptr,min(ptr+c,len(L))):
            k+=L[i]

        ans+=1
        ptr=min(ptr+c,len(L))
        c=k

    print(ans)


"""T=int(input())
for _ in range(0,T):
    n=int(input())
    a,b=map(int,input().split())
    s=input()
    s=[int(x) for x in input().split()]
    for i in range(0,len(s)):
        a,b=map(int,input().split())"""

"""T=int(input())
for _ in range(0,T):
    n=int(input())
    s=[int(x) for x in input().split()]
    c=1
    k=0
    ans=1
    L=[]
    for i in range(2,len(s)):
        if(s[i]<s[i-1]):
            k+=1
        if(k==c):
            ans+=1
            c=k
            k=0

    print(ans)"""

T=int(input())
for _ in range(0,T):
    n=int(input())
    s=[int(x) for x in input().split()]
    c=1
    L=[]
    for i in range(2,len(s)):
        if(s[i]>s[i-1]):
            c+=1
        else:
            L.append(c)
            c=1

    L.append(c)

    ans=0
    c=1
    ptr=0
    while(ptr<len(L)):
        k=0
        for i in range(ptr,min(ptr+c,len(L))):
            k+=L[i]

        ans+=1
        ptr=min(ptr+c,len(L))
        c=k

    print(ans)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = 'x' in file.mode or 'w' in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b'\n') + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

def get_input(a=str):
    return a(input())

def get_int_input():
    return get_input(int)

def get_input_arr(a):
    return list(map(a, input().split()))

def get_int_input_arr():
    return get_input_arr(int)

def solve():

    t = get_int_input()

    for _ in range(t):

        n = get_int_input()

        arr = get_int_input_arr()
        arr.append(float("inf"))

        res = 0

        ptr = 1
        tolerance = 1
        new_tolerance = 0
        while ptr < n:
            curr = arr[ptr]
            new_tolerance += 1
            while ptr < n and curr < arr[ptr + 1]:
                ptr += 1
                curr = arr[ptr]
                if tolerance:
                    new_tolerance += 1

            tolerance -= 1
            # print(tolerance, new_tolerance)

            if not tolerance:
                res += 1
                tolerance = new_tolerance
                new_tolerance = 0
            ptr += 1

        if new_tolerance:
            res += 1

        cout<<res<<endl

def main():
    solve()

if __name__ == "__main__":
    main()


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0

    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = 'x' in file.mode or 'w' in file.mode
        self.write = super(FastIO, self).write if self.writable else None

    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s

    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()

    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b'\n') + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')

# Cout implemented in Python
import sys
class ostream:
    def __lshift__(self,a):
        sys.stdout.write(str(a))
        return self
cout = ostream()
endl = '\n'

def get_input(a=str):
    return a(input())

def get_int_input():
    return get_input(int)

def get_input_arr(a):
    return list(map(a, input().split()))

def get_int_input_arr():
    return get_input_arr(int)

def solve():

    t = get_int_input()

    for _ in range(t):

        n = get_int_input()

        arr = get_int_input_arr()
        arr.append(float("inf"))

        res = 1

        ptr = 1
        while ptr < n:
            curr = arr[ptr]
            while ptr < n and curr < arr[ptr + 1]:
                ptr += 1
                curr = arr[ptr]

            if ptr < n:
                res += 1
                ptr += 1

        cout<<res<<endl

def main():
    solve()

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque,Counter
from bisect import *
from math import sqrt,pi,ceil,log,inf
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
    for _ in range(int(input())):
        n = int(input())
        a = list(map(int, input().split()))
        l,i=[],0
        while i<n:
            j=i
            while j<n-1 and a[j]<a[j+1]:
                j+=1
            l.append(j-i+1)
            i=j+1
        m,i,h,su,t=len(l),1,1,l[0]-1,0
        while i<m:
            while i<m and su:
                t+=l[i]
                su-=1
                i+=1
            su=t
            t=0
            h+=1
        print(h)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque,Counter
from bisect import *
from math import sqrt,pi,ceil,log,inf
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
    for _ in range(int(input())):
        n = int(input())
        a = list(map(int, input().split()))
        ans = 0
        for i in range(1, n):
            if a[i - 1] > a[i]:
                ans += 1
        print(ans + 1)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque,Counter
from bisect import *
from math import sqrt,pi,ceil,log,inf
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
    for _ in range(int(input())):
        n = int(input())
        a = list(map(int, input().split()))
        l=[]
        i=0
        while i<n:
            j=i
            while j<n-1 and a[j]<a[j+1]:
                j+=1
            l.append(j-i+1)
            i=j+1
        h=1
        m=len(l)
        su=l[0]-1
        i=1
        while i<m:
            i+=su
            su=sum(l[i:i+su])
            h+=1
        print(h)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


# Legends Always Come Up with Solution
# Author: Manvir Singh

import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict,deque,Counter
from bisect import *
from math import sqrt,pi,ceil,log,inf
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
    for _ in range(int(input())):
        n = int(input())
        a = list(map(int, input().split()))
        if n == 2:
            print(2)
        else:
            ans = 0
            for i in range(1, n):
                if a[i - 1] > a[i]:
                    ans += 1
            print(ans + 1)

# region fastio
BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == "__main__":
    main()


t=int(input())
for _ in range(t):
    n=int(input())
    l=list(map(int,input().split()))
    x=0
    h=1
    q=0
    for i in range(1,n):
        if l[i]>l[i-1]:
            x+=1
        else:
            if q==0:
                h+=1
                q=x-1
            else:
                q-=1


t=int(input())
for _ in range(t):
    n=int(input())
    l=list(map(int,input().split()))
    x=0
    h=1
    q=0
    for i in range(1,n):
        if l[i]>l[i-1]:
            x+=1
        else:
            if q==0:
                h+=1
                q=x-1
            else:
                q-=1
    print(h)


from sys  import stdin,stdout
from collections  import *
from math import *
st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")

mod=1000000007
INF=float('inf')
ANS=[]
def solve():
    n=inp()
    l=li()
    i=0
    j=1
    d={i:[] for i in range(n)}
    while i<n:
        if j==n:
            break
        d[i].append(j)
        a=l[j]
        j+=1
        while j<n and l[j]>=a:
            d[i].append(j)
            a=l[j]
            j+=1
        i+=1
    level={}
    level[0]=0
    q=deque()
    q.append((0,0))
    ans=0
    visited=[False for i in range(n)]
    while q:
        a,b=q.popleft()
        for i in d[a]:
            if not visited[i]:
                visited[i]=True
                level[i]=b+1
                q.append((i,level[i]))
                ans=max(ans,level[i])
    pr(ans)

for _ in range(inp()):
    solve()
#pr('\n'.join(map(str,ANS)))


from collections import *
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    d={}
    i=0
    j=1
    while i<n:
        if j==n:
            for x in range(i,n):
                d[i]=[]
            break
        d[i]=d.get(i,[])+[j]
        a=l[j]
        j+=1
        while j<n and l[j]>=a:
            a=l[j]
            d[i]=d.get(i,[])+[j]
            j+=1
        i+=1
    level={}
    q=deque()
    q.append((0,0))
    level[0]=0
    v=[False for i in range(n+1)]
    v[0]=0
    ans=0
    while q:
        a,b = q.popleft()
        for i in d[a]:
            if not v[i]:
                v[i]=True
                level[i]=level[a]+1
                ans= max(ans,level[i])
                q.append((level[i],i))
    print(ans)


from collections import *
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    d={}
    i=0
    p=[]
    j=1
    while i<n:
        if j==n:
            for x in range(i,n):
                p.append(x)
                d[x]=[]
            break
        d[i]=d.get(i,[])+[j]
        a=l[j]
        j+=1
        while j<n and l[j]>=a:
            a=l[j]
            d[i]=d.get(i,[])+[j]
            j+=1
        i+=1
    level={}
    q=deque()
    q.append((0,0))
    level[0]=0
    v=[False for i in range(n+1)]
    v[0]=0
    ans=0
    while q:
        a,b = q.popleft()
        for i in d[a]:
            if not v[i]:
                v[i]=True
                level[i]=level[a]+1
                ans= max(ans,level[i])
                q.append((level[i],i))

    if p:
        ans=n
        for i in p:
            ans= min(ans,level[i])
        print(ans)
    else:
        print(ans)


from collections import *
for _ in range(int(input())):
    n=int(input())
    l=list(map(int,input().split()))
    d={}
    i=0
    j=1
    while i<n:
        if j==n:
            for x in range(i,n):
                d[x]=[]
            break
        d[i]=d.get(i,[])+[j]
        a=l[j]
        j+=1
        while j<n and l[j]>=a:
            a=l[j]
            d[i]=d.get(i,[])+[j]
            j+=1
        i+=1
    level={}
    q=deque()
    q.append((0,0))
    level[0]=0
    v=[False for i in range(n+1)]
    v[0]=0
    ans=0
    while q:
        a,b = q.popleft()
        for i in d[a]:
            if not v[i]:
                v[i]=True
                level[i]=level[a]+1
                ans= max(ans,level[i])
                q.append((level[i],i))
    print(ans)


import sys
input=sys.stdin.readline
for _ in range(int(input())):
	n=int(input())
	# l,r=map(int,input().split())
	# s=input().strip()
	a=list(map(int,input().split()))
	ans=1
	# pre=0
	# c=0
	# for i in range(1,n):
	# 	if a[i]<pre:
	# 		if c>1:
	# 			c-=1
	# 		else:
	# 			ans+=1
	# 			c=0
	# 	else:
	# 		c+=1
	# 	pre=a[i]
	# print(ans)

	c={0:1,1:0}
	k=0
	pre=1
	for i in range(1,n):
		if a[i]>pre:
			pre=a[i]
			k+=1
		else:
			if c[ans-1]<=1:
				if ans in c:c[ans]+=k
				else:c[ans]=k
				ans+=1
				pre=a[i]
				k=1
			else:
				c[ans-1]-=1
				if ans in c:c[ans]+=k
				else:c[ans]=k
				k=1
		# print(c,k)
	print(ans)


import sys
input=sys.stdin.readline
for _ in range(int(input())):
	n=int(input())
	# l,r=map(int,input().split())
	# s=input().strip()
	a=list(map(int,input().split()))
	ans=1
	pre=0
	for i in range(1,n):
		if a[i]<pre:
			ans+=1
		pre=a[i]
	print(ans)


import sys
input=sys.stdin.readline
for _ in range(int(input())):
	n=int(input())
	# l,r=map(int,input().split())
	# s=input().strip()
	a=list(map(int,input().split()))
	ans=1
	# pre=0
	# c=0
	# for i in range(1,n):
	# 	if a[i]<pre:
	# 		if c>1:
	# 			c-=1
	# 		else:
	# 			ans+=1
	# 			c=0
	# 	else:
	# 		c+=1
	# 	pre=a[i]
	# print(ans)

	c={0:1,1:0}
	k=0
	pre=1
	for i in range(1,n):
		if a[i]>pre:
			pre=a[i]
			k+=1
		else:
			if c[ans-1]<=1:
				if ans in c:c[ans]+=k
				else:c[ans]=k
				ans+=1
				pre=a[i]
				k=1
			else:
				c[ans-1]-=1
				if ans in c:c[ans]+=k
				else:c[ans]=k
				k=1
				pre=a[i]
	print(ans)


import sys
input=sys.stdin.readline
for _ in range(int(input())):
	n=int(input())
	# l,r=map(int,input().split())
	# s=input().strip()
	a=list(map(int,input().split()))
	ans=1
	# pre=0
	# c=0
	# for i in range(1,n):
	# 	if a[i]<pre:
	# 		if c>1:
	# 			c-=1
	# 		else:
	# 			ans+=1
	# 			c=0
	# 	else:
	# 		c+=1
	# 	pre=a[i]
	# print(ans)

	c={0:1,1:0}
	k=0
	pre=1
	for i in range(1,n):
		if a[i]>pre:
			pre=a[i]
			k+=1
		else:
			if c[ans-1]<=1:
				if ans in c:c[ans]+=k
				else:c[ans]=k
				ans+=1
				pre=a[i]
				k=1
			else:
				c[ans-1]-=1
				if ans in c:c[ans]+=k
				else:c[ans]=k
				k=1
				pre=a[i]
		print(c,k)
	print(ans)


import sys
input=sys.stdin.readline
for _ in range(int(input())):
	n=int(input())
	# l,r=map(int,input().split())
	# s=input().strip()
	a=list(map(int,input().split()))
	ans=1
	pre=0
	c=0
	for i in range(1,n):
		if a[i]<pre:
			if c>1:
				c-=1
			else:
				ans+=1
				c=0
		else:
			c+=1
		pre=a[i]
	print(ans)


import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = 10**9
mod = int(1e9)+7

for t in range(int(data())):
    n=int(data())
    a=mdata()+[0]
    s1=1
    s2=0
    ans=0
    for i in range(1,n):
        s2+=1
        if a[i]>a[i+1]:
            s1-=1
            if s1==0:
                ans+=1
                s1,s2=s2,0
    out(ans)


import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = 10**9
mod = int(1e9)+7

for t in range(int(data())):
    n=int(data())
    a=mdata()+[0]
    s1=0
    s2=1
    ans=0
    for i in range(1,n):
        if s1 == 0:
            ans += 1
            s1, s2 = s2, 0
        s2+=1
        if a[i]>a[i+1]:
            s1-=1
    out(ans)


t=int(input())
for _ in range(t):
    n=int(input())
    a=[int(x) for x in input().split()]

    increasingGpSizes=[1] #1st item is 1
    a.append(-1) #for the last item to be added
    prev=-1
    sz=0
    for i in range(1,n+1):
        if a[i]>=prev:
            sz+=1
        else:
            increasingGpSizes.append(sz)
            sz=1
        prev=a[i]

    curTotalSz=1
    ht=0
    curAccumSz=0
    curAccumCnt=0
    for x in increasingGpSizes[1:]:
        curAccumCnt+=1
        curAccumSz+=x
        if curAccumCnt==curTotalSz: #have to move to next depth
            ht+=1
            curTotalSz=curAccumSz
            curAccumCnt=0
    if curAccumCnt>0: #last layer did not end so ht wasn't incremented
        ht+=1

#    print('ans')
#    print(a)
#    print(increasingGpSizes)
    print(ht)


t=int(input())
for _ in range(t):
    n=int(input())
    a=[int(x) for x in input().split()]

    increasingGpSizes=[1] #1st item is 1
    a.append(-1) #for the last item to be added
    prev=-1
    sz=0
    for i in range(1,n+1):
        if a[i]>=prev:
            sz+=1
        else:
            increasingGpSizes.append(sz)
            sz=1
        prev=a[i]

    depths=[] #store [sizes]
    curr=[]
    for x in increasingGpSizes:
        if len(depths)==0:
            depths.append([1])
            curr=[]
        else:
            curr.append(x)
            if len(curr)==sum(depths[-1]):
                depths.append(curr)
                curr=[]
    if len(curr)>0:
        depths.append(curr)
#    print('ans')
#    print(depths)
    print(len(depths)-1)


t=int(input())
for _ in range(t):
    n=int(input())
    a=[int(x) for x in input().split()]

    increasingGpSizes=[1] #1st item is 1
    a.append(-1) #for the last item to be added
    prev=-1
    sz=0
    for i in range(1,n+1):
        if a[i]>=prev:
            sz+=1
        else:
            increasingGpSizes.append(sz)
            sz=1
        prev=a[i]

    curTotalSz=1
    ht=0
    curAccumSz=0
    curAccumCnt=0
    for x in increasingGpSizes[1:]:
        curAccumCnt+=1
        curAccumSz+=x
        if curAccumCnt==curTotalSz: #have to move to next depth
            ht+=1
            curTotalSz=curAccumSz
            curAccumSz=0
            curAccumCnt=0
    if curAccumCnt>0: #last layer did not end so ht wasn't incremented
        ht+=1

#    print('ans')
#    print(a)
#    print(increasingGpSizes)
    print(ht)


from sys import stdout
from sys import stdin
def get():
    return stdin.readline().strip()
def getf():
    return [int(i) for i in get().split()]
def put(a, end="\n"):
    stdout.write(str(a) + end)
def putf(*a, sep=" ", end="\n"):
    stdout.write(sep.join([str(i) for i in a]) + end)

from math import log2, ceil

for _ in range(int(get())):
    n = int(get())
    a = getf()
    ans = 1

    for i in range(1, n):
        if a[i-1] > a[i]:
            ans += 1

    print(ceil(log2(ans))+1)


from sys import stdout
from sys import stdin
def get():
    return stdin.readline().strip()
def getf():
    return [int(i) for i in get().split()]
def put(*a, sep=" ", end="\n"):
    stdout.write(sep.join([str(i) for i in a]) + end)

from math import log2, ceil

for _ in range(int(get())):
    n = int(get())
    a = getf()

    dcp = [1]
    cur = 0
    for i in range(1, n):
        if a[i-1] < a[i]:
            cur += 1
        else:
            dcp.append(cur)
            cur = 1
    dcp.append(cur)

    i = 0
    curvc = 1
    ans = 0
    while i < n:

        y = 0
        for j in range(i+1, min(len(dcp), i+curvc+1)):
            y += dcp[j]

        i += curvc
        curvc = y
        ans += 1

    put(ans-1)


from sys import stdout
from sys import stdin
def get():
    return stdin.readline().strip()
def getf():
    return [int(i) for i in get().split()]
def put(a, end="\n"):
    stdout.write(str(a) + end)
def putf(*a, sep=" ", end="\n"):
    stdout.write(sep.join([str(i) for i in a]) + end)

for _ in range(int(get())):
    n = int(get())
    a = getf()
    ans = 1

    for i in range(1, n):
        if a[i-1] > a[i]:
            ans += 1

    print(ans)


from sys import stdout
from sys import stdin
def get():
    return stdin.readline().strip()
def getf():
    return [int(i) for i in get().split()]
def put(a, end="\n"):
    stdout.write(str(a) + end)
def putf(*a, sep=" ", end="\n"):
    stdout.write(sep.join([str(i) for i in a]) + end)

from math import log2, ceil

for _ in range(int(get())):
    n = int(get())
    a = getf()
    prevvc = 1
    curvc = 0
    ans = 1

    for i in range(1, n):
        if a[i-1] > a[i]:
            curvc += 1

        if curvc == prevvc:
            ans += 1
            prevc = curvc
            curvc = 0

    if curvc > 0:
        ans += 1

    put(ans)


from collections import deque
from copy import deepcopy as dcopy
t= int(input())
for test in range(t):
    n = int(input())
    bfs = list(map(int,input().strip().split()))
    adjacent_arr = [[] for i in range(n+1)]
    previous = [bfs[0],0]
    root = [bfs[0],0]
    n = len(bfs)
    queue = deque()
    level = 0
    max_level = 0
    for i in range(1,n):
        if bfs[i] > previous[0]:
            adjacent_arr[root[0]].append(bfs[i])
            curr_previous = [bfs[i],root[1]+1]
            previous = dcopy(curr_previous)
            max_level = max(previous[1],max_level)
            queue.append(curr_previous)
        else:
            root = queue.popleft()
            adjacent_arr[root[0]].append(bfs[i])
            curr_previous = [bfs[i],root[1] +1]
            previous = dcopy(curr_previous)
            queue.append(curr_previous)
            max_level = max(previous[1],max_level)

    print(max_level)


import sys
sys.setrecursionlimit(10**6)
def maxHeight(curr,adjacent_arr):
    adjacent_nodes = adjacent_arr[curr]
    ans = 0
    for node in adjacent_nodes:
        curr_ans = 1 + maxHeight(node,adjacent_arr)
        ans = max(ans,curr_ans)
    return ans
t= int(input())
for _ in range(t):
    n = int(input())
    bfs = list(map(int,input().strip().split()))
    adjacent_arr = [[] for i in range(n+1)]
    curr = bfs[0]
    root = bfs[0]
    for i in range(1,len(bfs)):
        if bfs[i] > curr:
            adjacent_arr[root].append(bfs[i])
            curr = bfs[i]
        else:
            root = curr
            adjacent_arr[root].append(bfs[i])
            curr = bfs[i]
    print(maxHeight(bfs[0],adjacent_arr))


from collections import defaultdict as dd
import sys
input=sys.stdin.readline
t=int(input())
while t:
    n=int(input())
    #n,m=map(int,input().split())
    l=list(map(int,input().split()))
    level=1
    cou=1
    i=1
    prev=1
    while i<n-1:
        if(l[i]<l[i+1]):
            cou+=1
            i+=1
        else:
            prev-=1
            if(prev==0):
                prev=cou
                cou=1
                level+=1
            i+=1
    print(level)
    t-=1


from collections import defaultdict as dd
import sys
input=sys.stdin.readline
t=int(input())
while t:
    n=int(input())
    #n,m=map(int,input().split())
    l=list(map(int,input().split()))
    level=1
    cou=1
    i=1
    prev=1
    while i<n-1:
        if(l[i]<l[i+1]):
            cou+=1
            i+=1
        else:
            prev-=1

            if(prev==0):
                prev=cou
                cou=1
                level+=1
            else:
                cou+=1

            i+=1
        #print(cou,level)

    print(level)
    t-=1


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    c = 0
    w = 0
    ans = 1
    for i in range(0,n-1):
        if l[i]>l[i+1]:
            c-=1
            if c <= 0:
                ans+=1
                c = w
                w = 0
        else:
            w+=1
    print(ans)


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    c = 1
    w = 0
    ans = 1
    for i in range(0,n-1):
        if l[i]>l[i+1]:
            c-=1
            if c == 0:
                ans+=1
                c = w
                w = 0
        else:
            w+=1
    print(ans)


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    c = 1
    for i in range(n-1):
        if l[i]>l[i+1]:
            c+=1
    print(c)


for _ in range(int(input())):
    n = int(input())
    l = list(map(int,input().split()))
    c = 1
    w = 0
    ans = 1
    for i in range(1,n):
        if l[i]<l[i-1]:
            c-=1
            if c == 0:
                c = w
                w = 1
                ans+=1
            else:
                w+=1
        else:
            w+=1
    print(ans)


t = int(input())
for case in range(t):
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    c = 1
    for i in range(1, n):
        if a[i] < a[i - 1]:
            c += 1
    print(c)


t = int(input())
for case in range(t):
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    h = 1
    c = 0
    for i in range(1, n):
        if a[i] > a[i - 1]:
            c += 1
        else:
            c -= 1
            if c <= 0:
                h += 1
    print(h)


t = int(input())
for case in range(t):
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    r = [a[0]]
    m = len(r) - 1
    for v in a[1:]:
        if v > r[-1] and len(r) != 1:
            r = r[:-1] + [v]
        else:
            r = r + [v]
        m = max(len(r) - 1, m)
    print(m)


t = int(input())
for case in range(t):
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    h = 1
    r = [1]
    u = 0
    d = 0
    for i in range(1, n):
        if a[i] > a[i - 1] or u + d == 0:
            u += 1
        else:
            d += 1
            if d >= r[-1]:
                r.append(u + d - 1)
                d = 1
                u = 0
    if u + d > 0:
        r.append(u + d)
    print(len(r) - 1)


t = int(input())
for case in range(t):
    n = int(input())
    a = [int(x) for x in input().split(' ')]
    h = 1
    r = [1]
    u = 0
    d = 0
    for i in range(1, n):
        if a[i] > a[i - 1] or u + d == 0:
            u += 1
        else:
            d += 1
            if d >= r[-1]:
                r.append(u + d - 1)
                d = 0
                u = 1
    if u + d > 0:
        r.append(u + d)
    print(len(r) - 1)


t=int(input())
for you in range(t):
    n=int(input())
    l=input().split()
    li=[int(i) for i in l]
    prev=1
    curr=0
    ans=0
    ok=0
    for i in range(1,n):
        if(li[i]>li[i-1]):
            ok+=1
            continue
        curr+=1
        if(prev==curr):
            prev=ok
            ok=1
            curr=0
            ans+=1
    print(ans+1)


t=int(input())
for you in range(t):
    n=int(input())
    l=input().split()
    li=[int(i) for i in l]
    prev=1
    curr=0
    ans=0
    ok=0
    for i in range(1,n):
        if(li[i]>li[i-1]):
            ok+=1
            continue
        curr+=1
        if(prev==curr):
            prev=ok
            ok=1
            curr=0
            ans+=1
        else:
            ok+=1
    print(ans+1)


# 1 2 3 4 5 9 8 7 6
for _ in range(int(input())):
    num_children = int(input())
    children = list(map(int, input().split()))
    branches = 1
    next_branches = 1
    layer = 1
    previous = children[1]
    for child in children[2:]:
        if child < previous:
            branches -= 1
            if branches == 0:
                layer += 1
                branches = next_branches
                next_branches = 0
        next_branches += 1
        previous = child
    print(layer)


# 1 2 3 4 5 9 8 7 6
for _ in range(int(input())):
    num_children = int(input())
    children = list(map(int, input().split()))
    branches = 1
    next_branches = 1
    layer = 1
    previous = children[1]
    for child in children[2:]:
        if child < previous:
            branches -= 1
            if branches == 0:
                layer += 1
                branches = next_branches
        next_branches += 1
        previous = child
    print(layer)


import sys, os
import heapq, functools, collections, bisect
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

def solve_(lst):
    lst = lst[1:] + [10**6]
    # everytime we decrease, we break, and see how many rows do we need

    segments = []
    cur = [lst[0]]
    for a,b in zip(lst, lst[1:]):
        if a > b:
            segments.append(cur)
            cur = []
        cur.append(b)
    cur.pop()
    segments.append(cur)

    segments = segments[::-1]
    console(segments)

    breadth = 1
    depth = 0
    while segments:
        depth += 1
        currow = 0
        for i in range(breadth):
            if not segments:
                break
            currow += len(segments.pop())
        console(currow)
        breadth = currow

    # console(segments)

    return depth

def console(*args):
    # print on terminal in different color
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    pass

# if Codeforces environment
if os.path.exists('input.txt'):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

    def console(*args):
        pass

def solve(*args):
    # screen input
    console("----- solving ------")
    console(*args)
    console("----- ------- ------")
    return solve_(*args)

if True:
    # if memory is not a constraint
    inp = iter(sys.stdin.buffer.readlines())
    input = lambda: next(inp)
else:
    # if memory is a constraint
    input = sys.stdin.buffer.readline

for case_num in range(int(input())):
    # read line as a string
    # strr = input()

    # read line as an integer
    k = int(input())

    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(lst)  # please change

    # post processing methods
    # res = [str(x) for x in res]
    # res = " ".join(res)

    # print result
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


import sys, os
import heapq, functools, collections, bisect
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy

def lds(arr):
    n = len(arr)

    lds = [0] * n
    max = 0

    # Initialize LDS with 1 for all index
    # The minimum LDS starting with any
    # element is always 1
    for i in range(n):
        lds[i] = 1

    # Compute LDS from every index
    # in bottom up manner
    for i in range(1, n):
        for j in range(i):
            if (arr[i] < arr[j] and
                lds[i] < lds[j] + 1):
                lds[i] = lds[j] + 1

    # Select the maximum
    # of all the LDS values
    for i in range(n):
        if (max < lds[i]):
            max = lds[i]

    # returns the length of the LDS
    return max

def solve_(lst):
    # your solution here

    # arr = [1]
    # d = defaultdict(list)

    # for a in lst:

    return lds(lst)

def console(*args):
    # print on terminal in different color
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    pass

# if Codeforces environment
if os.path.exists('input.txt'):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

    def console(*args):
        pass

def solve(*args):
    # screen input
    console("----- solving ------")
    console(*args)
    console("----- ------- ------")
    return solve_(*args)

if True:
    # if memory is not a constraint
    inp = iter(sys.stdin.buffer.readlines())
    input = lambda: next(inp)
else:
    # if memory is a constraint
    input = sys.stdin.buffer.readline

for case_num in range(int(input())):
    # read line as a string
    # strr = input()

    # read line as an integer
    k = int(input())

    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    # grid = []
    # for _ in range(nrows):
    #     grid.append(list(map(int,input().split())))

    res = solve(lst)  # please change

    # post processing methods
    # res = [str(x) for x in res]
    # res = " ".join(res)

    # print result
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)


for _ in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    ans=1
    parent=1
    curr=a[1]
    np=1
    for i in range(2,n):
        if a[i]>curr:
            curr=a[i]
            np+=1
        else:
            parent-=1
            if parent==0:
                ans+=1
                parent=np
                np=0

            else:
                curr=a[i]
                np+=1
    print(ans)


for _ in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    parent=1
    level=1
    child=1
    curr=a[1]
    for i in range(2,n):
        if a[i]>curr:
            child+=1
            curr=a[i]

        else:
            #a[i]>=curr
            parent-=1
            if parent>0:
                child+=1
                curr=a[i]
            else:
                level+=1
                parent=child
                child=1
                curr=a[i]
    print(level)


for _ in range(int(input())):
    n=int(input())
    a=list(map(int, input().split()))
    ans=1
    curr=a[1]
    for i in range(2,n):
        if a[i]>curr:
            curr=a[i]
        else:
            ans+=1
            curr=a[i]
    print(ans)


T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    cnt_old = 1
    cnt = 1
    for a1, a2 in zip(A[1:], A[2:]):
        if a1 < a2:
            cnt_old += 1
        else:
            cnt -= 1
            if cnt == 0:
                ans += 1
                cnt = cnt_old
    print(ans)


T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    ans = 1
    for a1, a2 in zip(A, A[1:]):
        if a1 > a2:
            ans += 1
    print(ans)


from sys import stdin

input = stdin.readline

def solve():
    n = int(input())
    a = list(map(int,input().split()))
    if n == 1:
        print(0)
        return
    lvl = 0
    pre = 1
    cur = 0
    i = 1
    while i < n:
        j = i
        while cur < pre:
            while j < n - 1 and a[j] < a[j + 1]:
                j += 1
            cur += 1
        pre = j - i + 1
        cur = 0
        i = j + 1
        lvl += 1
    print(lvl)

if __name__ == '__main__':
    t = int(input())
    for _ in range(t):
        solve()


from sys import stdin

input = stdin.readline

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    if n == 1:
        print(0)
        return
    lvl = 0
    pre = 1
    cur = 0
    i = 1
    while i < n:
        j = i
        # print(lvl, pre, cur)
        while cur < pre:
            j += 1
            while j < n and a[j-1] < a[j]:
                j += 1
            cur += 1
        pre = j - i
        cur = 0
        i = j
        lvl += 1
    print(lvl)

if __name__ == '__main__':
    t = int(input())
    for _ in range(t):
        solve()


from collections import defaultdict
class Graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addedge(self,u,v):
		self.graph[u].append(v)

g = Graph()
for _ in range(int(input())):
	n = int(input())
	a= list(map(int,input().split()))
	x=[]
	k=[]
	x.append(a.pop(0))
	ans=0
	if n==2 :
		print(1)
	else:
		for i in range(1,n-1):
			if i==n-2 and a[i-1]<a[i] :
				g.addedge(x[0],a[i-1])
				x.append(a[i-1])
				g.addedge(x[0],a[i])
				x.append(a[i])
				ans+=1

			elif a[i-1]<a[i] :
				g.addedge(x[0],a[i-1])
				x.append(a[i-1])
			elif i==n-2 :
				g.addedge(x[0],a[i-1])
				x.append(a[i-1])
				x.pop(0)
				g.addedge(x[0],a[i])
				x.append(a[i])
				x.pop(0)
				ans+=2

			else:
				if x[0]==1 :
					ans+=1
					k.append(a[i-1])
				elif x[0]==k[0]:
					k.append(a[i-1])
					k.pop(0)
					ans+=1
				g.addedge(x[0],a[i-1])
				x.append(a[i-1])
				x.pop(0)

		print(ans)


for _ in range(int(input())):
	n = int(input())
	a=list(map(int,input().split()))
	ans=1
	p=0
	levelCompleted=0
	for i in range(1,n):
		if a[i-1]<a[i] :
			p+=1
		else:
			if levelCompleted ==0 :
				ans+=1
				levelCompleted = p-1
			else:
				levelCompleted=levelCompleted-1
	print(ans)


import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	ans = 1
	count = 0
	count2 = 0
	for i in range(2,n):
		if a[i]>a[i-1]:
			count2+=1
		else:
			if count == 0:
				ans+=1
				count = count2
				count2 = 1
			else:
				count-=1
	print(ans)

#1 5 6 4 3 2


import sys
import math
def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	ans = 0
	for i in range(1,n):
		if a[i]<a[i-1]:
			ans+=1
	print(ans+1)


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    unsigned long long totalsum = 0;
    cin >> n >> m;
    for(int i = 0;i  <n; i++)
    {
        int t,T,tax,costbus;
        unsigned long long sum = 0;
        cin >> t >> T >> tax >> costbus;
        int maxchild = T-t;
       // cout << maxchild << " *\n";
        if(maxchild >= m)
        {
            totalsum += costbus;
            //cout << costbus << "   ((\n";
            continue;
        }
        sum = tax * m + costbus;
        //cout << sum << "  s"  << endl;
        for(int j = 1;j <= m;j++)
        {
            int k = m - maxchild*j ;
            if (k < 0 || k <= maxchild)
            k = 0;
            //cout << k << "  k\n";

            int p = (costbus*(j+1))+(tax*k);
           // cout<< k << " " << j << " " << p << endl;
               // cout << j << " "<< p << endl;
            if(p > sum)
                break;
            else
                sum = p;
        }
        //cout << sum << endl;
        totalsum += sum;

    }
    cout << totalsum;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int   main()
{
    long long n,m;
     long long sum = 0;
    cin >> n >> m;
    while(n--)
    {
        long long  t,T,tax,cost;
        cin >> t >> T >> tax >> cost;

        long long  maxst = T-t;
        if(t+m <= T)
        {
//        cout << 1 << " " << cost <<endl;
        sum += cost;
        }
        else if(maxst <= 0)
        {
//             cout << 2 << " " << tax*m + cost << endl;
            sum += tax*m + cost;

        }
        else
        {
             long long car = m/maxst;
             if(m%maxst) car++;
             long long miin = tax*m +cost;
             if(minn > car*cost)
                minn = car*cost;
             sum += miin;
        }
    }
    cout << sum;
    int k;cin >> k;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    unsigned long long  totalsum = 0;
    cin >> n >> m;
    for(int i = 0;i  <n; i++)
    {
        int t,T,tax,costbus;
        unsigned long long sum = 0;
        cin >> t >> T >> tax >> costbus;
        int maxchild = T-t;
       // cout << maxchild << " *\n";
        if(maxchild >= m)
        {
            totalsum += costbus;
            //cout << costbus << "   ((\n";
            continue;
        }
        else if(maxchild <= 0)
        {
            totalsum += tax * m + costbus;
        }
        sum = tax * m + costbus;
        //cout << sum << "  s"  << endl;
        for(int j = 1;j <= m;j++)
        {
            int k = m - maxchild*j ;
            if (k < 0 || k <= maxchild)
            k = 0;
            //cout << k << "  k\n";

            unsigned long long p = (costbus*(j+1))+(tax*k);
           // cout<< k << " " << j << " " << p << endl;
               // cout << j << " "<< p << endl;
            if(p < sum)
                sum = p;
        }
        //cout << sum << endl;
        totalsum += sum;

    }
    cout << totalsum;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    unsigned long long totalsum = 0;
    cin >> n >> m;
    for(int i = 0;i  <n; i++)
    {
        int t,T,tax,costbus;
        unsigned long long sum = 0;
        cin >> t >> T >> tax >> costbus;
        int maxchild = T-t;
       // cout << maxchild << " *\n";
        if(maxchild >= m)
        {
            totalsum += costbus;
            //cout << costbus << "   ((\n";
            continue;
        }
        sum = tax * m + costbus;
        //cout << sum << "  s"  << endl;
        for(int j = 1;j <= m;j++)
        {
            unsigned long long k = m - maxchild*j ;
            if (k < 0 || k <= maxchild)
            k = 0;
            //cout << k << "  k\n";

            unsigned long long p = (costbus*(j+1))+(tax*k);
           // cout<< k << " " << j << " " << p << endl;
               // cout << j << " "<< p << endl;
            if(p > sum)
                break;
            else
                sum = p;
        }
        //cout << sum << endl;
        totalsum += sum;

    }
    cout << totalsum;

    return 0;
}


#include <bits/stdc++.h>

using namespace std;

int   main()
{
    int n,m;
    unsigned long long sum = 0;
    cin >> n >> m;
    while(n--)
    {
        long long  t,T,tax,cost;
        cin >> t >> T >> tax >> cost;

        if(t+m <= T)
        sum += cost;
        else
        {
            unsigned long long  maxsum = tax*m + cost;
            unsigned long long  maxst = T-t;
            for(unsigned long long  i = 2; (i-1)*maxst <= m+maxst; i++)
            {
                 long long  posi = m - maxst*(i-1);
                if(posi <= maxst)
                    posi = 0;
                unsigned long long  a = i*cost + tax*(posi);

                if(a > maxsum)
                    break;
                maxsum = a;
            }
            //cout << maxsum;
            sum += maxsum;
        }
    }
    cout << sum;
    return 0;
}


        #include <bits/stdc++.h>

        using namespace std;

        int main()
        {
            int n,m;
            unsigned long long  totalsum = 0;
            cin >> n >> m;
            for(int i = 0;i  <n; i++)
            {
                int t,T,tax,costbus;
                unsigned long long sum = 0;
                cin >> t >> T >> tax >> costbus;
                 long long maxchild = T-t;
               // cout << maxchild << " *\n";
                if(maxchild >= m)
                {
                    totalsum += costbus;
                    //cout << costbus << "   ((\n";
                    continue;
                }
                else if(maxchild <= 0)
                {
                    totalsum += tax * m + costbus;
                    continue;
                }
                sum = tax * m + costbus;
                //cout << sum << "  s"  << endl;
                for(unsigned long long j = 1;j*maxchild <= m+maxchild;j++)
                {
                    unsigned long long k = m - maxchild*j ;
                    if (k < 0 || k <= maxchild)
                    k = 0;
                    //cout << k << "  k\n";

                    unsigned long long p = (costbus*(j+1))+(tax*k);
                   // cout<< k << " " << j << " " << p << endl;
                       // cout << j << " "<< p << endl;
                    if(p < sum)
                        sum = p;
                }
                //cout << sum << endl;
                totalsum += sum;

            }
            cout << totalsum;

            return 0;
        }


#include <bits/stdc++.h>

using namespace std;

int   main()
{
    long long n,m;
     long long sum = 0;
    cin >> n >> m;
    while(n--)
    {
        long long  t,T,tax,cost;
        cin >> t >> T >> tax >> cost;

        long long  maxst = T-t;
        if(t+m <= T)
        {
//        cout << 1 << " " << cost <<endl;
        sum += cost;
        }
        else if(maxst <= 0)
        {
//             cout << 2 << " " << tax*m + cost << endl;
            sum += tax*m + cost;

        }
        else
        {
             long long  maxsum = tax*m + cost;

            if(tax*(maxst) < cost)
            {
                sum += maxsum;
//                cout << 11 << " " << maxsum << endl;
            }
            else
            {
                if(m%maxst == 0)
                {
//                    cout << 110 << " " << (m/maxst) * cost << endl;
                    sum += (m/maxst) * cost;
                }
                else
                {
                    if(tax*(m%maxst) >= cost )
                    {
//                        cout << 12 << " " << ((m/maxst)+1) * cost << endl;
                    sum += ((m/maxst)+1) * cost;
                    }
                    else
                    {
                       // cout << 13 << " " << (m/maxst) * cost + tax*(m%maxst) << endl;
                        sum += (m/maxst) * cost + tax*(m%maxst);

                    }
                }
            }
        }
    }
    cout << sum;
    int k;cin >> k;
    return 0;
}


        #include <bits/stdc++.h>

        using namespace std;

        int main()
        {
            int n,m;
            unsigned long long  totalsum = 0;
            cin >> n >> m;
            for(int i = 0;i  <n; i++)
            {
                int t,T,tax,costbus;
                unsigned long long sum = 0;
                cin >> t >> T >> tax >> costbus;
                unsigned long long maxchild = T-t;
               // cout << maxchild << " *\n";
                if(maxchild >= m)
                {
                    totalsum += costbus;
                    //cout << costbus << "   ((\n";
                    continue;
                }
                else if(maxchild <= 0)
                {
                    totalsum += tax * m + costbus;
                    continue;
                }
                sum = tax * m + costbus;
                //cout << sum << "  s"  << endl;
                for(unsigned long long j = 1;j*maxchild <= m+maxchild;j++)
                {
                    unsigned long long k = m - maxchild*j ;
                    if (k < 0 || k <= maxchild)
                    k = 0;
                    //cout << k << "  k\n";

                    unsigned long long p = (costbus*(j+1))+(tax*k);
                   // cout<< k << " " << j << " " << p << endl;
                       // cout << j << " "<< p << endl;
                    if(p < sum)
                        sum = p;
                }
                //cout << sum << endl;
                totalsum += sum;

            }
            cout << totalsum;

            return 0;
        }