#include using namespace std; int A[100005]; const int r = 131072; int tab[2*r+5][5]; //or, and, max, min void add(int x, int value){ x += r; while (x){ if ( tab[x][4] ){ tab[x][0] |= value; tab[x][1] &= value; tab[x][2] = max(tab[x][2], value); tab[x][3] = min(tab[x][3], value); } else{ tab[x][0] = tab[x][1] = tab[x][2] = tab[x][3] = value; tab[x][4] = 1; } x /= 2; } } int check(int a, int b){ for(int i = 0; i < 5; i ++ )tab[0][i] = 0; while ( a <= b ){ int kom = a + r, z = 1; while ( kom % 2 == 0 and a + z * 2 <= b + 1 ){ kom /= 2; z *= 2; } int x = 0; if ( tab[x][4] ){ tab[x][0] |= tab[kom][0]; tab[x][1] &= tab[kom][1]; tab[x][2] = max(tab[x][2], tab[kom][2]); tab[x][3] = min(tab[x][3], tab[kom][3]); } else{ for(int i = 0; i < 5; i ++ ) tab[x][i] = tab[kom][i]; } a += z; } return tab[0][0] - tab[0][1] - (tab[0][2] - tab[0][3]); } int tre[2*r+5]; void goodAdd(int a, int b, int value){ while ( a <= b ){ int kom = a + r, z = 1; while ( kom % 2 == 0 and a + z * 2 <= b + 1 ){ kom /= 2; z *= 2; } tre[kom] = max(tre[kom], value); a += z; } } int goodCheck(int x){ x += r; int ans = 0; while(x){ ans = max(ans, tre[x]); x /= 2; } return ans; } int n, k; void go(){ for(int i = 2; i<= n+r; i ++){ tre[i] = max(tre[i], tre[i/2]); } } int main() { scanf("%d %d", &n, &k); for(int i = 0; i < n; i ++ ) { scanf("%d", &A[i]); add(i,A[i]); } for(int i = 0; i < n; i ++ ){ for(int j = i; j < n; j ++ ){ int c = check(i,j); if ( c >= k ){ goodAdd(i,j,j-i+1); } } } go(); for(int i = 0; i < n; i ++ ){ int a = tre[i+r];//goodCheck(i); if ( a == 0 ) printf("-1\n"); else printf("%d\n", a); } // puts(""); return 0; }