import java.io.*;
import java.util.*;

public class battle_av_40 {

	FastScanner in;
	PrintWriter out;
	final String fileName = "battle";

	void solve() {
		int n = in.nextInt();
		int k = in.nextInt();
		int[] a = readPermutation(n);
		int last = n - 1;
		for (int i = 0; i < k; i++) {
			int newLast = -1;
			for (int j = 0; j < last; j++) {
				if (a[j] > a[j + 1]) {
					int tmp = a[j];
					a[j] = a[j + 1];
					a[j + 1] = tmp;
					newLast = j;
				}
			}
			last = newLast;
		}
		writePermutation(a);
	}
	
	int[] readPermutation(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt() - 1;
		}
		return a;
	}

	void writePermutation(int[] a) {
		for (int i = 0; i < a.length; i++) {
			out.print(a[i] + 1);
			if (i + 1 == a.length) {
				out.println();
			} else {
				out.print(' ');
			}
		}
	}

	void run() {
		try {
			in = new FastScanner(fileName + ".in");
			out = new PrintWriter(fileName + ".out");
			solve();
			out.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}
	}

	public static void main(String[] args) {
		new battle_av_40().run();
	}
}
