실버3 문제
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
arr = list(map(int, input().split()))
alist = []
for i in range(n):
alist.append([arr[i], i])
cnt = 0
while True:
imax = 0
for k in alist:
if ( k[0] > imax ):
imax = k[0]
if ( alist[0][0] == imax ):
cnt += 1
if (alist[0][1] == m):
print(cnt)
break
else:
alist.pop(0)
else:
alist.append(alist.pop(0))
t = int(input())
for _ in range(t):
n, m = map(int, input().split())
arr = list(map(int, input().split()))
soon = list(range(len(arr)))
cnt = 0
while True:
if ( arr[0] == max(arr) ):
cnt += 1
if ( soon[0] == m ):
print(cnt)
break
else:
arr.pop(0)
soon.pop(0)
else:
arr.append(arr.pop(0))
soon.append(soon.pop(0))