def calc(values,current,cMin,x,unusedLen=0):
    unused = []
    cMins = [0]
    for v in values:
        print(cMin)
        if (v-cMin)%x == 0:
            current.append(cMin)
            cMin += 1
            cMins.append(cMin)
        else:
            unused.append(v)
    print(cMin)
    if unusedLen == len(unused):
        return cMins
    else:
        return cMins + calc(unused,current,cMin,x,len(unused))


v1 = input()
v1 = v1.split(" ")
x = int(v1[1])
current = []
while True:
    try:
        current.append(int(input()))
    except EOFError:
        break
calc(current,[],0,x)