Sum of Two Numbers

No attempts yetTime limit1sMemory limit128 MB

Problem

You are given a set of distinct integers S={a1,a2,,an}S = \{a_1, a_2, \ldots, a_n\} and another integer KK. Consider picking two distinct integers from SS and adding them; among all such pairs, look at the ones whose sum is closest to KK, meaning the absolute difference between the sum and KK is as small as possible.

For example, given the 1010 integers

S={7,9,2,4,12,1,5,3,2,0}S = \{-7, 9, 2, -4, 12, 1, 5, -3, -2, 0\}

the pair whose sum is closest to K=8K = 8 is {12,4}\{12, -4\} alone (their sum is exactly 88). For K=4K = 4, the smallest possible difference between a pair's sum and KK is 11, achieved by five pairs: {7,12},{9,4},{5,2},{5,0},{1,2}\{-7, 12\}, \{9, -4\}, \{5, -2\}, \{5, 0\}, \{1, 2\}.

Given the integers and KK, write a program that counts how many pairs of two distinct integers have a sum closest to KK.

Input

Input is given on standard input. The first line contains the number of test cases tt. Each test case then consists of two lines.

The first line of each test case contains two integers nn and KK separated by a space (2n1062 \le n \le 10^6, 108K108-10^8 \le K \le 10^8). The second line contains nn distinct integers separated by spaces, each between 108-10^8 and 10810^8 inclusive.

Output

For each test case, output the result on its own line, in the order the test cases are given. Each line contains the number of pairs of two distinct integers whose sum is closest to KK.