Distinct Number

아직 제출이 없습니다시간 제한1초메모리 제한512 MB

문제

Given nn intervals \[l_1,r_1],\[l_2,r_2],,\[l_n,r_n]\[l\_1,r\_1], \[l\_2,r\_2], \ldots, \[l\_n, r\_n] and an integer xx, you should find the size of the set S=yy=iANDx,,i\[l_1,r_1]\[l_2,r_2]\[l_n,r_n]S = \\{y \mid y = i \operatorname{AND} x, \\, i \in \[l\_1, r\_1] \cup \[l\_2, r\_2] \cup \ldots \cup \[l\_n, r\_n]\\}, where iANDxi\operatorname{AND} x is the bitwise and of integers ii and xx.

입력

There are multiple test cases. The first line of input contains an integer TT, indicating the number of test cases. For each test case:

The first line contains two integers nn and xx (1n51031 \le n \le 5 \cdot 10^3, 0x10180 \le x \le 10^{18}).

Each of the next nn lines contains two integers l_il\_i and r_ir\_i (0l_ir_i10180 \le l\_i \le r\_i \le 10^{18}).

It is guaranteed that the sum of nn over all test cases does not exceed 51035 \cdot 10^3.

출력

For each test case, output an integer denoting the size of the set SS.

힌트

For the first sample test case, we have S=0,1S = \\{0, 1\\}, so the answer is 22.

For the second sample test case, we have S=1,2,3S = \\{1, 2, 3\\}, so the answer is 33.