def maxmex(ar, n):
    count = len(ar)
    nls = [0] * n
    for a in range(count):
        nls[a % n] += 1
    k = 0
    mexi = 0
    while(True):
        if nls[k % n] == 0:
            mexi = k
            break
        elif nls[k % n] >= 1:
            nls[k % n] -= 1
            k += 1
    return mexi
    
ls = list(map(int, input().split()))
arri = []
x = ls[1]
for i in range(ls[0]):
    arri.append(int(input()))
for i in range(1,ls[0]+1):
    print(maxmex(arri[:i], x))