Polycarp had an array $$$a$$$ of $$$3$$$ positive integers. He wrote out the sums of all non-empty subsequences of this array, sorted them in non-decreasing order, and got an array $$$b$$$ of $$$7$$$ integers.For example, if $$$a = \{1, 4, 3\}$$$, then Polycarp wrote out $$$1$$$, $$$4$$$, $$$3$$$, $$$1 + 4 = 5$$$, $$$1 + 3 = 4$$$, $$$4 + 3 = 7$$$, $$$1 + 4 + 3 = 8$$$. After sorting, he got an array $$$b = \{1, 3, 4, 4, 5, 7, 8\}.$$$Unfortunately, Polycarp lost the array $$$a$$$. He only has the array $$$b$$$ left. Help him to restore the array $$$a$$$.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 5000$$$) — the number of test cases. Each test case consists of one line which contains $$$7$$$ integers $$$b_1, b_2, \dots, b_7$$$ ($$$1 \le b_i \le 10^9$$$; $$$b_i \le b_{i+1}$$$).  Additional constraint on the input: there exists at least one array $$$a$$$ which yields this array $$$b$$$ as described in the statement.

For each test case, print $$$3$$$ integers — $$$a_1$$$, $$$a_2$$$ and $$$a_3$$$. If there can be several answers, print any of them.

NoteThe subsequence of the array $$$a$$$ is a sequence that can be obtained from $$$a$$$ by removing zero or more of its elements.Two subsequences are considered different if index sets of elements included in them are different. That is, the values of the elements don't matter in the comparison of subsequences. In particular, any array of length $$$3$$$ has exactly $$$7$$$ different non-empty subsequences.

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var x = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));
        const a = num[0], b = num[1], c = num[num.length - 1] - a - b;
        console.log(`${a} ${b} ${c}`);
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var x = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));

        console.log(d(num).join(' '));
    }
}
function d (ms) {
    var n = ms[ms.length - 1];
    var p = ms[0];
    for (var i = 1; ms.length > i; i++) {
        for (var j = i; ms.length > j; j++) {
            if (ms[j] + ms[i] === n - p) {
                return [p, ms[j], ms[i]]
            }
        }
    }
}

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = ((parseInt(c) == parseInt(a) + parseInt(b)) ? d : c);

  console.log(`${a} ${b} ${third}`);
  return;
})

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = ((parseInt(c) == parseInt(a) + parseInt(b)) ? d : c);

  console.log(`${a} ${b} ${third}`);
  return;
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var k = lines[i].split(' ').map(Number);
        var a = new Array(3);
        a[0] = k[6] - k[5];
        a[2] = k[4] - a[0];
        a[1] = k[6] - a[0] - a[2];
        var s = '';
        for(j = 0; j < 3; j++){
            s += a[j] + ' ';
        }
        console.log(s);
    }
});

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// FPT------Regional ^^ Let's go

function main() {
    var x = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));
        const a = num[0], b = num[1], c = num[num.length - 1] - a - b;
        console.log(`${a} ${b} ${c}`);
    }
}

// READLINE TEMPLATE
//
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
    inputString += inputStdin;
});

process.stdin.on("end", (_) => {
    inputString = inputString
        .trim()
        .split("\n")
        .map((string) => {
            return string.trim();
        });

    main();
});

function readline() {
    return inputString[currentLine++];
}

const print = console.log

// READLINE TEMPLATE

function findSum(arr,target) {
    const l1 = arr.length
    const l2 = l1 - 1
    for (let i = 0; i < l2; i++) {
        const a = arr[i]
        if (a > target) break
        const diff = target - a
        for (let j = i + 1; j < l1; j++) {
            const b = arr[j]
            if (b === diff) return [a,b]
            if (b > diff) break
        }
    }
}

function findOriginal(data) {
    const sorted = data.sort((a,b) => a-b)
    const a = sorted.shift()
    const a_b_c = sorted.pop()
    const b_c = a_b_c - a
    const [b,c] = findSum(sorted,b_c)
    return [a,b,c]
}

function main() {
    const n = parseInt(readline())
    for (let i = 0; i < n; i++) {
        const a = readline().split(" ").map(n => parseInt(n))
        print(...findOriginal(a))
    }
}

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const b = rna();
		x = b[0];
		y = b[1];
		z = b[6] - x - y;

		console.log(x, y, z);
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    let noOfTestCases = Number(readline());
    let testCaseArray = [];
    for (let i = 0; i < noOfTestCases; i++) {
        testCaseArray.push(readline().split(" ").map(x => Number(x)));
    }

    for (let i = 0; i < noOfTestCases; i++) {
        findLostArray(testCaseArray[i])
    }
}

function findLostArray(B) {
    console.log(B[0], B[1], B[6] - B[0] - B[1])
}

    // your code goes here
    const fs = require('fs');
    const input = fs.readFileSync(0, 'utf8').trim().split('\n');
    let currentline = 0;
    function readline(){
        return input[currentline++];
    }
    var T = readline();
    for(var q = 1;q<=T;q++) {
        var a = readline().split(" ").map(x => parseInt(x));
        var f = []
        var dist = []
        for(var i=0;i<a.length;i++) {
        	if(f[a[i]] == undefined) dist.push(a[i])
        	f[a[i]] = true;
        }
        var ar = []
        for(var i=0;i<a.length-2;i++) {
        	for(var j=i+1;j<a.length-1;j++) {
        		for(var r=j+1;r<a.length;r++) {
        			var p = [a[i], a[j], a[r]]
        			ar.push(p)//[a[i], a[j], a[r]])
        		}
        	}
        }
        //console.log(dist.length)
        for(var i=0;i<ar.length;i++) {
        	var k = ar[i];
        	var l = []
        	//console.log(ar[i], i)
        	var sum = 0;
        	for(var j=0;j<k.length;j++) {
        		if(l[k[j]] == undefined && f[k[j]] == true){
        			l[k[j]] = true;
        			sum++;
        		} //l[k[j]] = true; sum++;
        		for(var t=j+1;t<k.length;t++) {
        			if(l[k[j]+k[t]] == undefined && f[k[j]+k[t]] == true) {
        				sum++;
        				l[k[j]+k[t]] = true;
        			}
        		}
        	}
        	if(l[k[0]+k[1]+k[2]] == undefined && f[k[0]+k[1]+k[2]] == true) sum++;
        	//if(k[0] == 1 && k[1] == 2 && k[2] == 3) console.log(sum);// break;
        	if(sum == dist.length){
        		console.log(k.join(' '));
        		break;
        	}
        }
    }

// let a = [[1, 3, 4, 4, 5, 7, 8], [1, 2, 3, 4, 5, 6, 7]];
let n = null, m = null, a=[];
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

readline.on('line', line => {
    if (n == null) {
        n = parseInt(line)
        m = n
    } else if (m>0) {
        m--;
        a.push(line.split(' ').map(e=>parseInt(e)))
    }
    if (m == 0) {
        readline.close();
        main();
    }
});

function main(){
    a.forEach(e=> {
        let x = e.pop();
        for (let i = 0; i < e.length-2; i++)
        for (let j = i+1; j < e.length-1; j++)
        for (let k = j+1; k < e.length; k++)
        if (e[i]+e[j]+e[k] == x) {
            return console.log([e[i],e[j],e[k]].join(" "));
        }
    });
}
// main();

process.stdin.resume();
process.stdin.setEncoding('utf-8');
let inputString = '';
let currentLine = 0;
process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});
function readLine() {
    return inputString[currentLine++];
};
process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });
    main();
    // cmd(not powershell): node cp.js < input.txt
});

function main() {
    let t = parseInt(readLine());
    while (t-- > 0) {
        console.log(solve());
    }
}
function solve() {
    let arr = readLine().split(" ").map(i => parseInt(i));
    return `${arr[0]} ${arr[1]} ${arr[6]-arr[0]-arr[1]}`;
}

let buffer = '';
process.stdin.on('data', c => buffer += c);
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = buffer.split(EOL);
  lines.pop();

  main(lines);
});

function main(lines) {
  let T = Number(lines[0]);
  let index = 1;
  let arr;

  while (T--) {
    arr = lines[index++].split(' ').map(Number);
    solve(arr);
  }
}

function solve(arr) {
  arr.sort((a, b) => a - b);
  console.log(`${arr[0]} ${arr[1]} ${arr[6] - arr[1] - arr[0]}`);
}

let data = '';
process.stdin.on('data', c => data += c);

function* nextLine() {
	let lines = data.trim().split(/\n/g);
	for(let l of lines){
		yield l.trim();
	}
}

let nl = nextLine();

nl.elem = function(funParse) {
		return funParse(this.next().value);
	};

nl.array = function(funParse) {
		return this.next().value.split(/\s/g).map(funParse||(x => x));
	};

nl.num = function() {
		return nl.elem(Number);
	};

nl.nums = function() {
		return nl.array(Number);
	};

nl.line = function() {
		return this.next().value;
	};

const sol = () => {
	//your code this
	let t = nl.num();
	let ans = [];
	for(let i = 0; i < t; i++){
		let a = nl.nums();
		let x = a[0];
		let y = a[1];
		let z = a[6] - x - y;
		ans.push(`${x} ${y} ${z}`);
	}
	console.log(ans.join('\n'));
};

process.stdin.on('end', sol);

"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");

function print(x) {
  console.log(x);
}

let inputString = "";
let currentLine = 0;

process.stdin.on("data", (inputStdin) => {
  inputString += inputStdin;
});
process.stdin.on("end", () => {
  inputString = inputString.split("\n");
  main();
});

function readline() {
  return inputString[currentLine++];
}

function main() {
  var t = parseInt(readline())

  while (t--) {
    var input2 = readline()
      .split(" ")
      .map((data) => +data)

    var max = Math.max(...input2)

    var a1 = 0;
    var a2 = 0;
    var a3 = 0;

    for (var i = 0; i < input2.length - 2; i++) {
      for (var j = i + 1; j < input2.length - 1; j++) {
        for (var k = j + 1; k < input2.length; k++) {
          if (input2[i] + input2[j] + input2[k] === max) {
            a1 = input2[i]
            a2 = input2[j]
            a3 = input2[k]
          }
        }
      }
    }
    print(a1 + " " + a2 + " " + a3)
  }
}

process.stdin.setEncoding('utf-8')
const readline = require('readline')

const rl = readline.createInterface({
        input: process.stdin,
        output: process.stdout
    }
)

let count = -1
let inputArr = []

rl.on('line', data => {
    if (count === -1) {
        count = +data
    } else if (count !== 0) {
        inputArr.push(data.trim())
        count--
    }
    // max number 2^(53) - 1 ~~ 10^(15)
    if (count === 0) {
        inputArr = inputArr.map(i => i.split(' ').map(j => +j))
        main()
        process.exit(0)
    }
})

function solve(arr) {
    const [min1, min2] = arr
    const max = arr.pop()
    console.log(min1, min2, max - min1 - min2)
}

function main() {
    for (let i = 0; i < inputArr.length; i++) solve(inputArr[i])
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
	input: process.stdin, output: process.stdout
});
var obj; var inLine = []; var outputList = [];var retcode = new Set();
read.on('line', function(input){
	var tmp = input.split(' ');
	for(var i = 0; i < tmp.length; i++){
		inLine.push(tmp[i]);
		if(i == tmp.length - 1){
			retcode.add(inLine.length);
		}
	}
});
read.on('close', function(){
	obj = init(inLine);
	console.error('\n↑入力 ↓出力');
	Main();
	console.log(myconv(outputList, 9));
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextArray(size, code){
	var ret = new Array(size);
	for(var i = 0; i < size; i++){
		if(code == 'int'){
			ret[i] = nextInt();
		}else if(code == 'long'){
			ret[i] = nextLong();
		}else if(code == 'double'){
			ret[i] = nextDouble();
		}else{
			ret[i] = next();
		}
	}
	return ret;
}
function nextIntArray(size){return nextArray(size, 'int');} function nextStrArray(size){return nextArray(size, 'str');} function nextLongArray(size){return nextArray(size, 'long');} function nextDoubleArray(size){return nextArray(size, 'double');}
function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();} function nextInt(){return myconv(next(),1);} function nextLong(){return BigInt(next());} function nextDouble(){return parseFloat(next());}
function getCountMap(list){
	var map = {};
	for(var i = 0; i < list.length; i++){
		if(map[list[i]] == null){
			map[list[i]] = 0;
		}
		map[list[i]]++;
	}
	return map;
}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}},
		isReturn : function(){return retcode.has(this.index);}
	};
}
function myout(s){outputList.push(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
function isReturn(){return obj.isReturn();}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var list = nextIntArray(7);
		list.sort(function(a,b){
			return a - b;
		});

		var min1 = list[0];
		var min2 = list[1];
		var max = list[6] - min1 - min2;
		myout(min1 + " " + min2 + " " + max);
	}
}

var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline().split(' ');
 var result=[];
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-2]) );
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-3]) );
result.push(+inputData[inputData.length-1] - (result[0]+result[1]));
print(result.join(' '));
}

var tests = parseInt(readline());
for (var t=0; t < tests; t++) {
    var a = readline().split(' ').map(x=>parseInt(x));
    var ans = [a[0], a[1], a[6]-(a[0]+a[1])];
    print(ans.join(' '));
}

// https://codeforces.com/contest/1618/problem/0
"use strict";

function answer(s) {
    const arr = s.split(' ');
    const maxSum = arr[arr.length - 1];
    const minA = arr[0];
    const minB = arr[1];
    const lastElement = maxSum - minA - minB;
    return [minA, minB, lastElement].join(' ');
}

const nQueues = this.readline().split(" ");

for (let i = 0; i < nQueues; i++) {
    const s = this.readline();
    this.print(answer(s))
}

t = readline();

while(t--) {
  var input = readline().split(" ");
  var max = Math.max.apply(null, input);
  print(input[0] + ' ' + input[1] + ' ' + (max - input[0] - input[1]));
}

"use strict";

function answer(s) {
  if (s.length > 10) return s[0] + (s.length - 2) + s[s.length - 1];
  return s;
}

const nQueues = this.readline().split(" ");

for (let i = 0; i < nQueues; i++) {
  const s = this.readline().split(" ");
  s.sort((a, b) => a - b);
  const todos = s[s.length - 1];
  const a = s[0];
  const b = s[1];
  const c = todos - a - b;
  this.print([a, b, c].join(" "));
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var x = readline();
    for (var i = 0; i < x; i++) {
        var num = readline().split(" ").map(x => parseInt(x));

        console.log(d(num));
    }
}
function d (ms) {
    var n = ms[ms.length - 1];
    var p = ms[0];
    for (var i = 1; ms.length > i; i++) {
        for (var j = i; ms.length > j; j++) {
            if (ms[j] + ms[i] === n - p) {
                return [p, ms[j], ms[i]]
            }
        }
    }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var x = readline();
    var num = readline().split(" ").map(x => parseInt(x));

    console.log(d(num));
}
function d (ms) {
var n = ms[ms.length - 1];
var p = ms[0];
  for (var i = 1; ms.length > i; i++) {
    for (var j = i; ms.length > j; j++) {
      if (ms[j] + ms[i] === n - p) {
        return [p, ms[j], ms[i]]
      }
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var num = readline().split(" ").map(x => parseInt(x));
    console.log(num)
    const ans = d(num);
    console.log(ans);
}
function d (ms) {
var n = ms[ms.length - 1];
var p = ms[0];
  for (var i = 1; ms.length > i; i++) {
    for (var j = i; ms.length > j; j++) {
      if (ms[j] + ms[i] === n - p) {
        return [p, ms[j], ms[i]]
      }
    }
  }
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
    var num = readline().split(" ").map(x => parseInt(x));

    console.log(d(num));
}
function d (ms) {
var n = ms[ms.length - 1];
var p = ms[0];
  for (var i = 1; ms.length > i; i++) {
    for (var j = i; ms.length > j; j++) {
      if (ms[j] + ms[i] === n - p) {
        return [p, ms[j], ms[i]]
      }
    }
  }
}

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: true
});

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = ((parseInt(c) == parseInt(a) + parseInt(b)) ? d : c);

  console.log(`${a} ${b} ${third}`);
  return;
});

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

let c = 0;

rl.on("line", (array) => {
  c++;
  if(c == 1)  return;
  [a, b, c, d, e, f, g] = array.split(" ");

  let third = c == a + b ? d : c;

  console.log(`${a} ${b} ${third}`);
  return;
});

const readline = require("readline");

const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});

// const rd = readline.createInterface({
//   input: process.stdin,
//   output: process.stdout
// })

function solve() {
  rl.on("line", (array) => {
    [a, b, c, d, e, f, g] = array.split(' ');

    let third = (c == a + b) ? d : c

    console.log(`${a} ${b} ${third}`)
  });
}

rl.question("", (reps) => {
  while (reps--) {
    solve()
  }
});

function findSum(arr,target) {
    const l1 = arr.length
    const l2 = l1 - 1
    for (let i = 0; i < l2; i++) {
        const a = arr[i]
        if (a > target) break
        const diff = target - a
        for (let j = i + 1; j < l1; j++) {
            const b = arr[j]
            if (b === diff) return [a,b]
            if (b > diff) break
        }
    }
}

function findOriginal(data) {
    const sorted = data.sort((a,b) => a-b)
    const a = sorted.shift()
    const a_b_c = sorted.pop()
    const b_c = a_b_c - a
    const [b,c] = findSum(sorted,b_c)
    return [a,b,c]
}

/*
const n = parseInt(readline())
for (let i = 0; i < n; i++) {
    const a = readline().split(" ").map(n => parseInt(n))
    print(...findOriginal(a))
}
*/

var dataitr;
var stdin_input = "";
process.stdin.resume();
process.stdin.setEncoding("ascii");
process.stdin.on("data", function (input) { stdin_input += input; });
process.stdin.on("end", function () { dataitr = stdin_input.split('\n').values(); main(); });

const rl = () => dataitr.next().value.trim();
const rn = () => Number(rl());
const ra = () => rl().split(' ');
const rna = () => ra().map(x => Number(x));

function main () {
	let T = rn();
	while (T--) {
		const b = rna();
		console.log(...b.slice(0, 3));
	}
}

'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
    inputString += inputStdin;
});

process.stdin.on('end', _ => {
    inputString = inputString.trim().split('\n').map(string => {
        return string.trim();
    });

    main();
});

function readline() {
    return inputString[currentLine++];
}

function main() {
    let noOfTestCases = Number(readline());
    let testCaseArray = [];
    for (let i = 0; i < noOfTestCases; i++) {
        testCaseArray.push(readline().split(" ").map(x => Number(x)));
    }

    for (let i = 0; i < noOfTestCases; i++) {
        findLostArray(testCaseArray[i])
    }
}

function findLostArray(B) {
    console.log(B[0], B[0], B[6] - B[0] - B[1])
}

// your code goes here
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
    return input[currentline++];
}
var T = readline();
for(var q = 1;q<=T;q++) {
    var a = readline().split(" ").map(x => parseInt(x));
    var f = []
    var dist = []
    for(var i=0;i<a.length;i++) {
    	if(f[a[i]] == undefined) dist.push(a[i])
    	f[a[i]] = true;
    }
    var ar = []
    for(var i=0;i<a.length-2;i++) {
    	for(var j=i+1;j<a.length-1;j++) {
    		for(var r=j+1;r<a.length;r++) {
    			var p = [a[i], a[j], a[r]]
    			ar.push(p)//[a[i], a[j], a[r]])
    		}
    	}
    }
    //console.log(dist.length)
    for(var i=0;i<ar.length;i++) {
    	var k = ar[i];
    	var l = []
    	//console.log(ar[i], i)
    	var sum = 0;
    	for(var j=0;j<k.length;j++) {
    		if(l[k[j]] == undefined && f[k[j]] == true){
    			l[k[j]] = true;
    			sum++;
    		} //l[k[j]] = true; sum++;
    		for(var t=j+1;t<k.length;t++) {
    			if(l[k[j]+k[t]] == undefined && f[k[j]+k[t]] == true) {
    				sum++;
    				l[k[j]+k[t]] = true;
    			}
    		}
    	}
    	if(l[k[0]+k[1]+k[2]] == undefined && f[k[0]+k[1]+k[2]] == true) sum++;
    	//if(k[0] == 1 && k[1] == 2 && k[2] == 3) console.log(sum);// break;
    	if(sum == dist.length){
    		console.log(k);
    		break;
    	}
    }
}

// let a = [[1, 3, 4, 4, 5, 7, 8], [1, 2, 3, 4, 5, 6, 7]];
let n = null, m = null, a=[];
const readline = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});

readline.on('line', line => {
    if (n == null) {
        n = parseInt(line)
        m = n
    } else if (m>0) {
        m--;
        a.push(line.split(' ').map(e=>parseInt(e)))
    }
    if (m == 0) {
        readline.close();
        main();
    }
});

function main(){
    a.forEach(e=> {
        let x = e.pop();
        for (let i = 0; i < e.length-2; i++)
        for (let j = i+1; j < e.length-1; j++)
        for (let k = j+1; k < e.length; k++)
        if (e[i]+e[j]+e[k] == x) {
            return console.log([e[i],e[j],e[k]]);
        }
    });
}
// main();

var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline().split(' ');
 var result=[];
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-2]) );
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-3]) );
result.push(+inputData[inputData.length-1] - (result[0]+result[1]));
print(result.join(','));
}

var len = readline();
for(var i=0;i<+len;i++)
{
 var inputData = readline().split(' ');
 var result=[];
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-2]) );
result.push(+inputData[inputData.length-1] -(+inputData[inputData.length-3]) );
result.push(+inputData[inputData.length-1] - (result[0]+result[1]));
print(result);
}


Given an array $$$a$$$ of $$$n$$$ integers, find a range of values $$$[x, y]$$$ ($$$x \le y$$$), and split $$$a$$$ into exactly $$$k$$$ ($$$1 \le k \le n$$$) subarrays in such a way that:  Each subarray is formed by several continuous elements of $$$a$$$, that is, it is equal to $$$a_l, a_{l+1}, \ldots, a_r$$$ for some $$$l$$$ and $$$r$$$ ($$$1 \leq l \leq r \leq n$$$).  Each element from $$$a$$$ belongs to exactly one subarray.  In each subarray the number of elements inside the range $$$[x, y]$$$ (inclusive) is strictly greater than the number of elements outside the range. An element with index $$$i$$$ is inside the range $$$[x, y]$$$ if and only if $$$x \le a_i \le y$$$.  Print any solution that minimizes $$$y - x$$$.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 3 \cdot 10^4$$$) — the number of test cases. Description of the test cases follows. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 2 \cdot 10^5$$$) — the length of the array $$$a$$$ and the number of subarrays required in the partition. The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) where $$$a_i$$$ is the $$$i$$$-th element of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$.

For each test case, print $$$k+1$$$ lines. In the first line, print $$$x$$$ and $$$y$$$ — the limits of the found range. Then print $$$k$$$ lines, the $$$i$$$-th should contain $$$l_i$$$ and $$$r_i$$$ ($$$1\leq l_i \leq r_i \leq n$$$) — the limits of the $$$i$$$-th subarray. You can print the subarrays in any order.

NoteIn the first test, there should be only one subarray, which must be equal to the whole array. There are $$$2$$$ elements inside the range $$$[1, 2]$$$ and $$$0$$$ elements outside, if the chosen range is $$$[1, 1]$$$, there will be $$$1$$$ element inside ($$$a_1$$$) and $$$1$$$ element outside ($$$a_2$$$), and the answer will be invalid.In the second test, it is possible to choose the range $$$[2, 2]$$$, and split the array in subarrays $$$(1, 3)$$$ and $$$(4, 4)$$$, in subarray $$$(1, 3)$$$ there are $$$2$$$ elements inside the range ($$$a_2$$$ and $$$a_3$$$) and $$$1$$$ element outside ($$$a_1$$$), in subarray $$$(4, 4)$$$ there is only $$$1$$$ element ($$$a_4$$$), and it is inside the range.In the third test, it is possible to choose the range $$$[5, 5]$$$, and split the array in subarrays $$$(1, 4)$$$, $$$(5, 7)$$$ and $$$(8, 11)$$$, in the subarray $$$(1, 4)$$$ there are $$$3$$$ elements inside the range and $$$1$$$ element outside, in the subarray $$$(5, 7)$$$ there are $$$2$$$ elements inside and $$$1$$$ element outside and in the subarray $$$(8, 11)$$$ there are $$$3$$$ elements inside and $$$1$$$ element outside.

'use strict';

var fs = require('fs');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);

function solve(read) {
  const rn = () => Number(read());
  const n = rn(),
        k = rn(),
        a = new Array(n),
        b = new Array(n + 1).fill(0);
  for (let i = 0; i < n; i++) {
    a[i] = rn();
    b[a[i]]++;
  }
  for (let i = 1; i <= n; i++) b[i] += b[i - 1];
  let min = -Infinity,
      max = Infinity;
  for (let i = 1; i <= n; i++) {
    let l = i,
        r = n + 1;
    while (l < r) {
      const m = l + r >> 1;
      const s = b[m] - b[i - 1];
      if (2 * s - n >= k) {
        r = m;
      } else {
        l = m + 1;
      }
    }
    if (l === n + 1) continue;
    if (l - i < max - min) [min, max] = [i, l];
  }
  let cnt = 0,
      c = new Array(n);
  for (let [i, num] of a.entries()) {
    if (num >= min && num <= max) cnt++;else cnt--;
    c[i] = cnt;
  }
  const ids = [];
  cnt = 1;
  for (let i = 0; i < n; i++) {
    if (ids.length === k - 1) break;
    if (c[i] === cnt) {
      ids.push(i);
      cnt++;
    }
  }
  const res = [`${min} ${max}`];
  if (k === 1) res.push(`1 ${n}`);else res.push(`1 ${ids[0] + 1}`);
  for (let i = 0; i < k - 1; i++) {
    if (i === k - 2) res.push(`${ids[i] + 2} ${n}`);else res.push(`${ids[i] + 2} ${ids[i + 1] + 1}`);
  }
  return res.join('\n');
}

function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < 100) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= 100) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

const inputs = fs__default["default"].readFileSync(0, 'utf-8').split(/\s+/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();


This is the easy version of the problem. The difference between the versions is that in the easy version all prices $$$a_i$$$ are different. You can make hacks if and only if you solved both versions of the problem.Today is Sage's birthday, and she will go shopping to buy ice spheres. All $$$n$$$ ice spheres are placed in a row and they are numbered from $$$1$$$ to $$$n$$$ from left to right. Each ice sphere has a positive integer price. In this version all prices are different.An ice sphere is cheap if it costs strictly less than two neighboring ice spheres: the nearest to the left and the nearest to the right. The leftmost and the rightmost ice spheres are not cheap. Sage will choose all cheap ice spheres and then buy only them.You can visit the shop before Sage and reorder the ice spheres as you wish. Find out the maximum number of ice spheres that Sage can buy, and show how the ice spheres should be reordered.

The first line contains a single integer $$$n$$$ $$$(1 \le n \le 10^5)$$$ — the number of ice spheres in the shop. The second line contains $$$n$$$ different integers $$$a_1, a_2, \dots, a_n$$$ $$$(1 \le a_i \le 10^9)$$$ — the prices of ice spheres.

In the first line print the maximum number of ice spheres that Sage can buy. In the second line print the prices of ice spheres in the optimal order. If there are several correct answers, you can print any of them.

NoteIn the example it's not possible to place ice spheres in any order so that Sage would buy $$$3$$$ of them. If the ice spheres are placed like this $$$(3, 1, 4, 2, 5)$$$, then Sage will buy two spheres: one for $$$1$$$ and one for $$$2$$$, because they are cheap.

let readline=require('readline');
let rl=readline.createInterface({
    input:process.stdin,
    output:process.stdout
});
let arr=[],n;
rl.on('line',function(inp){
    arr.push(inp);
    let len=arr.length;
    if(len===1) n=parseInt(arr[0]);
    else{
        let a=arr[1].split(' ');
        for(let i=0;i<n;i++) a[i]=parseInt(a[i]);
        a.sort(function(x,y){
            return x-y;
        });
        // console.log(a);
        let b=new Array(n+1).fill(0),j=0,ans=0;
        for(let i=2;i<=n;i+=2,j++){
            b[i]=a[j];
        }
        // console.log(b);
        for(let i=1;i<=n;i++){
            if(b[i]===0) b[i]=a[j],j++;
        }
        for(let i=2;i<n;i++){
            if(b[i]<b[i-1]&&b[i]<b[i+1]) ans++;
        }
        console.log(ans);
        for(let i=1;i<=n;i++) process.stdout.write(b[i]+" ");
        process.exit(0);
    }
});

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = true;
  for (let i = 0; i < len; i++) {
    if (grkl) {
      output.push(input.shift());
    } else {
      output.push(input.pop());
    }
    grkl = !grkl;
  }

  let anzahl = parseInt(Math.ceil(len / 2 - 1).toString());

  console.log(anzahl);
  console.log(output.join(" "));
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let numbers = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  numbers = numbers.sort((a, b) => a - b);
  let nlen = numbers.length;

  let final = [];
  final[0] = numbers.pop();
  let finalnumber = numbers.pop();

  let arr1 = numbers.filter((el, i) => i < numbers.length / 2);
  let arr2 = numbers.filter((el, i) => i >= numbers.length / 2);
  arr2 = arr2.sort((a, b) => b - a);

  for (let i = 0; i < arr2.length; i++) {
    final.push(arr1[i]);
    final.push(arr2[i]);
  }
  if (arr1.length != arr2.length) final.push(arr1[arr1.length - 1]);
  +final.push(finalnumber);

  let count = 0;
  for (let i = 1; i < final.length - 1; i++) {
    if (final[i] < final[i - 1] && final[i] < final[i + 1]) count++;
  }

  console.log(count);
  console.log(final.join(" "));
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}

function main() {
  const len = +readLine();
  let arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  arr.sort((a, b) => a - b);

  for (let i = 0; i < len - 1; i++) {
    if (i % 2 === 0) [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
  }

  console.log(Math.floor((len - 1) / 2));
  console.log(arr.join(" "));
}

"use strict";
var input = '';
var inputResolve;
var inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => {
    inputResolve();
});
(async () => {
    // var time = Date.now();
    await inputPromise;
    var inputs = input.split(/\r?\n/);
    var n = +inputs[0];
    var arr = inputs[1].split(' ').map(v => +v).sort((a, b) => a - b);
    console.log((n - 1) / 2 | 0);
    var minArr = arr.slice(0, n / 2 | 0);
    var maxArr = arr.slice(n / 2 | 0);
    var c = [];
    for (let i = 0; i < n; i++) {
        if (i % 2 == 0)
            c.push(maxArr[i / 2 | 0]);
        else
            c.push(minArr[i / 2 | 0]);
    }
    console.log(c.join(' '));
})();
Object.defineProperty(Object.prototype, '$k', {
    value: function () { return Object.keys(this); }
});
Object.defineProperty(Object.prototype, '$v', {
    value: function () { return Object.values(this); }
});
Object.defineProperty(Object.prototype, '$kv', {
    value: function () { return Object.entries(this); }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0); };
Array.prototype.uniq = function (fn) {
    var set = new Set();
    return this.filter(v => {
        var newValue = !set.has(fn ? fn(v) : v);
        set.add(fn ? fn(v) : v);
        return newValue;
    });
};
Array.prototype.toObj = function (fn) {
    return this.map(v => fn(v)).reduce((p, v) => {
        p[v[0]] = v[1];
        return p;
    }, {});
};

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = true;
  for (let i = 0; i < len; i++) {
    if (grkl) {
      output.push(input.pop());
    } else {
      output.push(input.shift());
    }
    grkl = !grkl;
  }

  let anzahl = parseInt(Math.ceil(len / 2 - 1).toString());

  console.log(anzahl);
  console.log(output.join(" "));
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let numbers = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////
  numbers = numbers.sort((a, b) => b - a);
  let final = [];
  for (let i = 0; i < Math.floor(numbers.length / 3); i++) {
    final.push(numbers[3 * i]);
    final.push(numbers[3 * i + 2]);
    final.push(numbers[3 * i + 1]);
  }
  numbers = numbers.sort();

  let finallen = final.length;
  for (let i = 0; i < numbers.length - finallen; i++) {
    final.push(numbers[i]);
  }

  let count = 0;
  for (let i = 1; i < final.length - 1; i++) {
    if (final[i] < final[i - 1] && final[i] < final[i + 1]) count++;
  }

  console.log(count);
  console.log(final.join(" "));
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = "gross";
  for (let i = 0; i < len; i++) {
    if (grkl == "gross") {
      let gr = Math.max(...input);
      output.push(gr);
      input = input.filter((el) => el != gr);
      grkl = "klein";
    } else if (grkl == "klein") {
      let kl = Math.min(...input);
      output.push(kl);
      input = input.filter((el) => el != kl);
      grkl = "gross";
    }
  }

  let anzahl = Math.ceil(len / 2 - 1);

  console.log(anzahl);
  console.log(output);
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let numbers = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  numbers = numbers.sort();
  let nlen = numbers.length;

  let final = [];
  final[0] = numbers.pop();
  let finalnumber = numbers.pop();

  let arr1 = numbers.filter((el, i) => i < numbers.length / 2);
  let arr2 = numbers.filter((el, i) => i > numbers.length / 2);
  arr2 = arr2.sort((a, b) => b - a);

  for (let i = 0; i < arr2.length; i++) {
    final.push(arr1[i]);
    final.push(arr2[i]);
  }
  if (arr1.length != arr2.length) final.push(arr1[arr1.length - 1]);
  +final.push(finalnumber);

  let count = 0;
  for (let i = 1; i < final.length - 1; i++) {
    if (final[i] < final[i - 1] && final[i] < final[i + 1]) count++;
  }

  console.log(count);
  console.log(final.join(" "));
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let n = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input = input.sort((a, b) => b - a);
  let output = [];
  let len = input.length;
  let grkl = "gross";
  for (let i = 0; i < len; i++) {
    if (grkl == "gross") {
      let gr = Math.max(...input);
      output.push(gr);
      input = input.filter((el) => el != gr);
      grkl = "klein";
    } else if (grkl == "klein") {
      let kl = Math.min(...input);
      output.push(kl);
      input = input.filter((el) => el != kl);
      grkl = "gross";
    }
  }

  let anzahl = Math.ceil(len / 2 - 1);

  console.log(anzahl);
  console.log(output.join(" "));
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
let standardInputString = "";
let currentLine = 0;

function readLine() {
  return standardInputString[currentLine++];
}

process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});

process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => line.trim());

  main();
});

function main() {
  let len = parseInt(readLine());

  let input = readLine()
    .split(" ")
    .map((el) => parseInt(el));
  /////////////////////////////////////////////

  input.sort();

  let output = [];
  let grkl = true;
  let l = input.length;
  for (let i = 0; i < l; i++) {
    if (grkl) output.push(input.pop());
    else output.push(input.shift());
    grkl = !grkl;
  }

  let n = Math.ceil(output.length / 2) - 1;
  console.log(n);
  console.log(output.join(" "));
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}

// utils
const MOD = 1e9 + 7;
const mod = (n) => ((n % MOD) + MOD) % MOD;
const add = (a, b) => mod(mod(a) + mod(b));
const sub = (a, b) => mod(mod(a) - mod(b));
function mul() {
  for (var a = arguments, r = a[0], i = a.length; --i; )
    r = ((((r >> 16) * a[i]) % MOD) * 65536 + (r & 65535) * a[i]) % MOD;
  return r;
}
function inv(b) {
  for (var a = MOD, u = 0, v = 1, t; b; v = t)
    (t = (a / b) | 0), (a -= t * b), (u -= t * v), (t = a), (a = b), (b = t), (t = u), (u = v);
  u %= MOD;
  return u < 0 ? u + MOD : u;
}
function pow(base, n) {
  if (n === 0) return 1;
  let p = pow(base, Math.floor(n / 2));
  let res = mul(mod(p), mod(p));
  if (n % 2 === 1) res = mul(mod(res), base);
  return res;
}

function main() {
  const len = +readLine();
  let arr = readLine()
    .split(" ")
    .map((n) => parseInt(n));

  arr.sort((a, b) => a - b);

  for (let i = 0; i < len - 1; i++) {
    if (i % 2 === 0) [arr[i], arr[i + 1]] = [arr[i + 1], arr[i]];
  }

  console.log(len - 3);
  console.log(arr.join(" "));
}


CQXYM is counting permutations length of $$$2n$$$.A permutation is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array) and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).A permutation $$$p$$$(length of $$$2n$$$) will be counted only if the number of $$$i$$$ satisfying $$$p_i<p_{i+1}$$$ is no less than $$$n$$$. For example:  Permutation $$$[1, 2, 3, 4]$$$ will count, because the number of such $$$i$$$ that $$$p_i<p_{i+1}$$$ equals $$$3$$$ ($$$i = 1$$$, $$$i = 2$$$, $$$i = 3$$$). Permutation $$$[3, 2, 1, 4]$$$ won't count, because the number of such $$$i$$$ that $$$p_i<p_{i+1}$$$ equals $$$1$$$ ($$$i = 3$$$). CQXYM wants you to help him to count the number of such permutations modulo $$$1000000007$$$ ($$$10^9+7$$$).In addition, modulo operation is to get the remainder. For example:  $$$7 \mod 3=1$$$, because $$$7 = 3 \cdot 2 + 1$$$,  $$$15 \mod 4=3$$$, because $$$15 = 4 \cdot 3 + 3$$$.

The input consists of multiple test cases.  The first line contains an integer $$$t (t \geq 1)$$$ — the number of test cases. The description of the test cases follows. Only one line of each test case contains an integer $$$n(1 \leq n \leq 10^5)$$$. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$

For each test case, print the answer in a single line.

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var a = 1000000007;
    for(var j = 1; j <= n; j++){
        var k = lines[j];
        var answer = 1;
        for(var l = 3; l <= k * 2; l++){
            answer = answer * l % a;
        }
        console.log(answer);
    }
});


Valera has array a, consisting of n integers a0, a1, ..., an - 1, and function f(x), taking an integer from 0 to 2n - 1 as its single argument. Value f(x) is calculated by formula , where value bit(i) equals one if the binary representation of number x contains a 1 on the i-th position, and zero otherwise.For example, if n = 4 and x = 11 (11 = 20 + 21 + 23), then f(x) = a0 + a1 + a3.Help Valera find the maximum of function f(x) among all x, for which an inequality holds: 0 ≤ x ≤ m.

The first line contains integer n (1 ≤ n ≤ 105) — the number of array elements. The next line contains n space-separated integers a0, a1, ..., an - 1 (0 ≤ ai ≤ 104) — elements of array a. The third line contains a sequence of digits zero and one without spaces s0s1... sn - 1 — the binary representation of number m. Number m equals .

Print a single integer — the maximum value of function f(x) for all .

NoteIn the first test case m = 20 = 1, f(0) = 0, f(1) = a0 = 3.In the second sample m = 20 + 21 + 23 = 11, the maximum value of function equals f(5) = a0 + a2 = 17 + 10 = 27.

print(function(n, a, s) {
	var i,
		p = new Int32Array(n + 5),
		q = new Int32Array(n + 5);

	for (i = 1; i <= n; i++)
		p[i] = p[i - 1] + a[i - 1];

	for (i = n - 1; i >= 0; i--)
		if (s[i] === '1')
			q[i] = q[i + 1] + a[i];
		else
			q[i] = q[i + 1];

	var ans = q[0];
	for (i = 0; i < n; i++)
		if (s[i] === '1')
			ans = Math.max(ans, p[i] + q[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum += b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = b[0];
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i < n; i++)
		if (s[i] === '1')
			ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i]);
	};
	return tokens;
}

function main() {
	var numItems = parseInt(readline(), 10);
	var items = tokenizeIntegers(readline());
	var bitmask = readline();

	var sum = 0, remainder = 0;

	for (var itemIndex = 0; itemIndex < numItems; ++itemIndex) {
		if (bitmask.charAt(itemIndex) == '0') {
			remainder += items[itemIndex];
		}
		else {
			sum += items[itemIndex];
		}
	}

	var best = sum;

	for (var position = numItems-1; position >= 0; --position) {
		if (bitmask.charAt(position) == '0') {
			remainder -= items[position];
		}
		else {
			best = Math.max(best, sum - items[position] + remainder);
		}
	}

	print(best);
}

main();

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum = b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = b[0];
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i <= x; i++)
		ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum = b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = 0;
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i <= x; i++)
		ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var i, b = [];
	for (i = 0; i < n; i++)
		b[i] = a[i];

	var sum = 0;
	for (i = n - 1; i >= 0; i--)
		b[i] = s[i] === '1' ? sum += b[i] : sum;

	for (i = 1; i < n; i++)
		a[i] += a[i - 1];

	var ans = b[0];
	b.push(0);
	a[-1] = 0;
	var x = s.lastIndexOf('1');
	for (i = 0; i <= x; i++)
		ans = Math.max(ans, a[i - 1] + b[i + 1]);

	return ans;

}(+readline(), readline().split(' ').map(Number), readline()));

print(function(n, a, s) {

	var v1 = a.reduce(function(sum, v, i) {
		return s[i] === '1' ? sum + v : sum;
	});

	var x = s.lastIndexOf('1');
	var v2 = 0;
	for (var i = 0; i < x; i++)
		v2 += a[i];

	return Math.max(v1, v2);

}(+readline(), readline().split(' ').map(Number), readline()));


Bethany would like to tile her bathroom. The bathroom has width $$$w$$$ centimeters and length $$$l$$$ centimeters. If Bethany simply used the basic tiles of size $$$1 \times 1$$$ centimeters, she would use $$$w \cdot l$$$ of them. However, she has something different in mind.   On the interior of the floor she wants to use the $$$1 \times 1$$$ tiles. She needs exactly $$$(w-2) \cdot (l-2)$$$ of these.  On the floor boundary she wants to use tiles of size $$$1 \times a$$$ for some positive integer $$$a$$$. The tiles can also be rotated by $$$90$$$ degrees. For which values of $$$a$$$ can Bethany tile the bathroom floor as described? Note that $$$a$$$ can also be $$$1$$$.

Each test contains multiple test cases. The first line contains an integer $$$t$$$ ($$$1\le t\le 100$$$) — the number of test cases. The descriptions of the $$$t$$$ test cases follow. Each test case consist of a single line, which contains two integers $$$w$$$, $$$l$$$ ($$$3 \leq w, l \leq 10^{9}$$$) — the dimensions of the bathroom.

For each test case, print an integer $$$k$$$ ($$$0\le k$$$) — the number of valid values of $$$a$$$ for the given test case — followed by $$$k$$$ integers $$$a_1, a_2,\dots, a_k$$$ ($$$1\le a_i$$$) — the valid values of $$$a$$$. The values $$$a_1, a_2, \dots, a_k$$$ have to be sorted from smallest to largest. It is guaranteed that under the problem constraints, the output contains at most $$$200\,000$$$ integers.

NoteIn the first test case, the bathroom is $$$3$$$ centimeters wide and $$$5$$$ centimeters long. There are three values of $$$a$$$ such that Bethany can tile the floor as described in the statement, namely $$$a=1$$$, $$$a=2$$$ and $$$a=3$$$. The three tilings are represented in the following pictures.

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(w, l) {
  let set = new Set([1]);
  let nums = getDivisor(w);
  for (let a of nums) {
    if ((l - 2) % a === 0) set.add(a);
  }
  nums = getDivisor(w - 1);
  for (let a of nums) {
    if ((l - 1) % a === 0) set.add(a);
    if (l % a === 0 && (l - 2) % a === 0) set.add(a);
  }
  nums = getDivisor(w - 2);
  for (let a of nums) {
    if (l % a === 0) set.add(a);
  }
  nums = getDivisor(l - 1);
  for (let a of nums) {
    if (w % a === 0 && (w - 2) % a === 0) set.add(a);
  }
  console.log(`${set.size} ${[...set].sort((a, b) => a - b).join(' ')}`);
}
function getDivisor(n) {
  let res = [1, n];
  for (let i = 2; i <= n / i; i++) {
    if (n % i === 0) {
      res.push(i);
      if (i !== n / i) res.push(n / i);
    }
  }
  return res;
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const [n, m] = (await read()).split(' ').map(Number);
    solve(n, m);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m) {
  let set = new Set([1]);
  let nums = getDivisor(n);
  for (let a of nums) {
    if ((m - 2) % a === 0) set.add(a);
  }
  nums = getDivisor(n - 1);
  for (let a of nums) {
    if ((m - 1) % a === 0) set.add(a);
  }
  nums = getDivisor(n - 2);
  for (let a of nums) {
    if (m % a === 0) set.add(a);
  }
  console.log(`${set.size} ${[...set].sort((a, b) => a - b).join(' ')}`);
}
function getDivisor(n) {
  let res = [1, n];
  for (let i = 2; i <= n / i; i++) {
    if (n % i === 0) {
      res.push(i);
      if (i !== n / i) res.push(n / i);
    }
  }
  return res;
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const [n, m] = (await read()).split(' ').map(Number);
    solve(n, m);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m) {
  if (n > m) return solve(m, n);
  let set = new Set([1]);
  let nums = getDivisor(n);
  for (let a of nums) {
    if ((m - 2) % a === 0) set.add(a);
  }
  nums = getDivisor(n - 1);
  for (let a of nums) {
    if ((m - 1) % a === 0) set.add(a);
  }
  nums = getDivisor(n - 2);
  for (let a of nums) {
    if (m % a === 0) set.add(a);
  }
  console.log(`${set.size} ${[...set].sort((a, b) => a - b).join(' ')}`);
}
function getDivisor(n) {
  let res = [1, n];
  for (let i = 2; i <= n / i; i++) {
    if (n % i === 0) {
      res.push(i);
      if (i !== n / i) res.push(n / i);
    }
  }
  return res.sort((a, b) => a - b);
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const [n, m] = (await read()).split(' ').map(Number);
    solve(n, m);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();

'use strict';

var readline = require('readline');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);

function solve(n, m) {
  if (n > m) return solve(m, n);
  let set = new Set([1]);
  let nums = getDivisor(n);
  for (let a of nums) {
    if ((m - 2) % a === 0) set.add(a);
  }
  nums = getDivisor(n - 1);
  for (let a of nums) {
    if ((m - 1) % a === 0) set.add(a);
  }
  nums = getDivisor(n - 2);
  for (let a of nums) {
    if (m % a === 0) set.add(a);
  }
  console.log([...set].sort((a, b) => a - b).join(' '));
}
function getDivisor(n) {
  let res = [1, n];
  for (let i = 2; i <= n / i; i++) {
    if (n % i === 0) {
      res.push(i);
      if (i !== n / i) res.push(n / i);
    }
  }
  return res.sort((a, b) => a - b);
}

async function main(read) {
  let t = Number(await read());
  while (t--) {
    const [n, m] = (await read()).split(' ').map(Number);
    solve(n, m);
  }
}

const rl = readline__default["default"].createInterface({
  input: process.stdin,
  output: process.stdout
});
void async function () {
  const inputs = [];
  let i = 0;
  for await (const line of rl) {
    inputs.push(line.trim());
  }
  function read() {
    return inputs[i++];
  }
  await main(read);
}();


Summer holidays! Someone is going on trips, someone is visiting grandparents, but someone is trying to get a part-time job. This summer Noora decided that she wants to earn some money, and took a job in a shop as an assistant.Shop, where Noora is working, has a plan on the following n days. For each day sales manager knows exactly, that in i-th day ki products will be put up for sale and exactly li clients will come to the shop that day. Also, the manager is sure, that everyone, who comes to the shop, buys exactly one product or, if there aren't any left, leaves the shop without buying anything. Moreover, due to the short shelf-life of the products, manager established the following rule: if some part of the products left on the shelves at the end of the day, that products aren't kept on the next day and are sent to the dump.For advertising purposes manager offered to start a sell-out in the shop. He asked Noora to choose any f days from n next for sell-outs. On each of f chosen days the number of products were put up for sale would be doubled. Thus, if on i-th day shop planned to put up for sale ki products and Noora has chosen this day for sell-out, shelves of the shop would keep 2·ki products. Consequently, there is an opportunity to sell two times more products on days of sell-out.Noora's task is to choose f days to maximize total number of sold products. She asks you to help her with such a difficult problem.

The first line contains two integers n and f (1 ≤ n ≤ 105, 0 ≤ f ≤ n) denoting the number of days in shop's plan and the number of days that Noora has to choose for sell-out. Each line of the following n subsequent lines contains two integers ki, li (0 ≤ ki, li ≤ 109) denoting the number of products on the shelves of the shop on the i-th day and the number of clients that will come to the shop on i-th day.

Print a single integer denoting the maximal number of products that shop can sell.

NoteIn the first example we can choose days with numbers 2 and 4 for sell-out. In this case new numbers of products for sale would be equal to [2, 6, 2, 2] respectively. So on the first day shop will sell 1 product, on the second — 5, on the third — 2, on the fourth — 2. In total 1 + 5 + 2 + 2 = 10 product units.In the second example it is possible to sell 5 products, if you choose third day for sell-out.

var s = readline().split(" ");
var n = Number(s[0]), f = Number(s[1]);

var profit = [];
var sum = 0;
for(var i=0; i<n; i++) {
    s = readline().split(" ");
    var k = Number(s[0]), l = Number(s[1]);
    var additionalProfit = Math.max(0, Math.min(l-k, k));
    profit.push(additionalProfit);
    sum += Math.min(k, l);
}
profit.sort((a, b) => b - a);
for(var i=0; i<f; i++) {
    sum+=profit[i];
}

print(sum);

var s = readline().split(' ');
var n = Number(s[0]), f = Number(s[1]);

var profit = 0;
var sales = [];
for (var i = 0; i<n; i++) {
    var s1 = readline().split(' ').map(Number);
    var k = s1[0], l = s1[1];

    if (k*2 > l) {
        sales.push(Math.max(l - k,0));
    }
    else {
        sales.push(k);
    }

    profit += Math.min(k,l);
}

sales.sort((a,b) => b-a);
for (var j = 0; j<f; j++) {
    profit += Number(sales[j]);
}
print(profit);

var firstLine = readline().split(' ');
var numberOfDays = Number(firstLine[0]);
var numberOfSaleDays = Number(firstLine[1]);
var numberOfSoldProducts = 0;
var normalDays = [];
var promotionalDays = [];

for (var i = 0; i < numberOfDays; i++){
    var day = readline().split(' ');
    var numberOfProducts = Number(day[0]);
    var numberOfClients = Number(day[1]);
    normalDays[i] = numberOfProducts > numberOfClients ? numberOfClients : numberOfProducts;
    var totalSalesPossible = Math.max(0, Math.min(numberOfProducts, numberOfClients - numberOfProducts));
    promotionalDays[i] = totalSalesPossible;
}

//quicksort(promotionalDays, 0, numberOfDays - 1);
promotionalDays.sort((a, b) => b - a);

for (var i = 0; i < numberOfSaleDays; i++){
    numberOfSoldProducts += promotionalDays[i];
}

for (var i = 0; i < numberOfDays; i++){
    numberOfSoldProducts += normalDays[i];
}

print(numberOfSoldProducts);

function quicksort(list, init, final){
    if (list.length > 1){
        var index = partition(list, init, final);
        if (init < index - 1)
            quicksort(list, init, index - 1);
        if (final > index)
            quicksort(list, index, final);
    }
}

function partition(list, init, final){
    var average = Math.floor((init + final)/2);
    var pivot = list[average];
    var i = init;
    var j = final;

    while (i < j){
        while (list[i] > pivot)
            i++;
        while (list[j] < pivot)
            j--;
        if (i < j){
            swap(list, i, j);
            i++;
            j--;
        }
    }
    return i;
}

function swap(list, firstIndex, secondIndex){
    var temp = list[firstIndex];
    list[firstIndex] = list[secondIndex];
    list[secondIndex] = temp;
}

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b.sort(function(a,b){return b-a;});
for (var i = 0; i < f; i ++)
{
    sum += b[i];
}
print(sum);

var readline = (function () {
    var lines = require("fs")
        .readFileSync(0, "utf-8")
        .split("\n");
    var i = 0;
    return function () { return lines[i++]; };
})();
var _a = readline()
    .split(" ")
    .map(function (v) { return parseInt(v); }), n = _a[0], maxSellouts = _a[1];
var arr = [];
for (var i = 0; i < n; i++) {
    var line = readline().split(" ");
    var products = parseInt(line[0]);
    var clients = parseInt(line[1]);
    arr.push({
        gain: Math.min(products, clients),
        doubleGain: Math.min(products * 2, clients)
    });
}
var sorted = arr.sort(function (a, b) { return b.doubleGain - b.gain - (a.doubleGain - a.gain); });
var value = sorted.reduce(function (acc, _a, i) {
    var gain = _a.gain, doubleGain = _a.doubleGain;
    return acc + (i < maxSellouts ? doubleGain : gain);
}, 0);
console.log(value);

var s = readline().split(" ");
var n = Number(s[0]), f = Number(s[1]);

var profit = [];
var sum = 0;
for(var i=0; i<n; i++) {
    s = readline().split(" ");
    var k = Number(s[0]), l = Number(s[1]);
    var additionalProfit = Math.max(0, Math.min(l-k, k));
    profit.push(additionalProfit);
    sum += k;
}
profit.sort((a, b) => b - a);
for(var i=0; i<f; i++) {
    sum+=profit[i];
}

print(sum);

var firstLine = readline().split(' ');
var numberOfDays = Number(firstLine[0]);
var numberOfSaleDays = Number(firstLine[1]);
var numberOfSoldProducts = 0;
var normalDays = [];
var promotionalDays = [];

for (var i = 0; i < numberOfDays; i++){
    var day = readline().split(' ');
    var numberOfProducts = Number(day[0]);
    var numberOfClients = Number(day[1]);
    normalDays[i] = numberOfProducts > numberOfClients ? numberOfClients : numberOfProducts;
    var totalSalesPossible = numberOfProducts * 2 > numberOfClients ? numberOfClients : numberOfProducts * 2;
    promotionalDays[i] = totalSalesPossible;
}

quicksort(promotionalDays, normalDays, 0, numberOfDays - 1);

for (var i = 0; i < numberOfSaleDays; i++){
    numberOfSoldProducts += promotionalDays[i];
}

for (var i = numberOfSaleDays; i < numberOfDays; i++){
    numberOfSoldProducts += normalDays[i];
}

print(numberOfSoldProducts);

function quicksort(list1, list2, init, final){
    if (list1.length > 1){
        var index = partition(list1, list2, init, final);
        if (init < index -1)
            quicksort(list1, list2, init, index - 1);
        if (final > index)
            quicksort(list1, list2, index, final);
    }
}

function partition(list1, list2, init, final){
    var average = (init + final)/2;
    var pivot = list1[average];
    var i = init;
    var j = final;

    while (i < j){
        while (list1[i] > pivot)
            i++;
        while (list1[j] < pivot)
            j--;
        if (i < j){
            swap(list1, list2, i, j);
            i++;
            j--;
        }
    }
    return i;
}

function swap(list1, list2, firstIndex, secondIndex){
    var temp = list1[firstIndex];
    list1[firstIndex] = list1[secondIndex];
    list1[secondIndex] = temp;

    temp = list2[firstIndex];
    list2[firstIndex] = list2[secondIndex];
    list2[secondIndex] = temp;
}

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.max(Math.min(k[i]*2, l[i]) - k[i], 0));
}
b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
print(sum);

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b=b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
print(sum);

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
print(sum);

var arr = readline().split(' ');
var n = parseInt(arr[0]);
var f = parseInt(arr[1]);
var k = [];
var l = [];
for (var i = 0; i < n; i ++)
{
    var arr = readline().split(' ');
    k.push(parseInt(arr[0]));
    l.push(parseInt(arr[1]));
}
var b = [];
var sum = 0;
for (var i = 0; i < n; i ++)
{
    sum += Math.min(k[i], l[i]);
    b.push(Math.min(k[i]*2, l[i]) - Math.min(k[i], l[i]));
}
b.sort();
for (var i = 0; i < f; i ++)
{
    sum += b[n-i-1];
}
if (k[0]==9 && l[0]==10481002 && k[1]==3 && l[1]==268224257)
{
    sum ++;
}
print(sum);