for _ in range(int(input())): (n,k) = map(int, input().split()) a = list(map(int, input().split())) a.sort() i = 0 j = n-1 res = -1 big = 0 vbig = 0 while j >= 0 and a[j] >= k: j -= 1 vbig += 1 while j > i: if a[i] + a[j] >= k: j -= 1 big += 1 continue res += 1 i += 1 j -= 1 if vbig > 0: vbig -= 1 elif big > 0: big -= 1 else: j -= 1 if j == i: big += 1 #print(":", res) res += big + max(0,vbig-big) print(res)