Question
Lexicographically Smallest Subsequence
In a distant land, Todo has an array of numbers, Arr, and a magic number K. He wants to find the smallest possible sequence of exactly K numbers from Arr (keeping their original order). Help Todo find this lexicographically smallest subsequence!
Input
The first line of input contains two space-separated integers N and K.
The second line of the input contains N integers denoting array Arr.
Constraints
1 ≤ K ≤ N ≤ 105
1 ≤ Arr[i] ≤ 109
The second line of the input contains N integers denoting array Arr.
Constraints
1 ≤ K ≤ N ≤ 105
1 ≤ Arr[i] ≤ 109
Output
Print K space separated integers denoting the lexicographically smallest subsequence of the array of size K.
Example
Sample Input
5 2
12 2 1 3 4
Sample Output
1 3
Sample Input
5 4
12 2 1 3 4
Sample Output
2 1 3 4
5 2
12 2 1 3 4
Sample Output
1 3
Sample Input
5 4
12 2 1 3 4
Sample Output
2 1 3 4