#include <bits/stdc++.h>
using namespace std;
void swap(long long &x, long long &y) {
  long long temp = x;
  x = y;
  y = temp;
}
void google(long long t) { cout << "Case #" << t << ": "; }
long long mod_add(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a + b) % m) + m) % m;
}
long long mod_mul(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a * b) % m) + m) % m;
}
long long mod_sub(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a - b) % m) + m) % m;
}
long long expom(long long x, long long y, long long m) {
  if (y == 0) return 1;
  x = x % m;
  if (y % 2 == 0) return expom(x * x, y / 2, m) % m;
  return (x * expom(x * x, y / 2, m)) % m;
}
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long ceil(long long a, long long b) {
  return (a % b == 0) ? a / b : a / b + 1;
}
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
vector<long long> pri(200000 + 6);
void prime_factorization_sieve() {
  pri[1] = 1;
  for (long long i = 2; i <= 200000 + 5; i++) {
    pri[i] = -1;
  }
  for (long long i = 2; i <= 200000 + 5; i++) {
    if (pri[i] == -1) {
      for (long long j = i; j <= 200000 + 5; j += i) {
        if (pri[j] == -1) pri[j] = i;
      }
    }
  }
}
vector<long long> get_factors(long long n) {
  vector<long long> res;
  while (pri[n] != 1) {
    res.push_back(pri[n]);
    n = n / pri[n];
  }
  return res;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n + 1);
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  long long ans = INT_MIN;
  long long x = (n >= 300) ? n - 300 : n;
  if (n >= 300) {
    for (long long i = x + 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        if (i != j) {
          ans = ((ans) < (i * j - k * (arr[i] | arr[j]))
                     ? (i * j - k * (arr[i] | arr[j]))
                     : (ans));
        }
      }
    }
  } else {
    for (long long i = 1; i <= x; i++) {
      for (long long j = 1; j <= n; j++) {
        if (i != j) {
          ans = ((ans) < (i * j - k * (arr[i] | arr[j]))
                     ? (i * j - k * (arr[i] | arr[j]))
                     : (ans));
        }
      }
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

### Prompt

Please provide a Cpp coded solution to the problem described below:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
void swap(long long &x, long long &y) {
  long long temp = x;
  x = y;
  y = temp;
}
void google(long long t) { cout << "Case #" << t << ": "; }
long long mod_add(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a + b) % m) + m) % m;
}
long long mod_mul(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a * b) % m) + m) % m;
}
long long mod_sub(long long a, long long b, long long m) {
  a = a % m;
  b = b % m;
  return (((a - b) % m) + m) % m;
}
long long expom(long long x, long long y, long long m) {
  if (y == 0) return 1;
  x = x % m;
  if (y % 2 == 0) return expom(x * x, y / 2, m) % m;
  return (x * expom(x * x, y / 2, m)) % m;
}
inline long long gcd(long long a, long long b) {
  return b == 0 ? a : gcd(b, a % b);
}
inline long long lcm(long long a, long long b) { return a * b / gcd(a, b); }
inline long long ceil(long long a, long long b) {
  return (a % b == 0) ? a / b : a / b + 1;
}
long long dx[] = {1, 0, -1, 0};
long long dy[] = {0, 1, 0, -1};
vector<long long> pri(200000 + 6);
void prime_factorization_sieve() {
  pri[1] = 1;
  for (long long i = 2; i <= 200000 + 5; i++) {
    pri[i] = -1;
  }
  for (long long i = 2; i <= 200000 + 5; i++) {
    if (pri[i] == -1) {
      for (long long j = i; j <= 200000 + 5; j += i) {
        if (pri[j] == -1) pri[j] = i;
      }
    }
  }
}
vector<long long> get_factors(long long n) {
  vector<long long> res;
  while (pri[n] != 1) {
    res.push_back(pri[n]);
    n = n / pri[n];
  }
  return res;
}
void solve() {
  long long n, k;
  cin >> n >> k;
  vector<long long> arr(n + 1);
  for (long long i = 1; i <= n; i++) cin >> arr[i];
  long long ans = INT_MIN;
  long long x = (n >= 300) ? n - 300 : n;
  if (n >= 300) {
    for (long long i = x + 1; i <= n; i++) {
      for (long long j = 1; j <= n; j++) {
        if (i != j) {
          ans = ((ans) < (i * j - k * (arr[i] | arr[j]))
                     ? (i * j - k * (arr[i] | arr[j]))
                     : (ans));
        }
      }
    }
  } else {
    for (long long i = 1; i <= x; i++) {
      for (long long j = 1; j <= n; j++) {
        if (i != j) {
          ans = ((ans) < (i * j - k * (arr[i] | arr[j]))
                     ? (i * j - k * (arr[i] | arr[j]))
                     : (ans));
        }
      }
    }
  }
  cout << ans << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}

```