Recall that MEX of an array is a minimum non-negative integer that does not belong to the array. Examples:  for the array $[0, 0, 1, 0, 2]$ MEX equals to $3$ because numbers $0, 1$ and $2$ are presented in the array and $3$ is the minimum non-negative integer not presented in the array;  for the array $[1, 2, 3, 4]$ MEX equals to $0$ because $0$ is the minimum non-negative integer not presented in the array;  for the array $[0, 1, 4, 3]$ MEX equals to $2$ because $2$ is the minimum non-negative integer not presented in the array. 

You are given an empty array $a=[]$ (in other words, a zero-length array). You are also given a positive integer $x$.

You are also given $q$ queries. The $j$-th query consists of one integer $y_j$ and means that you have to append one element $y_j$ to the array. The array length increases by $1$ after a query.

In one move, you can choose any index $i$ and set $a_i := a_i + x$ or $a_i := a_i - x$ (i.e. increase or decrease any element of the array by $x$). The only restriction is that $a_i$ cannot become negative. Since initially the array is empty, you can perform moves only after the first query.

You have to maximize the MEX (minimum excluded) of the array if you can perform any number of such operations (you can even perform the operation multiple times with one element).

You have to find the answer after each of $q$ queries (i.e. the $j$-th answer corresponds to the array of length $j$).

Operations are discarded before each query. I.e. the array $a$ after the $j$-th query equals to $[y_1, y_2, \dots, y_j]$.


-----Input-----

The first line of the input contains two integers $q, x$ ($1 \le q, x \le 4 \cdot 10^5$) — the number of queries and the value of $x$.

The next $q$ lines describe queries. The $j$-th query consists of one integer $y_j$ ($0 \le y_j \le 10^9$) and means that you have to append one element $y_j$ to the array.


-----Output-----

Print the answer to the initial problem after each query — for the query $j$ print the maximum value of MEX after first $j$ queries. Note that queries are dependent (the array changes after each query) but operations are independent between queries.


-----Examples-----
Input
7 3
0
1
2
2
0
0
10

Output
1
2
3
3
4
4
7

Input
4 3
1
2
1
2

Output
0
0
0
0



-----Note-----

In the first example:  After the first query, the array is $a=[0]$: you don't need to perform any operations, maximum possible MEX is $1$.  After the second query, the array is $a=[0, 1]$: you don't need to perform any operations, maximum possible MEX is $2$.  After the third query, the array is $a=[0, 1, 2]$: you don't need to perform any operations, maximum possible MEX is $3$.  After the fourth query, the array is $a=[0, 1, 2, 2]$: you don't need to perform any operations, maximum possible MEX is $3$ (you can't make it greater with operations).  After the fifth query, the array is $a=[0, 1, 2, 2, 0]$: you can perform $a[4] := a[4] + 3 = 3$. The array changes to be $a=[0, 1, 2, 2, 3]$. Now MEX is maximum possible and equals to $4$.  After the sixth query, the array is $a=[0, 1, 2, 2, 0, 0]$: you can perform $a[4] := a[4] + 3 = 0 + 3 = 3$. The array changes to be $a=[0, 1, 2, 2, 3, 0]$. Now MEX is maximum possible and equals to $4$.  After the seventh query, the array is $a=[0, 1, 2, 2, 0, 0, 10]$. You can perform the following operations:   $a[3] := a[3] + 3 = 2 + 3 = 5$,  $a[4] := a[4] + 3 = 0 + 3 = 3$,  $a[5] := a[5] + 3 = 0 + 3 = 3$,  $a[5] := a[5] + 3 = 3 + 3 = 6$,  $a[6] := a[6] - 3 = 10 - 3 = 7$,  $a[6] := a[6] - 3 = 7 - 3 = 4$.  The resulting array will be $a=[0, 1, 2, 5, 3, 6, 4]$. Now MEX is maximum possible and equals to $7$.

Difficulty: introductory

Starter code:

Solutions:
import sys
from heapq import *
input = sys.stdin.readline

quer, m = list(map(int, input().split()))

vals = list(range(m))
q = []
for v in vals:
    heappush(q, v)

out = []
for _ in range(quer):
    nex = int(input()) % m
    vals[nex] += m
    heappush(q, vals[nex])

    new = heappop(q)
    while vals[new % m] != new:
        new = heappop(q)

    out.append(new)
    heappush(q, new)

print('\n'.join(map(str,out)))
    


import sys
input = sys.stdin.readline

q,x=list(map(int,input().split()))

seg_el=1<<((x+1).bit_length())
SEG=[0]*(2*seg_el)

def add1(n,seg_el):
    i=n+seg_el
    SEG[i]+=1
    i>>=1
    
    while i!=0:
        SEG[i]=min(SEG[i*2],SEG[i*2+1])
        i>>=1
        
def getvalues(l,r):
    L=l+seg_el
    R=r+seg_el
    ANS=1<<30

    while L<R:
        if L & 1:
            ANS=min(ANS , SEG[L])
            L+=1

        if R & 1:
            R-=1
            ANS=min(ANS , SEG[R])
        L>>=1
        R>>=1

    return ANS

for qu in range(q):
    t=int(input())
    add1(t%x,seg_el)

    #print(SEG)

    MIN=getvalues(0,x)

    OK=0
    NG=x

    while NG-OK>1:
        mid=(OK+NG)//2

        if getvalues(0,mid)>MIN:
            OK=mid
        else:
            NG=mid

    #print(MIN,OK)
    print(MIN*x+OK)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return list(map(int, minp().split()))

def solve():
	n,x = mints()
	c = [0]*x
	ans = 0
	for i in range(n):
		y = mint()
		c[y%x] += 1
		while c[ans%x] > 0:
			c[ans%x] -= 1
			ans += 1
		print(ans)

solve()



import sys

def main():
    input = sys.stdin.readline

    q,x = [int(i) for i in input().split()]
    A = [0 for i in range(x)]
    m = 0
    c = 0
    ans = []
    for a in range(q):
        n = int(input())
        A[n%x] += 1
        while A[c] >= (m//x+1):
            c = (c+1)%x
            m += 1
        ans.append(str(m))

    print("\n".join(ans))


def __starting_point():
    main()
__starting_point()

from sys import stdin
input = stdin.readline
n, x = map(int,input().split())
przyst = [0] * x
l = []
best = 0
for i in range(n):
    nju = int(input())
    przyst[nju%x] += 1
    while True:
        if przyst[best%x] != 0:
            best += 1
            przyst[(best-1)%x] -= 1
        else:
            break
    print(best)