"It does not matter how slowly you go as long as you do not stop." - Confucius
You are given an array $A_1, A_2, \ldots, A_N$ and an integer $K$. For each subarray $S = [A_l, A_{l+1}, \ldots, A_r]$ ($1 \le l \le r \le N$):
- Let's define an array $B$ as $S$ concatenated with itself $m$ times, where $m$ is the smallest integer such that $m(r-l+1) \ge K$.
- Next, let's sort $B$ and define $X = B_K$, i.e. as a $K$-th smallest element of $B$. Note that $|B| \ge K$.
- Then, let's define $F$ as the number of occurrences of $X$ in $S$.
- The subarray $S$ is beautiful if $F$ occurs in $S$ at least once.
Find the number of beautiful subarrays of $A$. Two subarrays $A_l, A_{l+1}, \ldots, A_r$ and $A_p, A_{p+1}, \ldots, A_q$ are different if $l \neq p$ or $r \neq q$.

-----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 $A_1, A_2, \ldots, A_N$.

-----Output-----
For each test case, print a single line containing one integer - the number of beautiful subarrays.

-----Constraints-----
- $1 \le T \le 5$
- $1 \le N \le 2,000$
- $1 \le K \le 10^9$
- $1 \le A_i \le 2000$ for each valid $i$

-----Subtasks-----
Subtask #1 (20 points): $1 \le N \le 200$
Subtask #2 (80 points): original constraints

-----Example Input-----
1
3 3
1 2 3

-----Example Output-----
3

-----Explanation-----
Example case 1: There are six subarrays of $A$: $[1]$, $[2]$, $[3]$, $[1, 2]$, $[2, 3]$, $[1, 2, 3]$. The corresponding arrays $B$ are $[1, 1, 1]$, $[2, 2, 2]$, $[3, 3, 3]$, $[1, 2, 1, 2]$, $[2, 3, 2, 3]$, $[1, 2, 3]$.
Three of the subarrays are beautiful: $[1]$, $[1, 2]$ and $[1, 2, 3]$. For these subarrays, $X$ is $1$, $2$ and $3$ respectively (for example, for $S = [1, 2]$, $B = [1, 2, 1, 2]$ is sorted to $[1, 1, 2, 2]$ and $X = 2$ is the $3$-rd element). Then, $F = 1$ for each of these subarrays, and each of these subarrays contains $1$.

```python

USER_FILENAME = "<user_code>"
import sys, json, builtins
import math, heapq, bisect, itertools, functools, collections, statistics, fractions, decimal, operator, array, random, re, string, os, pathlib
try:
    import resource as _res
except Exception:
    _res = None
from collections import Counter, defaultdict, deque, OrderedDict
from functools import lru_cache, reduce
from itertools import accumulate, permutations, combinations, product
from math import gcd, ceil, floor, sqrt
from decimal import Decimal
try:
    from typing import *
except Exception:
    pass
try:
    sys.setrecursionlimit(1_000_000)
except Exception:
    pass
try:
    import site as _site
    try:
        _sys_sites = _site.getsitepackages() if hasattr(_site, "getsitepackages") else []
        for _p in _sys_sites:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
    try:
        _usp = _site.getusersitepackages()
        if isinstance(_usp, str):
            _usp = [_usp]
        for _p in _usp:
            if _p and _p not in sys.path:
                sys.path.append(_p)
    except Exception:
        pass
except Exception:
    pass

ns = {"__name__": "__main__"}
for _k, _v in list(globals().items()):
    if not _k.startswith("_"):
        ns[_k] = _v
_CODE = 'import math\nimport heapq\ndef counting_sort(array1, max_val):\n m = max_val + 1\n count = [0] * m\n for a in array1:\n  count[a] += 1\n i = 0\n for a in range(m):\n  for c in range(count[a]):\n   array1[i] = a\n   i += 1\n return array1\nfor _ in range(int(input())):\n n,k=list(map(int,input().split()))\n l=list(map(int,input().split()))\n M=[]\n ans=0\n for i in range(n):\n  for j in range(i,n):\n   m=math.ceil(k/(j-i+1))\n   gt=(k-1)//m\n   M.append(gt)\n  break\n for i in range(n):\n  max=-1\n  s=set()\n  d={}\n  hallo_frnd={}\n  for j in range(i,n):\n   x=None\n   value=M[j-i]\n   if l[j] not in d:\n    d[l[j]]=1\n   else:\n    d[l[j]]+=1\n   if l[j]>max:\n    max=l[j]\n   if value not in s:\n    ####\n    s.add(value)\n    x=max\n    hallo_frnd[value]=max\n   else:\n    if l[j]<hallo_frnd[value]:\n     yt=l[i:j+1]\n     heapq.heapify(yt)\n     x=heapq.nsmallest(value+1,yt)[-1]\n     hallo_frnd[value]=x\n    else:\n     x=hallo_frnd[value]\n   if d[x] in d:\n    ans+=1\n print(ans)\n'
_co = compile(_CODE, USER_FILENAME, "exec")
exec(_co, ns, ns)

```

Measured memory_bytes: 13883