You have been given an array A of size N and an integer K. This array consists of N integers ranging from 1 to 10^7. Each element in this array is said to have a Special Weight. The special weight of an element a[i] is a[i]\%K.

You now need to sort this array in Non-Increasing order of the weight of each element, i.e the element with the highest weight should appear first, then the element with the second highest weight and so on. In case two elements have the same weight, the one with the lower value should appear in the output first. 

Input Format:

The first line consists of two space separated integers N and K. The next line consists of N space separated integers denoting the elements of array A. 

Output Format:

Print N space separated integers denoting the elements of the array in the order in which they are required.

Constraints:

 1 ≤ N ≤ 10^5 

 1 ≤ A[i] ≤ 10^7 

 1 ≤ K ≤ 10^7 

Note:

You need to print the value of each element and not their weight. 

SAMPLE INPUT
5 2
1 2 3 4 5

SAMPLE OUTPUT
1 3 5 2 4
import sys
s=raw_input().split(" ")
s1=raw_input().split(" ")
s1=[int(x) for x in s1]
s1=sorted(s1)
dict={}
for i in range(0,len(s1)):
	dict.update({s1[i]:s1[i]%int(s[1])})
list=sorted(dict,key=dict.__getitem__,reverse=True)
list=[str(x) for x  in list]
print ' '.join(list)