problem

N students from JOI High School are lined up in a row from east to west. The i-th student from the western end of the column is student i. Each student has a bib with one integer. Initially, the integer Ai is written on the number of student i.

There are M batons, and the batons are numbered from 1 to M. For k = 1, 2, ..., M, perform the following operations. The operation related to baton k (2 ≤ k ≤ M) is performed after the operation related to baton k -1 is completed.

1. The teacher gives the baton k to student 1.
2. Students who receive the baton pass the baton according to the following rules.
* Rule: Suppose student i receives the baton k.
* 1 ≤ i ≤ N-1: When the remainder of the integer of the number of student i divided by k is greater than the remainder of the integer of the number of student i + 1 divided by k, student i and student i + 1 exchanges the number, and student i passes the baton to student i + 1. Otherwise, student i passes the baton to student i + 1 without changing the bib.
* When i = N: Student N passes the baton to the teacher.
3. When the teacher receives the baton k from student N, the operation related to the baton k is finished.



Given the integer and the number of batons M that were originally written in the student number, write a program to find the integer of each student's number after the teacher receives the baton M from student N.

input

The input consists of 1 + N lines.

The integers N and M (1 ≤ N ≤ 100, 1 ≤ M ≤ 100) are written on the first line, separated by blanks, and represent the number of students and the number of batons, respectively.

The integer Ai (1 ≤ Ai ≤ 1000) is written on the i-th line (1 ≤ i ≤ N) of the following N lines, and represents the integer Ai first written on the number of student i.

output

The output consists of N lines. On line i (1 ≤ i ≤ N), output the integer of the number of student i after the teacher receives the baton M from student N.

Input / output example

Input example 1


6 4
3
2
8
3
1
Five


Output example 1


2
3
1
8
Five
3


Input example 2


10 6
1
2
3
Four
Five
6
7
8
9
Ten


Output example 2


6
1
2
3
Ten
Four
8
7
9
Five


Input / output example 1 has 6 students. Initially, the student numbers are 3, 2, 8, 3, 1, and 5, in that order. There are four batons.

* At the end of the operation related to baton 1, the student numbers are 3, 2, 8, 3, 1, and 5, respectively.
* At the end of the operation related to baton 2, the student numbers are 2, 8, 3, 3, 1, and 5, respectively.
* At the end of the operation related to baton 3, the student numbers are 2, 3, 3, 1, 8, and 5, respectively.
* At the end of the operation related to baton 4, the student numbers are 2, 3, 1, 8, 5, and 3 in order.



Creative Commons License

Information Olympics Japan Committee work "15th Japan Information Olympics JOI 2015/2016 Qualifying Competition Tasks"





Example

Input

6 4
3
2
8
3
1
5


Output

2
3
1
8
5
3

Source: aizu | Difficulty: UNKNOWN_DIFFICULTY


Solutions:
(n, m) = map(int, input().split())
a = [int(input()) for _ in range(n)]
for i in range(1, m + 1):
	for j in range(n - 1):
		if a[j] % i > a[j + 1] % i:
			(a[j], a[j + 1]) = (a[j + 1], a[j])
for i in a:
	print(i)


(N, M) = map(int, input().split())
A = [0] * N
for i in range(N):
	A[i] = int(input())
for i in range(1, M + 1):
	if i == 1:
		continue
	else:
		for j in range(N - 1):
			if A[j] % i > A[j + 1] % i:
				tmp_val = A[j]
				A[j] = A[j + 1]
				A[j + 1] = tmp_val
for i in range(N):
	print(A[i])


(n, m) = map(int, input().split())
stu = []
for i in range(n):
	stu.append(int(input()))
for i in range(2, m + 1):
	for j in range(n - 1):
		if stu[j] % i > stu[j + 1] % i:
			(stu[j], stu[j + 1]) = (stu[j + 1], stu[j])
for i in stu:
	print(i)


a = input()
columns = a.split(' ')
num_of_student = int(columns[0])
Baton = int(columns[1])
student_bib = []
for i in range(num_of_student):
	student_bib.append(int(input()))
for Baton_num in range(Baton + 1):
	if Baton_num == 0:
		continue
	m = 0
	for j in range(num_of_student):
		if num_of_student - 1 == m:
			break
		if student_bib[m] % Baton_num > student_bib[m + 1] % Baton_num:
			student_bib_tmp = student_bib[m]
			student_bib[m] = student_bib[m + 1]
			student_bib[m + 1] = student_bib_tmp
		m += 1
for student_bib_ in student_bib:
	print(student_bib_)


(n, m) = map(int, input().split())
d = {}
for i in range(n):
	d[i + 1] = int(input())
for l in range(m):
	k = l + 1
	for j in range(n):
		i = j + 1
		if i == n:
			break
		if d[i] % k > d[i + 1] % k:
			t = d[i]
			d[i] = d[i + 1]
			d[i + 1] = t
for i in range(n):
	print(d[i + 1])


(N, M) = map(int, input().split())
zekken = []
for i in range(N):
	zekken.append(int(input()))

def sousa(zekken, k):
	for i in range(N - 1):
		if zekken[i] % k > zekken[i + 1] % k:
			(zekken[i], zekken[i + 1]) = (zekken[i + 1], zekken[i])
	return zekken
for k in range(1, M + 1):
	zekken = sousa(zekken, k)
for i in range(N):
	print(zekken[i])


(n, m) = map(int, input().split())
a = [int(input()) for i in range(n)]
for k in range(m):
	for i in range(n - 1):
		if a[i] % (k + 1) > a[i + 1] % (k + 1):
			(a[i], a[i + 1]) = (a[i + 1], a[i])
for i in range(n):
	print(a[i])


(n, m) = map(int, input().split())
s = [0 for _ in range(n + 1)]
for i in range(n):
	s[i + 1] = int(input())
for k in range(2, m + 1):
	for i in range(1, n):
		if s[i] % k > s[i + 1] % k:
			(s[i], s[i + 1]) = (s[i + 1], s[i])
for i in s[1:]:
	print(i)


(n, m) = map(int, input().split())
student = []
for _ in range(n):
	a = int(input())
	student.append(a)
for k in range(1, m + 1):
	for i in range(n - 1):
		if student[i] % k > student[i + 1] % k:
			(student[i], student[i + 1]) = (student[i + 1], student[i])
for s in student:
	print(s)


(n, m) = map(int, input().split())
a = [int(input()) for i in range(n)]
for k in range(1, m + 1):
	for i in range(n - 1):
		if a[i] % k > a[i + 1] % k:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
print(*a, sep='\n')


(n, m) = map(int, input().split())
s = []
for i in range(n):
	s.append(int(input()))
for i in range(2, m + 1):
	for j in range(n - 1):
		a = s[j] % i
		b = s[j + 1] % i
		if a > b:
			(s[j], s[j + 1]) = (s[j + 1], s[j])
for i in range(n):
	print(s[i])


(n, m) = map(int, input().split())
a = [int(input()) for i in range(n)]
for k in range(1, m + 1):
	for i in range(1, n):
		if a[i - 1] % k > a[i] % k:
			(a[i - 1], a[i]) = (a[i], a[i - 1])
for i in a:
	print(i)


def swappingBibs(a, k):
	for i in range(0, len(a) - 1):
		if a[i] % k > a[i + 1] % k:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
	return a
(N, M) = map(int, input().split())
A = [int(input()) for _ in range(N)]
for m in range(1, M + 1):
	A = swappingBibs(A, m)
for j in A:
	print(j)


(n, m) = map(int, input().split())
alst = [int(input()) for _ in range(n)]
for k in range(2, m + 1):
	for j in range(n - 1):
		if alst[j] % k > alst[j + 1] % k:
			(alst[j], alst[j + 1]) = (alst[j + 1], alst[j])
print(*alst, sep='\n')


(n, m) = [int(s) for s in input().split(' ')]
bibs = [int(input()) for i in range(n)]
for k in range(1, m + 1):
	for i in range(n - 1):
		if bibs[i] % k > bibs[i + 1] % k:
			(bibs[i], bibs[i + 1]) = (bibs[i + 1], bibs[i])
for bib in bibs:
	print(bib)


def main():
	(n, m) = map(int, input().split())
	a = []
	for i in range(n):
		a += [int(input())]
	for i in range(1, m + 1):
		for j in range(n - 1):
			if a[j] % i > a[j + 1] % i:
				(a[j], a[j + 1]) = (a[j + 1], a[j])
	print('\n'.join(map(str, a)))
main()


(N, M) = map(int, input().split())
bibs = [int(input()) for _ in range(N)]
btns = [k + 1 for k in range(M)]
for k in btns:
	for i in range(N - 1):
		if bibs[i] % k > bibs[i + 1] % k:
			(bibs[i], bibs[i + 1]) = (bibs[i + 1], bibs[i])
print(*bibs, sep='\n')


(N, M) = list(map(int, input().split(' ')))
A = [int(input()) for i in range(N)]
for k in range(1, M + 1):
	i = 1
	while i != N:
		if A[i - 1] % k > A[i] % k:
			(A[i - 1], A[i]) = (A[i], A[i - 1])
		i += 1
for a in A:
	print(a)


(n, m) = map(int, input().split())
a = [int(input()) for _ in range(n)]
baton = 0
for k in range(1, m + 1):
	for i in range(n):
		if i == n - 1:
			continue
		elif a[i] % k > a[i + 1] % k:
			v = a[i + 1]
			a[i + 1] = a[i]
			a[i] = v
for i in a:
	print(i)


(n, m) = map(int, input().split())
a = [int(input()) for i in range(n)]
for k in range(1, m + 1):
	for i in range(n - 1):
		if a[i] % k > a[i + 1] % k:
			(a[i], a[i + 1]) = (a[i + 1], a[i])
print(*a, sep='\n')


(n, m) = map(int, input().split())
a = []
for i in range(n):
	a.append(int(input()))
for k in range(m):
	for i in range(n - 1):
		if a[i] % (k + 1) > a[i + 1] % (k + 1):
			tmp = a[i]
			a[i] = a[i + 1]
			a[i + 1] = tmp
for i in range(n):
	print(a[i])


(N, M) = map(int, input().split())
A = [int(input()) for i in range(N)]
for k in range(1, M + 1):
	for i in range(N - 1):
		if A[i] % k > A[i + 1] % k:
			(A[i], A[i + 1]) = (A[i + 1], A[i])
for a in A:
	print(a)


def swap(i, j):
	X = A[i]
	A[i] = A[j]
	A[j] = X
(N, M) = map(int, input().split())
A = list()
for i in range(N):
	A.append(int(input()))
for i in range(M):
	for j in range(N - 1):
		if A[j] % (i + 1) > A[j + 1] % (i + 1):
			swap(j, j + 1)
for i in range(N):
	print(A[i])