#!/bin/python3 import sys from functools import reduce def costlyIntervals(n, k, A): # Return a list of length n consisting of the answers s={} for i in range(len(A)): for j in range(i+1,len(A)+1): subs=A[i:j] cost=reduce(lambda x,y:x|y,subs)-reduce(lambda x,y:x&y,subs)-(max(subs)-min(subs)) if cost>=6: for a in range(i,j): s[a]=len(subs) if s.get(i)==None: s[i]=-1 for k,v in s.items(): A[k]=v return A if __name__ == "__main__": n, k = input().strip().split(' ') n, k = [int(n), int(k)] A = list(map(int, input().strip().split(' '))) result = costlyIntervals(n, k, A) print ("\n".join(map(str, result)))