#abc262f. [abc262_f]Erase and Rotate

[abc262_f]Erase and Rotate

Problem Statement

You are given a sequence P=(p1,p2,ldots,pN)P = (p_1,p_2,\\ldots,p_N) that contains 1,2,ldots,N1,2,\\ldots,N exactly once each.
You may perform the following operations between 00 and KK times in total in any order:

  • Choose one term of PP and remove it.
  • Move the last term of PP to the head.

Find the lexicographically smallest PP that can be obtained as a result of the operations.

Constraints

  • 1leqNleq2times1051 \\leq N \\leq 2 \\times 10^5
  • 0leqKleqN10 \\leq K \\leq N-1
  • 1leqpileqN1 \\leq p_i \\leq N
  • (p1,p2,ldots,pN)(p_1,p_2,\\ldots,p_N) contains 1,2,ldots,N1,2,\\ldots,N exactly once each.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK p1p_1 p2p_2 ldots\\ldots pNp_N

Output

Print the lexicographically smallest PP that can be obtained as a result of the operations, separated by spaces.


Sample Input 1

5 3
4 5 2 3 1

Sample Output 1

1 2 3

The following operations make PP equal (1,2,3)(1,2,3).

  • Removing the first term makes PP equal (5,2,3,1)(5,2,3,1).
  • Moving the last term to the head makes PP equal (1,5,2,3)(1,5,2,3).
  • Removing the second term makes PP equal (1,2,3)(1,2,3).

There is no way to obtain PP lexicographically smaller than (1,2,3)(1,2,3), so this is the answer.


Sample Input 2

3 0
3 2 1

Sample Output 2

3 2 1

You may be unable to perform operations.


Sample Input 3

15 10
12 10 7 2 8 11 9 1 6 14 3 15 13 5 4

Sample Output 3

1 3 4 7 2 8 11 9