#include <bits/stdc++.h>
using namespace std;
const int MAXBIT = 20;
int nbElem, nbBits;
vector<int> arr;
vector<int> sol[MAXBIT];
vector<int> solve(int deb, int fin, int bit, vector<int> restants) {
  if (bit == -1) {
    assert(restants.size() <= 1);
    return restants;
  }
  int mid = (deb + fin) / 2;
  vector<int> lft, rgt;
  for (int &x : restants) {
    if (x & (1 << bit))
      rgt.push_back(x);
    else
      lft.push_back(x);
  }
  if (lft.empty()) {
    auto ret = solve(mid, fin, bit - 1, rgt);
    assert(ret.size() == (1 << bit));
    for (int i = 0; i < (1 << bit); ++i) ret.push_back(ret[i]);
    return ret;
  } else if (rgt.empty()) {
    auto ret = solve(deb, mid, bit - 1, lft);
    assert(ret.size() == (1 << bit));
    for (int i = 0; i < (1 << bit); ++i) ret.push_back(ret[i]);
    return ret;
  }
  auto retLft = solve(deb, mid, bit - 1, lft);
  auto retRgt = solve(mid, fin, bit - 1, rgt);
  assert(retLft.size() == (1 << bit));
  assert(retRgt.size() == (1 << bit));
  vector<int> ret(1 << (bit + 1));
  for (int a = 0; a < (1 << (bit + 1)); ++a) {
    int y = 1e9;
    int flipA = (1 << (bit + 1)) - 1 - a;
    assert(flipA < (1 << (bit + 1)));
    if (!(a & (1 << bit))) {
      y = (a ^ retRgt[a]) - (a ^ retLft[(1 << bit) - 1 - a]);
      ret[a] = retLft[a];
    } else {
      y = (a ^ retLft[a ^ (1 << bit)]) - (a ^ retRgt[flipA]);
      ret[a] = retRgt[a ^ (1 << bit)];
    }
    sol[bit][a] = min(sol[bit][a], y);
  }
  return ret;
}
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> nbElem >> nbBits;
  arr.resize(nbElem);
  for (int i = 0; i < MAXBIT; ++i) sol[i].assign(1 << nbBits, 1e9);
  for (int &v : arr) cin >> v;
  sort(arr.begin(), arr.end());
  solve(0, (1 << nbBits), nbBits - 1, arr);
  for (int x = 0; x < (1 << nbBits); ++x) {
    int ret = 1e9;
    int y = x;
    for (int bit = nbBits - 1; bit >= 0; --bit) {
      ret = min(ret, sol[bit][y]);
      if ((1 << bit) & y) y ^= 1 << bit;
    }
    cout << ret << '\n';
  }
  cout << endl;
}

### Prompt

Please create a solution in CPP to the following problem:

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 MAXBIT = 20;
int nbElem, nbBits;
vector<int> arr;
vector<int> sol[MAXBIT];
vector<int> solve(int deb, int fin, int bit, vector<int> restants) {
  if (bit == -1) {
    assert(restants.size() <= 1);
    return restants;
  }
  int mid = (deb + fin) / 2;
  vector<int> lft, rgt;
  for (int &x : restants) {
    if (x & (1 << bit))
      rgt.push_back(x);
    else
      lft.push_back(x);
  }
  if (lft.empty()) {
    auto ret = solve(mid, fin, bit - 1, rgt);
    assert(ret.size() == (1 << bit));
    for (int i = 0; i < (1 << bit); ++i) ret.push_back(ret[i]);
    return ret;
  } else if (rgt.empty()) {
    auto ret = solve(deb, mid, bit - 1, lft);
    assert(ret.size() == (1 << bit));
    for (int i = 0; i < (1 << bit); ++i) ret.push_back(ret[i]);
    return ret;
  }
  auto retLft = solve(deb, mid, bit - 1, lft);
  auto retRgt = solve(mid, fin, bit - 1, rgt);
  assert(retLft.size() == (1 << bit));
  assert(retRgt.size() == (1 << bit));
  vector<int> ret(1 << (bit + 1));
  for (int a = 0; a < (1 << (bit + 1)); ++a) {
    int y = 1e9;
    int flipA = (1 << (bit + 1)) - 1 - a;
    assert(flipA < (1 << (bit + 1)));
    if (!(a & (1 << bit))) {
      y = (a ^ retRgt[a]) - (a ^ retLft[(1 << bit) - 1 - a]);
      ret[a] = retLft[a];
    } else {
      y = (a ^ retLft[a ^ (1 << bit)]) - (a ^ retRgt[flipA]);
      ret[a] = retRgt[a ^ (1 << bit)];
    }
    sol[bit][a] = min(sol[bit][a], y);
  }
  return ret;
}
signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> nbElem >> nbBits;
  arr.resize(nbElem);
  for (int i = 0; i < MAXBIT; ++i) sol[i].assign(1 << nbBits, 1e9);
  for (int &v : arr) cin >> v;
  sort(arr.begin(), arr.end());
  solve(0, (1 << nbBits), nbBits - 1, arr);
  for (int x = 0; x < (1 << nbBits); ++x) {
    int ret = 1e9;
    int y = x;
    for (int bit = nbBits - 1; bit >= 0; --bit) {
      ret = min(ret, sol[bit][y]);
      if ((1 << bit) & y) y ^= 1 << bit;
    }
    cout << ret << '\n';
  }
  cout << endl;
}

```