def solve(X, Y): N = len(X) M = len(Y) dp = [[0] * (M + 1) for _ in range(N + 1)] for i in range(1, N + 1): for j in range(1, M + 1): if X[i - 1] == Y[j - 1]: dp[i][j] = dp[i - 1][j - 1] + 1 else: dp[i][j] = max(dp[i-1][j], dp[i][j-1]) return M - dp[-1][-1] N, M = map(int, input().split()) A = list(map(int, input().split())) ans = [0] * N for i in range(N): L = list(range(1, i + 1)) L.reverse() ans[i] = solve(A, L) B = list(range(N)) for a in A[::-1]: B[a-1], B[a] = B[a], B[a-1] ind = B.index(0) for i in range(N): if ans[i] == 0: if i != ind: ans[i] = 1 print(*ans[1:])