#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
int sz(const T &a) {
  return int(a.size());
}
struct trie {
  struct node {
    int ans, mival, maval, left, right;
    node() {
      left = -1, right = -1;
      ans = INT_MAX, mival = INT_MAX, maval = INT_MAX;
    }
  };
  vector<node> t;
  int newnode() {
    t.push_back(node());
    return sz(t) - 1;
  }
  int mt(int ind, int level) {
    if (ind == -1) ind = newnode();
    if (level == 0) return ind;
    int te = mt(-1, level - 1);
    t[ind].left = te;
    te = mt(-1, level - 1);
    t[ind].right = te;
    return ind;
  }
  void calc(int ind, int level) {
    t[ind].mival =
        (t[t[ind].left].mival == INT_MAX
             ? t[t[ind].right].mival +
                   (t[t[ind].right].mival == INT_MAX ? 0 : (1 << (level - 1)))
             : t[t[ind].left].mival);
    t[ind].maval = (t[t[ind].right].maval == INT_MAX
                        ? t[t[ind].left].maval
                        : t[t[ind].right].maval + (1 << (level - 1)));
    t[ind].ans = min(
        {t[t[ind].left].ans, t[t[ind].right].ans,
         (t[t[ind].left].maval == INT_MAX || t[t[ind].right].mival == INT_MAX
              ? INT_MAX
              : t[t[ind].right].mival + (1 << (level - 1)) -
                    t[t[ind].left].maval)});
  }
  void insert(int ind, int level, int val) {
    if (level == 0) {
      if (t[ind].mival == INT_MAX)
        t[ind].mival = t[ind].maval = 0;
      else
        t[ind].ans = 0;
      return;
    }
    if (val & (1 << (level - 1)))
      insert(t[ind].right, level - 1, val);
    else
      insert(t[ind].left, level - 1, val);
    calc(ind, level);
  }
  void xored(int ind, int level, int xorlevel) {
    if (level - 1 == xorlevel) {
      swap(t[ind].left, t[ind].right);
      calc(ind, level);
      return;
    }
    xored(t[ind].left, level - 1, xorlevel);
    xored(t[ind].right, level - 1, xorlevel);
    calc(ind, level);
  }
} solver;
int ans[(1 << 19)];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, k, a;
  cin >> n >> k;
  solver.mt(-1, k);
  for (int i = 0; i < n; i++) {
    cin >> a;
    solver.insert(0, k, a);
  }
  for (int i = 0; i < (1 << k); i++) {
    if (i)
      for (int j = 0; j < k; j++) {
        if ((i & (1 << j)) != ((i - 1) & (1 << j))) {
          solver.xored(0, k, k - j - 1);
        }
      }
    int val = 0;
    for (int j = 0; j < k; j++) {
      if (i & (1 << j)) val += (1 << (k - j - 1));
    }
    ans[val] = solver.t[0].ans;
  }
  for (int i = 0; i < (1 << k); i++)
    printf("%d%c", ans[i], " \n"[i == (1 << k) - 1]);
  return 0;
}

### Prompt

Create a solution in cpp for 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;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename T>
int sz(const T &a) {
  return int(a.size());
}
struct trie {
  struct node {
    int ans, mival, maval, left, right;
    node() {
      left = -1, right = -1;
      ans = INT_MAX, mival = INT_MAX, maval = INT_MAX;
    }
  };
  vector<node> t;
  int newnode() {
    t.push_back(node());
    return sz(t) - 1;
  }
  int mt(int ind, int level) {
    if (ind == -1) ind = newnode();
    if (level == 0) return ind;
    int te = mt(-1, level - 1);
    t[ind].left = te;
    te = mt(-1, level - 1);
    t[ind].right = te;
    return ind;
  }
  void calc(int ind, int level) {
    t[ind].mival =
        (t[t[ind].left].mival == INT_MAX
             ? t[t[ind].right].mival +
                   (t[t[ind].right].mival == INT_MAX ? 0 : (1 << (level - 1)))
             : t[t[ind].left].mival);
    t[ind].maval = (t[t[ind].right].maval == INT_MAX
                        ? t[t[ind].left].maval
                        : t[t[ind].right].maval + (1 << (level - 1)));
    t[ind].ans = min(
        {t[t[ind].left].ans, t[t[ind].right].ans,
         (t[t[ind].left].maval == INT_MAX || t[t[ind].right].mival == INT_MAX
              ? INT_MAX
              : t[t[ind].right].mival + (1 << (level - 1)) -
                    t[t[ind].left].maval)});
  }
  void insert(int ind, int level, int val) {
    if (level == 0) {
      if (t[ind].mival == INT_MAX)
        t[ind].mival = t[ind].maval = 0;
      else
        t[ind].ans = 0;
      return;
    }
    if (val & (1 << (level - 1)))
      insert(t[ind].right, level - 1, val);
    else
      insert(t[ind].left, level - 1, val);
    calc(ind, level);
  }
  void xored(int ind, int level, int xorlevel) {
    if (level - 1 == xorlevel) {
      swap(t[ind].left, t[ind].right);
      calc(ind, level);
      return;
    }
    xored(t[ind].left, level - 1, xorlevel);
    xored(t[ind].right, level - 1, xorlevel);
    calc(ind, level);
  }
} solver;
int ans[(1 << 19)];
int main() {
  cin.tie(NULL);
  ios_base::sync_with_stdio(false);
  int n, k, a;
  cin >> n >> k;
  solver.mt(-1, k);
  for (int i = 0; i < n; i++) {
    cin >> a;
    solver.insert(0, k, a);
  }
  for (int i = 0; i < (1 << k); i++) {
    if (i)
      for (int j = 0; j < k; j++) {
        if ((i & (1 << j)) != ((i - 1) & (1 << j))) {
          solver.xored(0, k, k - j - 1);
        }
      }
    int val = 0;
    for (int j = 0; j < k; j++) {
      if (i & (1 << j)) val += (1 << (k - j - 1));
    }
    ans[val] = solver.t[0].ans;
  }
  for (int i = 0; i < (1 << k); i++)
    printf("%d%c", ans[i], " \n"[i == (1 << k) - 1]);
  return 0;
}

```