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. 
#include <bits/stdc++.h>

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	// scanf("%d", &x);
	cin >> x;
	return x;
}

const int K = 19;
const int N = 1 << K;
int ans[N];

struct Node {
	int mn, mx, df;
} def = {-1, -1, -1};

ostream& operator <<(ostream& ostr, const Node& nd) {
	return ostr << "(mn=" << nd.mn << ", mx=" << nd.mx << ", df=" << nd.df << ")";
}

Node tree[K][N];

void relax(int& x, int y) {
	if (x == -1 || (y > -1 && y < x)) {
		x = y;
	}
}

Node merge(const Node& a, const Node& b) {
	int df = -1;
	if (a.mx > -1 && b.mn > -1) {
		relax(df, b.mn - a.mx);
	}
	if (a.df > -1) {
		relax(df, a.df);
	}
	if (b.df > -1) {
		relax(df, b.df);
	}
	return {
		a.mn > -1 ? a.mn : b.mn,
		b.mx > -1 ? b.mx : a.mx,
		df
	};
}

int big;

void fill_ans(int v, int cur, int when) {
	if (cur < when) {
		const int ll = (1 << when);
		for (int mask = 0; mask < ll; ++mask) {
			Node res = def;
			for (int i = 0; i < big; ++i) {
				int off = ((v >> when) ^ i);
				auto tmp = tree[when][(off << when) | mask];
				if (tmp.mn > -1) {
					tmp.mn ^= v;
				}
				if (tmp.mx > -1) {
					tmp.mx ^= v;
				}
				// if ((v | mask) == 5) cerr << tmp << " ";
				res = merge(res, tmp);
			}
			// if ((v | mask) == 5) cerr << (v | mask) << ": " << res << "\n";
			ans[v | mask] = res.df;
		}
		return;
	}
	fill_ans(v, cur - 1, when);
	fill_ans(v | (1 << cur), cur - 1, when);
}

void solve() {
	int n = nxt(), k = nxt();
	vector<int> a(n);
	generate(all(a), nxt);

	if (k == 1) {
		cout << "1 1\n";
		return;
	}

	const int kk = 1 << k;
	const int sm = min(k - 2, k / 2 + 2);

	fill(tree[0], tree[0] + kk, def);
	for (int x : a) {
		tree[0][x] = {x, x, -1};
	}
	for (int l = 1; l <= sm; ++l) {
		const int ll = 1 << l;
		const int lll = ll >> 1;
		fill(tree[l], tree[l] + kk, def);
		for (int i = 0; i < kk; i += ll) {
			for (int mask = 0; mask < ll; ++mask) {
				tree[l][i + mask] = (mask & lll)
						? merge(tree[l - 1][i + (mask ^ lll)], tree[l - 1][i + lll + (mask ^ lll)])
						: merge(tree[l - 1][i + lll + mask], tree[l - 1][i + mask]);
				if (mask & lll) {
					if (tree[l][i + mask].mn > -1) {
						tree[l][i + mask].mn ^= lll;
					}
					if (tree[l][i + mask].mx > -1) {
						tree[l][i + mask].mx ^= lll;
					}
				}
				// cerr << "tree[" << l << "][" << i + mask << "] = " << tree[l][i + mask] << "\n";
			}
		}
	}
	big = 1 << (k - sm);
	fill_ans(0, k - 1, sm);

	for (int i = 0; i < (1 << (k - 1)); ++i) {
		cout << ans[i] << " ";
	}
	for (int i = (1 << (k - 1)) - 1; i >= 0; --i) {
		cout << ans[i] << " ";
	}
	cout << "\n";
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int t = 1; // nxt();
	while (t--) {
		solve();
	}

	return 0;
}
