human
Can you solve the below in PYTHON3?
You are given n integers a_1, a_2, …, a_n and an integer k. Find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤ n. Here, | is the [bitwise OR operator](https://en.wikipedia.org/wiki/Bitwise_operation#OR).

Input

The first line contains a single integer t (1 ≤ t ≤ 10 000) — the number of test cases.

The first line of each test case contains two integers n (2 ≤ n ≤ 10^5) and k (1 ≤ k ≤ min(n, 100)).

The second line of each test case contains n integers a_1, a_2, …, a_n (0 ≤ a_i ≤ n).

It is guaranteed that the sum of n over all test cases doesn't exceed 3 ⋅ 10^5.

Output

For each test case, print a single integer — the maximum possible value of i ⋅ j - k ⋅ (a_i | a_j).

Example

Input

4
3 3
1 1 3
2 2
1 2
4 3
0 1 2 3
6 6
3 2 0 0 5 6

Output

-1
-4
3
12

Note

Let f(i, j) = i ⋅ j - k ⋅ (a_i | a_j).

In the first test case, 

  * f(1, 2) = 1 ⋅ 2 - k ⋅ (a_1 | a_2) = 2 - 3 ⋅ (1 | 1) = -1. 
  * f(1, 3) = 1 ⋅ 3 - k ⋅ (a_1 | a_3) = 3 - 3 ⋅ (1 | 3) = -6. 
  * f(2, 3) = 2 ⋅ 3 - k ⋅ (a_2 | a_3) = 6 - 3 ⋅ (1 | 3) = -3. 


So the maximum is f(1, 2) = -1.

In the fourth test case, the maximum is f(3, 4) = 12.
assistant
#Here is Python code to find the maximum value of i ⋅ j - k ⋅ (a_i | a_j) over all pairs (i, j) of integers with 1 ≤ i < j ≤ n.

from collections import deque
import heapq
from math import sqrt
import operator
from operator import itemgetter
import sys

import copy

 
inf_var = 0
if inf_var == 1:
    inf = open('input.txt', 'r')
else:
    inf = sys.stdin
 
input = inf.readline
# sys.stdout = open('output.txt', 'w')
 
def read_one_int():
    return int(input().rstrip('\n'))

def read_one_float():
    return float(input().rstrip('\n'))
 
 
def read_list_of_ints():
    res = [int(val) for val in (input().rstrip('\n')).split(' ')]
    return res
 
def read_str():
    return input().rstrip()

def to_left_diag(i, j):
    return i + j

def to_right_diag(i, j):
    return i - j

class Vertex:
    def __init__(self):
        self.next = {}
        self.terminal = False
        self.cnt = 1

def add_str(trie, cur_str):
    vertices_cnt = 0
    cur_node = trie
    for ch in cur_str:
        if ch in cur_node.next:
            cur_node = cur_node.next[ch]
            cur_node.cnt += 1
        else:
            cur_node.next[ch] = Vertex()
            vertices_cnt += 1
            cur_node = cur_node.next[ch]

    cur_node.terminal = True
    return vertices_cnt

def main():
    tests = read_one_int()

    inf = 10 ** 8

    for _ in range(tests):
        n, k = read_list_of_ints()
        elements = read_list_of_ints()

        st = 0
        if n > 1000:
            st = n - 1000

        cur_res = -inf

        for i in range(st, n - 1):
            for j in range(i + 1, n):
                cur_res = max(cur_res, (i + 1) * (j + 1) - k * (elements[i] | elements[j]))

        print(cur_res)

if __name__== '__main__':
    main()