#include using namespace std; const int N = 5e5 + 5; int n, k, a[N]; int st[4][20][N]; int lg[N]; void build() { for (int i = 0; i < n; ++i) { st[0][0][i] = a[i]; st[1][0][i] = a[i]; st[2][0][i] = a[i]; st[3][0][i] = a[i]; } for (int j = 0; (2 << j) <= n; ++j) { for (int i = 0; i + (2 << j) <= n; ++i) { int k = i + (1 << j); st[0][j+1][i] = st[0][j][i] | st[0][j][k]; st[1][j+1][i] = st[1][j][i] & st[1][j][k]; st[2][j+1][i] = min(st[2][j][i], st[2][j][k]); st[3][j+1][i] = max(st[3][j][i], st[3][j][k]); } } for (int i = 2; i < N; ++i) { lg[i] = lg[i >> 1] + 1; } } int qor(int a, int b) { int k = lg[b - a + 1]; int ab = b - (1 << k) + 1; return st[0][k][a] | st[0][k][ab]; } int qand(int a, int b) { int k = lg[b - a + 1]; int ab = b - (1 << k) + 1; return st[1][k][a] & st[1][k][ab]; } int qmin(int a, int b) { int k = lg[b - a + 1]; int ab = b - (1 << k) + 1; return min(st[2][k][a], st[2][k][ab]); } int qmax(int a, int b) { int k = lg[b - a + 1]; int ab = b - (1 << k) + 1; return max(st[3][k][a], st[3][k][ab]); } int query(int a, int b) { return qor(a, b) - qand(a, b) - qmax(a, b) + qmin(a, b); } map f; vector rem[N]; int ans[N]; int main() { scanf("%d%d", &n, &k); for (int i = 0; i < n; ++i) scanf("%d", &a[i]); build(); // cout << qor(1, 2) << ' ' << (4|3) - (4&3) - 4 + 3 << endl; // cout << qand(1, 2) << endl; // cout << qmax(1, 2) << endl; // cout << qmin(1, 2) << endl; // cout << query(1, 2) << endl; for (int i = 0; i < n; ++i) { // search when or - and >= k int start;{ int L = i + 1, R = n - 1; while (L < R) { int M = (L + R) / 2; if (qor(i, M) - qand(i, M) < k) { L = M + 1; } else { R = M; } } start = L; } /* int mid; { int L = i + 1, R = n - 1; while (L < R) { int M = (L + R) / 2; if (query(i, M) < query(i, M + 1)) { L = M + 1; } else { R = M; } } mid = L; } */ // for (int j = i; j < n; ++j) { // cout << query(i, j) << ' '; // } // cout << endl; // cout << i << ": " << mid << endl; int L = start; int R = n - 1; while (L < R) { int M = (L + R) / 2; if (query(i, M + 1) >= k) { L = M + 1; } else { R = M; } } // cout << i << ": " << L << " " << query(i, L) << " " << k << endl; if (query(i, L) >= k) { // if (i == L) { // ans[i] = -1; // continue; // } int len = L - i + 1; f[len]++; rem[L].push_back(len); } ans[i] = f.size() == 0 ? -1 : f.rbegin()->first; for (auto& it : rem[i]) { if (--f[it] == 0) { f.erase(it); } } } for (int i = 0; i < n; ++i) { // if (ans[i] == 1) ans[i] = -1; printf("%d\n", ans[i]); } }