Under construction

Still being built. Things may change

Bubble Sort

Time limit1sMemory limit64 MB

Summary
Compute the array after K left-to-right bubble sort passes over N numbers without simulating every swap.
Level

Medium6 of 10

Topics
Segment tree, Sorting, Simulation
Solved
No attempts yet

Problem

Bubble sort orders a sequence of length NN by comparing two adjacent values and swapping them. Call one execution of the procedure below a round.

  • Compare the value at position 1 with the value at position 2, and swap them if the earlier one is larger.
  • Compare the value at position 2 with the value at position 3, and swap them if the earlier one is larger.
  • Continue the same way to the right end.
  • Compare the value at position N−1N-1 with the value at position NN, and swap them if the earlier one is larger.

Repeating a round NN times sorts the sequence in ascending order. Sechan already knows the sorted result, so he wants to look at an intermediate state instead. NN is very large, so imitating KK rounds directly takes too long. Help Sechan and write a program that computes the state of the sequence after KK rounds.

Input

The first line contains NN and KK, separated by a space.

The second line contains the NN integers of the initial sequence in order, separated by spaces.

  • 1≤N≤1000001 \le N \le 100000
  • 1≤K≤N1 \le K \le N
  • Each term of the sequence is an integer between 11 and 10000000001000000000.

Output

Print the state of the sequence after KK rounds on one line. Separate the numbers with a single space.

Examples3

  1. Example 1

    Input
    4 1
    62 23 32 15
    
    Expected output
    23 32 15 62
    
  2. Example 2

    Input
    1 1
    7
    
    Expected output
    7
    
  3. Example 3

    Input
    5 5
    5 4 3 2 1
    
    Expected output
    1 2 3 4 5