Snackdown 2019 is coming! There are two rounds (round A and round B) after the qualification round. From both of them, teams can qualify to the pre-elimination round. According to the rules, in each of these two rounds, teams are sorted in descending order by their score and each team with a score greater or equal to the score of the team at the $K=1500$-th place advances to the pre-elimination round (this means it is possible to have more than $K$ qualified teams from each round in the case of one or more ties after the $K$-th place).
Today, the organizers ask you to count the number of teams which would qualify for the pre-elimination round from round A for a given value of $K$ (possibly different from $1500$). They provided the scores of all teams to you; you should ensure that all teams scoring at least as many points as the $K$-th team qualify.

-----Input-----
- The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
- The first line of each test case contains two space-separated integers $N$ and $K$.
- The second line contains $N$ space-separated integers $S_1, S_2, \dots, S_N$.

-----Output-----
For each test case, print a single line containing one integer — the number of qualified teams.

-----Constraints-----
- $1 \le T \le 1,000$
- $1 \le K \le N \le 10^5$
- $1 \le S_i \le 10^9$ for each valid $i$
- the sum of $N$ for all test cases does not exceed $10^6$

-----Example Input-----
2
5 1
3 5 2 4 5
6 4
6 5 4 3 2 1

-----Example Output-----
2
4

Starter code:

Solutions:
# cook your dish here
#t = int(input())
for i in range(int(input())):
 n,k = map(int,input().split())
 l = list(map(int,input().split()))
 l.sort(reverse = True)
 c = 0
 for i in l:
  if i >= l[k-1]:
   c += 1
 print(c)

# cook your dish here
t = int(input())
for i in range(t):
 n,k = map(int,input().split())
 l = list(map(int,input().split()))
 l.sort(reverse = True)
 c = 0
 for i in l:
  if i >= l[k-1]:
   c += 1
 print(c)

for t in range(int(input())):
 n,k = list(map(int,input().split()))
 l = list(map(int,input().split()))
 c = 0
 l.sort(reverse = True)
 for i in range(n):
  if l[i] >= l[k-1]:
   c += 1
 print(c)


# cook your dish here
t = int(input())
for j in range(t):
 n,k = list(map(int,input().split()))
 l = list(map(int,input().split()))
 c = 0
 l.sort(reverse = True)
 for i in range(n):
  if l[i] >= l[k-1]:
   c += 1
 print(c)


for _ in range(int(input())):
 n, k = map(int, input().split())
 s=[int(x) for x in input().split()]
 s.sort(reverse=True)
 count=0
 req=s[k-1]
 for x in s:
  if x >=req:
   count+=1
  else:
   break
 print(count)

# cook your dish here
t = int(input())
for _ in range(t):
 n,k = map(int,input().split())
 l = list(map(int,input().split()))
 c = 0
 l.sort(reverse = True)
 for i in range(n):
  if l[i] >= l[k-1]:
   c += 1
 print(c)

# cook your dish here
test_cases = int(input())

for i in range(test_cases):
 N, K = map(int, input().split())
 
 scores = list(map(int, input().split()))
 scores = sorted(scores)[::-1]
 print(len([i for i in scores if i >= scores[K-1] ]))

for _ in range(int(input())):
 n,k = map(int,input().split())
 l = list(map(int,input().split()))
 l.sort(reverse = True)
 ans = 0
 x = l[k-1]
 for i in range(n):
  if x>l[i]:
   break
  ans+=1
 print(ans) 

for _ in range(int(input())):
 n,k = [int(x) for x in input().split()]
 lst = [int(x) for x in input().split()]
 lst.sort(reverse=True)
 el = lst[k-1]
 count = 0
 for i in lst:
  if i<el:
   break
  else:
   count = count + 1
 print(count)


t=int(input())
while t>0:
  t-=1
  n,p=map(int,input().split())
  l=list(map(int,input().split()))
  l.sort()
  l.reverse()
  count=0
  k=l[p-1]
  for i in range(n):
   if l[i]<k:
    break
   else:
    count+=1
  print(count)

for _ in range(int(input())):
 # n = int(input())
 n,k = list(map(int,input().split()))
 s = sorted(map(int,input().split()),reverse=True)
 while k<n and s[k-1] == s[k] :
  k += 1
 print(k)


for _ in range(int(input())):
 # n = int(input())
 n,k = list(map(int,input().split()))
 s = sorted(map(int,input().split()),reverse=True)
 while k<n and s[k-1] == s[k] :
  k += 1
 print(k)


# cook your dish here
import math
def solve():
 #n=int(input())
 
 #n,m,k,l,r=map(int,input().split())
 #l=list(map(int,input().split()))
 #l1=list(map(int,input().split()))
 n,k = list(map(int,input().split()))
 s = sorted(map(int,input().split()),reverse=True)
 while k<n and s[k-1] == s[k] :
  k += 1
 print(k)

t=int(input())
#t=1
#res=[]
for i in range(t):
 solve()


# cook your dish here
import sys
input=sys.stdin.readline
t=int(input())
for you in range(t):
 l=input().split()
 n=int(l[0])
 k=int(l[1])
 l=input().split()
 li=[int(i) for i in l]
 li.sort()
 li.reverse()
 z=li[k-1]
 count=0
 for i in li:
  if(i>=z):
   count+=1
 print(count)


for _ in range(int(input())):
 # n = int(input())
 n,k = list(map(int,input().split()))
 s = sorted(map(int,input().split()),reverse=True)
 while k<n and s[k-1] == s[k] :
  k += 1
 print(k)


for _ in range(int(input())):
 # n = int(input())
 n,k = list(map(int,input().split()))
 s = sorted(map(int,input().split()),reverse=True)
 while k<n and s[k-1] == s[k] :
  k += 1
 print(k)


try:
 t = int(input())
 result = []
 for i in range(t):
  count = 0
  li = list(map(int, input().split()))
  scores = list(map(int, input().split()))
  scores.sort(reverse=True)
  needed_score = scores[li[1] - 1]
  for u in scores:
   if (u >= needed_score):
    count = count + 1
   else:
    continue
  result.append(count)

 for v in result:
  print(v)



except:
 pass


t = int(input())
for i in range(t):
 n,k = map(int,input().split())
 l = list(map(int,input().split()))
 l.sort(reverse = True)
 a = l[k-1]
 j = 0
 count = 0
 while j<len(l):
  if l[j]>=a:
   count += 1
  else:
   break
  j += 1
 print(count)

# cook your dish here
for t in range(int(input())):
 n,k=map(int,input().split())
 a=[int(i) for i in input().split()]
 a.sort()
 a=a[::-1]
 count=k
 while k<n and a[k-1]==a[k]:
  count+=1
  k+=1
 print(count)

# cook your dish here
a = int(input())
for i in range(a):
 b = str(input()).split(' ')
 c = list(map(int,str(input()).split(' ')))
 Ans = int(b[1])
 c.sort(reverse=True)
 Ans+=c[int(b[1]):int(b[0])].count(c[int(b[1])-1])
 print(Ans)


for T in range(int(input())):
 N,K = map(int,input().split())
 S = sorted(list(map(int,input().split())))[::-1]
 print(sum([1 for i in S if i >= S[K-1]]))

for _ in range(int(input())):
 a = input().split()
 n = int(a[0])
 k = int(a[1])
 s = sorted(map(int, input().split()), reverse = True)
 i = k
 while i<n and s[i]==s[k-1]:
  i+=1
 print(i)

# cook your dish here
testcases = int(input())
for t in range(testcases) :
 n,k = map(int,input().split())
 S = list(map(int,input().split()))
 S.sort(reverse=True)
 count = k
 current = S[k-1]
 i=k
 while i<n and S[i]==S[k-1] :
  i+=1
  count+=1
 print(count)

for _ in range(int(input())):
 N, K = map(int, input().split())
 L = sorted(map(int, input().split()), reverse=True)
 cut = L[K-1]
 c = K
 for i in range(K, N):
  if L[i] == cut:
   c += 1 
  else:
   break
 print(c)

for i in range(int(input())):
 n,k = map(int, input().split())
 Q = list(map(int, input().split()))

 Q.sort(reverse=True)

 score = Q[k-1]
 result = 0
 for i in Q:
  if i>=score:
   result = result+1
 print(result)