const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void async function () {
// Write your code here
while(line = await readline()){
const stringObj = await readline();
const orderTyppe = parseInt(await readline());
const formatStringObj = stringObj.split(' ');
if (orderTyppe === 0) {
const arr = formatStringObj.sort((a, b) => a - b);
console.log(arr.join(" "));
} else {
const brr = formatStringObj.sort((a, b) => b - a);
console.log(brr.join(" "));
}
}
}()