#include <bits/stdc++.h>
using namespace std;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXBITS = 19;
const int MAXN = 1 << MAXBITS;
struct Res {
  int mn, mx, best;
  Res() {}
  Res(int mn, int mx, int best) : mn(mn), mx(mx), best(best) {}
};
int n, nbits;
int a[MAXN];
int ans[1 << MAXBITS];
int cnt[1 << MAXBITS];
Res combine(const Res& a, const Res& b, int step) {
  Res ret;
  ret.mn = a.mn != INT_MAX ? a.mn : b.mn != INT_MAX ? step + b.mn : INT_MAX;
  ret.mx = b.mx != INT_MIN ? step + b.mx : a.mx != INT_MIN ? a.mx : INT_MIN;
  ret.best = min(a.best, b.best);
  if (a.mx != INT_MIN && b.mn != INT_MAX)
    ret.best = min(ret.best, step + b.mn - a.mx);
  return ret;
}
vector<Res> rec(int offset, int k) {
  vector<Res> ret(1 << k);
  if (k == 0) {
    if (cnt[offset] == 0)
      ret[0] = Res(INT_MAX, INT_MIN, INT_MAX);
    else
      ret[0] = Res(0, 0, INT_MAX);
  } else {
    vector<Res> l = rec(offset, k - 1);
    vector<Res> r = rec(offset + (1 << (k - 1)), k - 1);
    for (int i = (0); i < (1 << (k - 1)); ++i) {
      ret[i] = combine(l[i], r[i], 1 << (k - 1));
      ret[(1 << (k - 1)) + i] = combine(r[i], l[i], 1 << (k - 1));
    }
  }
  return ret;
}
void solve() {
  for (int i = (0); i < (1 << nbits); ++i) cnt[i] = 0;
  for (int i = (0); i < (n); ++i) ++cnt[a[i]];
  for (int i = (0); i < (1 << nbits); ++i)
    if (cnt[i] >= 2) {
      for (int j = (0); j < (1 << nbits); ++j) ans[i] = 0;
      return;
    }
  vector<Res> res = rec(0, nbits);
  for (int i = (0); i < (1 << nbits); ++i) ans[i] = res[i].best;
}
void run() {
  scanf("%d%d", &n, &nbits);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  solve();
  for (int i = (0); i < (1 << nbits); ++i) {
    if (i != 0) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
}
int main() {
  run();
  return 0;
}

### Prompt

Develop a solution in Cpp 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;
std::mt19937 rnd(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXBITS = 19;
const int MAXN = 1 << MAXBITS;
struct Res {
  int mn, mx, best;
  Res() {}
  Res(int mn, int mx, int best) : mn(mn), mx(mx), best(best) {}
};
int n, nbits;
int a[MAXN];
int ans[1 << MAXBITS];
int cnt[1 << MAXBITS];
Res combine(const Res& a, const Res& b, int step) {
  Res ret;
  ret.mn = a.mn != INT_MAX ? a.mn : b.mn != INT_MAX ? step + b.mn : INT_MAX;
  ret.mx = b.mx != INT_MIN ? step + b.mx : a.mx != INT_MIN ? a.mx : INT_MIN;
  ret.best = min(a.best, b.best);
  if (a.mx != INT_MIN && b.mn != INT_MAX)
    ret.best = min(ret.best, step + b.mn - a.mx);
  return ret;
}
vector<Res> rec(int offset, int k) {
  vector<Res> ret(1 << k);
  if (k == 0) {
    if (cnt[offset] == 0)
      ret[0] = Res(INT_MAX, INT_MIN, INT_MAX);
    else
      ret[0] = Res(0, 0, INT_MAX);
  } else {
    vector<Res> l = rec(offset, k - 1);
    vector<Res> r = rec(offset + (1 << (k - 1)), k - 1);
    for (int i = (0); i < (1 << (k - 1)); ++i) {
      ret[i] = combine(l[i], r[i], 1 << (k - 1));
      ret[(1 << (k - 1)) + i] = combine(r[i], l[i], 1 << (k - 1));
    }
  }
  return ret;
}
void solve() {
  for (int i = (0); i < (1 << nbits); ++i) cnt[i] = 0;
  for (int i = (0); i < (n); ++i) ++cnt[a[i]];
  for (int i = (0); i < (1 << nbits); ++i)
    if (cnt[i] >= 2) {
      for (int j = (0); j < (1 << nbits); ++j) ans[i] = 0;
      return;
    }
  vector<Res> res = rec(0, nbits);
  for (int i = (0); i < (1 << nbits); ++i) ans[i] = res[i].best;
}
void run() {
  scanf("%d%d", &n, &nbits);
  for (int i = (0); i < (n); ++i) scanf("%d", &a[i]);
  solve();
  for (int i = (0); i < (1 << nbits); ++i) {
    if (i != 0) printf(" ");
    printf("%d", ans[i]);
  }
  puts("");
}
int main() {
  run();
  return 0;
}

```