#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int n, k;
int a[N];
int ch[N][2], siz[N], tot = 1;
int num[21];
int ans[N], nowans[N], now[N * 10];
int dongtot = 0;
bool Fa = false;
void Ins(int x) {
  for (int i = 20; i >= 1; i--) {
    num[i] = (x & 1);
    x >>= 1;
  }
  int now = 1;
  siz[now]++;
  for (int i = 1; i <= 20; i++) {
    if (!ch[now][num[i]]) ch[now][num[i]] = (++tot);
    now = ch[now][num[i]];
    siz[now]++;
  }
  if (siz[now] >= 2) {
    Fa = true;
  }
}
inline int Min(int A, int B) { return (A > B) ? B : A; }
int Qmin(int posi, int x, int qian) {
  if (!qian) return 0;
  int topos = ((x & qian) ? 1 : 0);
  if (ch[posi][topos])
    return Qmin(ch[posi][topos], x, qian >> 1);
  else
    return (qian) + Qmin(ch[posi][!topos], x, qian >> 1);
}
int Qmax(int posi, int x, int qian) {
  if (!qian) return 0;
  int topos = ((x & qian) ? 1 : 0);
  if (ch[posi][!topos])
    return (qian) + Qmax(ch[posi][!topos], x, qian >> 1);
  else
    return Qmax(ch[posi][topos], x, qian >> 1);
}
void Solve(int posi, int qian) {
  if (siz[posi] < 2) {
    for (int i = 0; i < qian; i++) nowans[i] = 2147483647;
    return;
  }
  int hahaha = (qian >> 1);
  int L = dongtot + 1;
  dongtot += qian;
  for (int i = 0; i < qian; i++) now[L + i] = 2147483647;
  Solve(ch[posi][0], hahaha);
  for (int i = 0; i < (hahaha); i++) {
    now[L + i] = Min(now[L + i], nowans[i]);
    now[L + i + (hahaha)] = Min(now[L + i + (hahaha)], nowans[i]);
  }
  Solve(ch[posi][1], hahaha);
  for (int i = 0; i < (hahaha); i++) {
    now[L + i] = Min(now[L + i], nowans[i]);
    now[L + i + (hahaha)] = Min(now[L + i + (hahaha)], nowans[i]);
  }
  if (!ch[posi][0] || !ch[posi][1]) {
    for (int i = 0; i < qian; i++) {
      nowans[i] = now[L + i];
      ans[i] = Min(ans[i], nowans[i]);
    }
    return;
  }
  for (int i = 0; i < (hahaha); i++) {
    int Md1 = Qmin(ch[posi][1], i, hahaha >> 1);
    int Md2 = Qmax(ch[posi][0], i, hahaha >> 1);
    now[L + i] = Min(now[L + i], Md1 - Md2 + (hahaha));
  }
  for (int i = (hahaha); i < qian; i++) {
    int Md1 = Qmin(ch[posi][0], i ^ (hahaha), hahaha >> 1);
    int Md2 = Qmax(ch[posi][1], i ^ (hahaha), hahaha >> 1);
    now[L + i] = Min(now[L + i], Md1 - Md2 + (hahaha));
  }
  for (int i = 0; i < qian; i++) {
    nowans[i] = now[L + i];
    ans[i] = Min(ans[i], nowans[i]);
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    Ins(a[i]);
  }
  if (Fa) {
    for (int i = 0; i < (1 << k); i++) printf("0 ");
    return 0;
  }
  for (int i = 0; i < (1 << k); i++) ans[i] = 2147483647;
  Solve(1, (1 << 20));
  for (int i = 0; i < (1 << k); i++) printf("%d ", ans[i]);
}

### Prompt

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

You are given an array a consisting of n distinct elements and an integer k. Each element in the array is a non-negative integer not exceeding 2^k-1.

Let's define the XOR distance for a number x as the value of 

$$$f(x) = min_{i = 1}^{n} min_{j = i + 1}^{n} |(a_i ⊕ x) - (a_j ⊕ x)|,$$$

where ⊕ denotes [the bitwise XOR operation](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).

For every integer x from 0 to 2^k-1, you have to calculate f(x).

Input

The first line contains two integers n and k (1 ≤ k ≤ 19; 2 ≤ n ≤ 2^k).

The second line contains n integers a_1, a_2, ..., a_n (0 ≤ a_i ≤ 2^k-1). All these integers are distinct.

Output

Print 2^k integers. The i-th of them should be equal to f(i-1).

Examples

Input


3 3
6 0 3


Output


3 1 1 2 2 1 1 3 


Input


3 4
13 4 2


Output


2 2 6 6 3 1 2 2 2 2 1 3 6 6 2 2 

Note

Consider the first example:

  * for x = 0, if we apply bitwise XOR to the elements of the array with x, we get the array [6, 0, 3], and the minimum absolute difference of two elements is 3; 
  * for x = 1, if we apply bitwise XOR to the elements of the array with x, we get the array [7, 1, 2], and the minimum absolute difference of two elements is 1; 
  * for x = 2, if we apply bitwise XOR to the elements of the array with x, we get the array [4, 2, 1], and the minimum absolute difference of two elements is 1; 
  * for x = 3, if we apply bitwise XOR to the elements of the array with x, we get the array [5, 3, 0], and the minimum absolute difference of two elements is 2; 
  * for x = 4, if we apply bitwise XOR to the elements of the array with x, we get the array [2, 4, 7], and the minimum absolute difference of two elements is 2; 
  * for x = 5, if we apply bitwise XOR to the elements of the array with x, we get the array [3, 5, 6], and the minimum absolute difference of two elements is 1; 
  * for x = 6, if we apply bitwise XOR to the elements of the array with x, we get the array [0, 6, 5], and the minimum absolute difference of two elements is 1; 
  * for x = 7, if we apply bitwise XOR to the elements of the array with x, we get the array [1, 7, 4], and the minimum absolute difference of two elements is 3. 

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
const int N = 2000005;
int n, k;
int a[N];
int ch[N][2], siz[N], tot = 1;
int num[21];
int ans[N], nowans[N], now[N * 10];
int dongtot = 0;
bool Fa = false;
void Ins(int x) {
  for (int i = 20; i >= 1; i--) {
    num[i] = (x & 1);
    x >>= 1;
  }
  int now = 1;
  siz[now]++;
  for (int i = 1; i <= 20; i++) {
    if (!ch[now][num[i]]) ch[now][num[i]] = (++tot);
    now = ch[now][num[i]];
    siz[now]++;
  }
  if (siz[now] >= 2) {
    Fa = true;
  }
}
inline int Min(int A, int B) { return (A > B) ? B : A; }
int Qmin(int posi, int x, int qian) {
  if (!qian) return 0;
  int topos = ((x & qian) ? 1 : 0);
  if (ch[posi][topos])
    return Qmin(ch[posi][topos], x, qian >> 1);
  else
    return (qian) + Qmin(ch[posi][!topos], x, qian >> 1);
}
int Qmax(int posi, int x, int qian) {
  if (!qian) return 0;
  int topos = ((x & qian) ? 1 : 0);
  if (ch[posi][!topos])
    return (qian) + Qmax(ch[posi][!topos], x, qian >> 1);
  else
    return Qmax(ch[posi][topos], x, qian >> 1);
}
void Solve(int posi, int qian) {
  if (siz[posi] < 2) {
    for (int i = 0; i < qian; i++) nowans[i] = 2147483647;
    return;
  }
  int hahaha = (qian >> 1);
  int L = dongtot + 1;
  dongtot += qian;
  for (int i = 0; i < qian; i++) now[L + i] = 2147483647;
  Solve(ch[posi][0], hahaha);
  for (int i = 0; i < (hahaha); i++) {
    now[L + i] = Min(now[L + i], nowans[i]);
    now[L + i + (hahaha)] = Min(now[L + i + (hahaha)], nowans[i]);
  }
  Solve(ch[posi][1], hahaha);
  for (int i = 0; i < (hahaha); i++) {
    now[L + i] = Min(now[L + i], nowans[i]);
    now[L + i + (hahaha)] = Min(now[L + i + (hahaha)], nowans[i]);
  }
  if (!ch[posi][0] || !ch[posi][1]) {
    for (int i = 0; i < qian; i++) {
      nowans[i] = now[L + i];
      ans[i] = Min(ans[i], nowans[i]);
    }
    return;
  }
  for (int i = 0; i < (hahaha); i++) {
    int Md1 = Qmin(ch[posi][1], i, hahaha >> 1);
    int Md2 = Qmax(ch[posi][0], i, hahaha >> 1);
    now[L + i] = Min(now[L + i], Md1 - Md2 + (hahaha));
  }
  for (int i = (hahaha); i < qian; i++) {
    int Md1 = Qmin(ch[posi][0], i ^ (hahaha), hahaha >> 1);
    int Md2 = Qmax(ch[posi][1], i ^ (hahaha), hahaha >> 1);
    now[L + i] = Min(now[L + i], Md1 - Md2 + (hahaha));
  }
  for (int i = 0; i < qian; i++) {
    nowans[i] = now[L + i];
    ans[i] = Min(ans[i], nowans[i]);
  }
}
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    Ins(a[i]);
  }
  if (Fa) {
    for (int i = 0; i < (1 << k); i++) printf("0 ");
    return 0;
  }
  for (int i = 0; i < (1 << k); i++) ans[i] = 2147483647;
  Solve(1, (1 << 20));
  for (int i = 0; i < (1 << k); i++) printf("%d ", ans[i]);
}

```