def zip_sorted(a,b):

	# sorted  by a
	a,b = zip(*sorted(zip(a,b)))
	# sorted by b
	sorted(zip(a, b), key=lambda x: x[1])

	return a,b

import sys
input = sys.stdin.readline
I = lambda : list(map(int,input().split()))
S = lambda : list(map(str,input().split()))


q,x = I()
if x==1:
	for t1 in range(q):
		y,   = I()
		print(t1+1)
else:
	arr = []
	dp  = [0]*(4*(10**5)+1)
	dp1 = [0]*(4*(10**5)+1)
	min_idx = 0
	for t1 in range(q):
		y,   = I()
		if y<min_idx:

			sum1 = y-((min_idx)%x)

		elif y>min_idx:

			sum1 = ((y-min_idx)%x)

		else:

			sum1 = 0

		if (sum1+min_idx)>=len(dp):

			pass

		else:

			if dp[min_idx+sum1]==1:
				while True and min_idx+sum1<len(dp):
					if dp[min_idx+sum1]==0:
						dp[min_idx+sum1] = 1
						break
					else:
						sum1 = sum1+x
			else:
				dp[min_idx+sum1] = 1

		while dp[min_idx]==1:
			min_idx+=1
		print(min_idx)
		print(dp[:10])