import operator class RangeOp: def __init__(self, ar, op): n = len(ar) self.op = op self.inc = [ar[:]] skip = 1 while True: if skip >= n: break cur_inc = self.inc[-1][:] for i in xrange(0, n - skip): cur_inc[i] = op(cur_inc[i], cur_inc[i + skip]) self.inc.append(cur_inc) skip <<= 1 def query(self, lo, hi): # Inclusive! w = hi - lo + 1 ret = None for i in xrange(w.bit_length()): if w & 1: v = self.inc[i][lo] ret = v if ret is None else self.op(ret, v) lo += 1 << i w >>= 1 return ret class Comp: def __init__(self, ar): self.romax = RangeOp(A, max) self.romin = RangeOp(A, min) self.roor = RangeOp(A, operator.__or__) self.roand = RangeOp(A, operator.__and__) def val(self, lo, hi): return self.roor.query(lo, hi) - self.roand.query(lo, hi) - \ self.romax.query(lo, hi) + self.romin.query(lo, hi) def costlyIntervals(n, k, A): if k == 0: return [n] * n c = Comp(A) ret = [-1] * n for span in xrange(2, n + 1): for lo in xrange(n + 1 - span): hi = lo + span - 1 v = c.val(lo, hi) if v >= k: for i in xrange(lo, hi + 1): ret[i] = span return ret n, k = raw_input().strip().split(' ') n, k = [int(n), int(k)] A = map(int, raw_input().strip().split(' ')) result = costlyIntervals(n, k, A) print "\n".join(map(str, result))