MOAGEZA is cooking#12283

MOAGEZA is cooking

3 seconds
256 megabytes
Hard

Shenawy is given an array of integers and a number .

He wants to find, for each subarray size (1 \le k \le n), how many subarrays of that size have a bitwise OR equal to .

A subarray is defined as a contiguous segment of the array.

Formally, for an array of length , a subarray is any sequence of the form a_l, a_{l+1}, \ldots, a_r where 1 \le l \le r \le n.

The size of a subarray is the number of elements it contains.

For example, if the array is [1, 2, 3], its subarrays of size are and .

The bitwise OR of a sequence of numbers is calculated by applying the OR operation to all its elements. For instance, the bitwise OR of is 1\,|\,2 = 3.

Since Shenawy is not confident with bitwise operations, he asked you to help him solve this problem efficiently for all subarray sizes.

Input

The first line contains a single integer (1 \le t \le 10^4) — the number of test cases.

The first line of each test case contains two integers (1 \le n \le 2 \cdot 10^5, 1 \le x \le 10^9) — the size of the array and the target value.

The second line contains integers a_1, a_2, \ldots, a_n (1 \le a_1, a_2, \ldots, a_n \le 10^9) — the elements of the array.

It is guaranteed that the sum of all over all test cases does not exceed 2 \cdot 10^5.

Output

Print integers — the -th integer should be the number of subarrays of size whose bitwise OR equals .

Examples

Example 1

Loading
Loading

Note

In the first test case, a = [1, 2, 3, 2, 1] and x = 3:

  • k = 1: Since we only have a single integer, we count occurrences of which is only one, , thus the answer is .

  • k = 2: The subarrays , , , all have bitwise OR of , thus the answer is .

  • k = 3: The subarrays [1, 2, 3], [2, 3, 2], [3, 2, 1] all have bitwise OR of , thus the answer is .

  • k = 4: The subarrays [1, 2, 3, 2] and [2, 3, 2, 1] both have bitwise OR of , thus the answer is .

  • k = 5: The whole array a = [1, 2, 3, 2, 1] has bitwise OR of , thus the answer is .

Scoring

  1. Subtask ( points): (1 \le \sum n \le 1000)

  2. Subtask ( points): (1 \le x, a_i \le 2^{10})

  3. Subtask ( points): (x = 2^k), i.e., is a power of .

  4. Subtask ( points): No additional constraints.