A ticket is a string consisting of six digits. A ticket is considered lucky if the sum of the first three digits is equal to the sum of the last three digits. Given a ticket, output if it is lucky or not. Note that a ticket can have leading zeroes.

The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of testcases. The description of each test consists of one line containing one string consisting of six digits.

Output $$$t$$$ lines, each of which contains the answer to the corresponding test case. Output "YES" if the given ticket is lucky, and "NO" otherwise. You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).

NoteIn the first test case, the sum of the first three digits is $$$2 + 1 + 3 = 6$$$ and the sum of the last three digits is $$$1 + 3 + 2 = 6$$$, they are equal so the answer is "YES".In the second test case, the sum of the first three digits is $$$9 + 7 + 3 = 19$$$ and the sum of the last three digits is $$$8 + 9 + 4 = 21$$$, they are not equal so the answer is "NO".In the third test case, the sum of the first three digits is $$$0 + 4 + 5 = 9$$$ and the sum of the last three digits is $$$2 + 0 + 7 = 9$$$, they are equal so the answer is "YES".

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var a = lines[i].split('').map(Number);
        var x = 0;
        var y = 0;
        for(j = 0; j < 6; j++){
            if(j >= 3){
                x += a[j];
            }else{
                y += a[j];
            }
        }
        console.log(x == y ? 'YES' : 'NO');
    }
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var n = lines[0];
    var e = 0;
    for(j = 1; j <= n; j++){
        var k = lines[j].split('').map(Number);
        var a = 0;
        var b = 0;
        for(i = 0; i < 6; i++){
            if(i >= 3){
                a += k[i];
            }else{
                b += k[i];
            }
        }
        if(a == b){
            console.log('YES');
        }else{
            console.log('NO');
        }
    }
});

const { createInterface } = require('readline');
/*
import { createWriteStream, createReadStream } from 'fs';
import { format } from 'util';

const log_file = createWriteStream('output.txt', { flags: 'w' }
);
const log_stdout = process.stdout;
console.log = function (d) {
  log_file.write(format(d) + '\n');
  log_stdout.write(format(d) + '\n');
};
const fileStream = createReadStream('input.txt');
*/
function main() {
  const readline = createInterface({
    input: process.stdin,
    output: process.stdout
  });
  let lineNb = 0;
  let n;
  let t = [];
  readline.on('line', line => {
    if (!lineNb)
      n = parseInt(line);
    lineNb && t.push(line);
    if (lineNb === n) {
      for (let i = 0; i < n; i++) {
        let s = Array.from(t[i]).map(i => Number(i));
        console.log(s[0] + s[1] + s[2] === s[3] + s[4] + s[5] ? "YES" : "NO");
      }
      readline.close();
    }
    lineNb++;
  });
  // let { n, t } = await processLineByLine();
}

main()

const main = (input) => {
  input = input.split("\n");
  const t = parseInt(input[0]);

  for (let i = 0; i < t; i++) {
    const digits = input[i + 1];
    const head = digits
      .substring(0, 3)
      .split("")
      .map(Number)
      .reduce((a, b) => a + b, 0);
    const tail = digits
      .substring(3, 6)
      .split("")
      .map(Number)
      .reduce((a, b) => a + b, 0);

    console.log(head === tail ? "YES" : "NO");
  }
};

main(require("fs").readFileSync(0, "utf8"));

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];

    for(j = 1; j <= n; j++){
        var a = lines[j].split('').map(Number)
        if(a[0] + a[1] + a[2] == a[3] + a[4] + a[5]){
            console.log('YES')
        }else{
            console.log('NO')
        }
    }

});

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const s = readLine();

        const res = MY_FUNC(s);

        console.log(res)
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

function MY_FUNC(s){
    ans = 'YES';
    a = 0;
    b = 0;
    for(let i = 0 ; i < s.length; i++){
        if(i < 3){
            a += parseInt(s[i]);
        } else {
            b += parseInt(s[i]);
        }
    }
   a == b ? ans = 'YES' : ans = 'NO';
    return ans;
}

'use strict';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
let [inputString, currentLine] = ['', 0];
process.stdin.on('data', inputStdin => inputString += inputStdin);
process.stdin.on('end', _ => {
  inputString = inputString.trim().split('\n').map(string => string.trim());
  main();
});
const input = () => inputString[currentLine++];

const main = () => {
  let tc = parseInt(input());
  while(tc--){
    const t = input().split('').map(Number);
    if(t[0]+t[1]+t[2] === t[3]+t[4]+t[5]) console.log("YES");
    else console.log("NO");
  }
}

'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 input() {
  return inputString[currentLine++];
}

function main() {
  let tc = parseInt(input());
  while(tc--){
    const t = input().split('').map(Number);
    if(t[0]+t[1]+t[2] === t[3]+t[4]+t[5]) console.log("YES");
    else console.log("NO");
  }
}

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 t = readLine();
    t = parseInt(t);
    while(t--) {
        let line = readLine();
        line = line.split("");
       if(parseInt(line[0])+parseInt(line[1])+parseInt(line[2])==parseInt(line[line.length-3])+parseInt(line[line.length-2])+parseInt(line[line.length-1]))
	   {console.log("YES");}
		else console.log("NO");

    }
}

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

let inp = [];

readline.on('line', line => {
    inp.push(line);
}).on('close', () => {
    let cases = inp.slice(1);
    for (let c of cases) {
        let n = c.split('').map(Number);
        console.log(n[0]+n[1]+n[2] === n[3]+n[4]+n[5] ? 'YES' : 'NO');
    }
});

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

let c = 0;

rl.on("line", (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const [a1, b1, c1, d1, e1, f1] = d.split("").map(Number);
  const ans = a1 + b1 + c1 === d1 + e1 + f1 ? "YES" : "NO";
  console.log(ans);
  c++;
});

rl.on("close", () => {});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

function main() {
    let N = readline();

    for (let test = 0; test < N; test++) {
        let [a, b, c, d, e, f] = readline().split('').map(Number);
        output((a + b + c) === (d + e + f) ? 'YES' : 'NO');
    }
}

const rdline = require('readline');

const rl = rdline.createInterface({
    input: process.stdin
});

let lines = [];
rl.on('line', (line) => {
    lines.push(line);
}).on('close', () => {
    // input in lines
    solve();
});

let line = 0;
const readline = () => lines[line++];
solve = () => {
    const t = parseInt(readline());
    for (let i = 0; i < t; i++) {
        var n = readline().split("").map(Number);
        var sum1 = 0;
        var sum2 = 0;
        for (let i = 0; i < 3; i++) {
            sum1 = n[i] + sum1;
        }
        for (let i = 3; i < 6; i++) {
            sum2 = n[i] + sum2;
        }
        if (sum1 === sum2) {
            console.log('YES')
        } else {
            console.log('NO');
        }
    }
}

"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++];
}

// ********** Code Start **********

function main() {
  var n = parseInt(readline());
  let arr = [];

  for (let i = 0; i < n; i++) {
      let num = readline();
      let a = num.split('');

      for (let j = 0; j < 6; j++) {
          a[j] = parseInt(a[j]);
      }

      if (a[0] + a[1] + a[2] === a[3] + a[4] + a[5]) arr[i] = "YES";
      else arr[i] = "NO";
  }

  for (let i = 0; i < n; i++) {
      console.log(arr[i]);
  }
}

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 s = nl.line();
		let a = s.substring(0, 3).split('').map(Number).reduce((x, a) => a + x, 0);
		let b = s.substring(3).split('').map(Number).reduce((x, a) => a + x, 0);
		ans.push(a === b);
	}
	console.log(ans.map(x => x?"YES":"NO").join('\n'));
};

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

function solve(inp) {
  var n = Number(inp.nextLine());
  while(n--) {
    const ss = inp.nextLine();
    const s1 = [...ss.substring(0, 3)].reduce((sum, c) => sum + Number(c), 0);
    const s2 = [...ss.substring(3, 6)].reduce((sum, c) => sum + Number(c), 0);

    console.log(s1 == s2 ? "YES" : "NO");
  }
}

class Input {
    constructor(lines) {
        this.lines = lines;
        this.next = 0;
    }

    addLine(line) {
        this.lines.push(line)
    }

    hasLine() {
       return this.lines.size() > 0;
    }

    nextLine() {
        const line = this.lines[this.next];
        if (line) {
            this.next++;
        }
        return line;
    }
}

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

const inp = new Input([]);

readline.on('line', line => {
    inp.addLine(line);
});

readline.on('close', () => {
    solve(inp);
});

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

    function foo (data) {
        const [a, b, c, d, e, f] = Array.from(data).map(Number);
        return a + b + c === d + e + f ? 'YES' : 'NO';
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount]
        let result = foo(data);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

"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++];
}

// ********** Code Start **********

function main() {

    let input = Number.parseInt(readline())
    while(input-- > 0){
        let num = readline()
        let arr = Array.from(num)
        let first = Number.parseInt(arr[0]) + Number.parseInt(arr[1]) + Number.parseInt(arr[2])
        let sec = Number.parseInt(arr[3]) + Number.parseInt(arr[4]) + Number.parseInt(arr[5])
        print(first === sec ? 'YES' : 'NO')
    }
}

const solve = (arr) => {
     let sum1=0,sum2=0;
     for(let i=0;i<3;i++) sum1+=arr[i];
     for(let i=3;i<6;i++) sum2+=arr[i];
     if(sum1===sum2) console.log("YES");
     else console.log("NO")
};
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let n = parseInt(readline());
  for(let i=0;i<n;i++){
       solve(readline().trim().split("").map(cur=>parseInt(cur)));
  }
}
main();

'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(s) {
  const nums = s.split('').map(Number);
  if (nums[0] + nums[1] + nums[2] === nums[3] + nums[4] + nums[5]) {
    return 'YES';
  } else {
    return 'NO';
  }
}

async function main(read) {
  let t = Number(await read());
  let res = [];
  while (t--) {
    const s = await read();
    res.push(solve(s));
  }
  console.log(res.join('\n'));
}

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);
}();

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

let lines = 0;

rl.on("line", function (line) {
  if (lines !== 0) {
    let input = line.split("").map(Number);

    console.log(
      input[0] + input[1] + input[2] === input[3] + input[4] + input[5]
        ? "YES"
        : "NO"
    );
  }
  lines++;
});

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 str = readLine();
    let lsum = 0; rsum = 0;
    let l = 0;
    for (let i = 0; i < str.length; i++) {
        lsum += parseInt(str[i]);
        l++;
        if (l == 3) {
            break;
        }
    }
    l = 0;
    for (let i = str.length - 1; i >= 0; i--) {
        rsum += parseInt(str[i]);
        l++;
        if (l == 3) {
            break;
        }
    }
    return rsum == lsum ? "Yes" : "No";
}

function processData(data) {
    data = data.split("\n");
  const T = data.shift();
  let i = 0;
  while (i < T) {
      const N = data.shift().split("");
      const res =
        Number(N[0]) + Number(N[1]) + Number(N[2]) ===
        Number(N[3]) + Number(N[4]) + Number(N[5]) ? "YES" : "NO";
      console.log(res);
      i++;
  }
}

// processData(`5
// 213132
// 973894
// 045207
// 000000
// 055776`);

process.stdin.resume();
process.stdin.setEncoding("ascii");
let _input = "";
process.stdin.on("data", function (input) {
  _input += input;
});

process.stdin.on("end", function () {
  processData(_input);
});

const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trim().split('\r\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
var T = readline();
for(var q=1;q<=T;q++) {
  var a = readline();
  //var a = readline().split(' ').map((x)=>parseInt(x));
  var ans_one = 0, ans_two = 0;
  for(var i=0;i<a.length;i++) {
    if(i<3) ans_one += (a[i]-1)
    else ans_two += (a[i]-1);
  }
  var ans = ans_one==ans_two ? 'YES' : 'NO';

  console.log(ans);
  //fs.appendFileSync('output.txt', ans+'\r\n');

  //os.EOL
}
//fs.writeFileSync('output.txt', f.join(' '));

//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;}}

function Main(){
    // test case in nodeJs
	var t = nextInt();
	while(hasNext()){
		solve();
	}
}

function solve() {
	const nums = nextCharArray().map(ele => parseInt(ele));
    let sum = 0;
    for (let i = 0; i < 6; i++) {
        if (i < 3) {
            sum+= nums[i]
        } else {
            sum-= nums[i]
        }
    }

    const ans = sum === 0 ? "YES" : "NO"

    myout(ans)
}

'use strict';
// HEADER:
const print = console.log;
let IS_MULTITEST, testN;
const pcalc = testN=>{
  let res = calc(testN);
  if (Array.isArray(res)){
    pa(res);
  } else if (Number.isFinite(res) || typeof res=='string'){
    print(res);
  }
};

const main = ()=>{
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(T);
  } else
   pcalc();
};

const lines = [];
const rl = require('readline').createInterface({
   input: process.stdin, output: process.stdout});
rl.on('line', line=>{
  lines.push(line);
});
rl.on('close', main);
let rli = 0;
const readline = ()=>lines[rli++];
const L = process.env.DEBUG ? console.log : ()=>{};
const LT = obj=>L(`Test #${testN}`, obj);

const ra = ()=>readline().split(' ').map(a=>+a)
const pa = arr=>print(arr.join(' '));

// SOLUTION:
IS_MULTITEST = 1;

const calc = ()=>{
  // READING:
  let s = readline();
  LT({s});

  // PROCESSING:
  let ans = 0;
  return +s[0]+ +s[1]+ +s[2] ==+s[4]+ +s[5]+ +s[3]  ? 'YES' : 'no'
};

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const str = lines[l++]
        output[i] = solve(str) ? 'YES' : 'NO'
    }
    console.log(output.join('\n'))
// })()
})

function solve(str) {
    const [a, b, c, d, e, f] = str.split('').map(Number)
    return a + b + c === d + e + f
}

//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 S = next();
		var L = 0;
		var R = 0;
		for(var i = 0; i < 3; i++){
			L += myconv(S[i], 1);
			R += myconv(S[i + 3], 1);
		}
		if(L == R){
			myout("YES");
		}else{
			myout("NO");
		}
	}
}

var rows = readline();
while (rows--) {
	i = [...readline()].map(c=>parseInt(c));
	print(i[0]+i[1]+i[2] === i[3]+i[4]+i[5]?'YES':'NO')
}

var rows = readline();
while (rows--) {
	i = Array.prototype.map.call(readline(), (c)=>parseInt(c));
	print(i[0]+i[1]+i[2] === i[3]+i[4]+i[5]?"YES":"NO")
}

var t = readline();
for(var i =0 ; i < t ; i++){
    var arr = [...readline()].map(x => Number(x));
    var former = arr.slice(0, 3).reduce((sum, a) => sum + a, 0);
    var latter = arr.slice(3, 6).reduce((sum, a) => sum + a, 0);

    if (former === latter ) {
        print('YES');
    } else {
        print('NO');
    }
}

var t = parseInt(readline());

for (var test = 0; test < t; test++) {
    var inp = readline().split('');
    var a = parseInt(inp[0]);
    var b = parseInt(inp[1]);
    var c = parseInt(inp[2]);
    var d = parseInt(inp[3]);
    var e = parseInt(inp[4]);
    var f = parseInt(inp[5]);

    var happy = a + b + c === d + e + f;

    print(happy ? 'YES' : 'NO');
}

var t = readline();
for(var  i = 0 ; i < t ; i++){
    var ticket = readline().split(''),
        firstThreeDigits  = ticket.slice(0,3),
        lastThreeDigits  = ticket.slice(3,6),
        sum1 = 0 , sum2 = 0;
        for(var j=0 ; j < 3 ; j++){
            sum1 += parseInt(firstThreeDigits[j]) ;
            sum2 += parseInt(lastThreeDigits[j]) ;
        }
        if(sum1 == sum2){
            print("YES");
        }
        else{
            print("NO");
        }
}

var testCase=+readline()
for(var i=0;i<testCase;i++){
    var sequence=readline().split("").map(node=>+node)
    var a=sequence.slice(0,3).reduce((a,b)=>a+b)
    var b=sequence.slice(-3).reduce((a,b)=>a+b)
    if(a===b){
        print("YES")
    }else{
        print("NO")
    }
}

T = readline()
while (T--) {
   x = readline().split('').map(x => +x)
   if(x[0]+x[1]+x[2] === x[3]+x[4]+x[5])
      print('YES')
   else
      print('NO')

}

t = parseInt(readline());
for(i = 0; i < t; i++)
{
    var n = readline();
    n0 = parseInt(n[0]);
    n1 = parseInt(n[1]);
    n2 = parseInt(n[2]);
    n3 = parseInt(n[3]);
    n4 = parseInt(n[4]);
    n5 = parseInt(n[5]);
    if(n0+n1+n2 === n3+n4+n5) print("YES");
    else print("NO");
}

var t = +readline();

for(var i = 0; i< t; i ++) {
    var a = readline();
    print(Task1(a));
}

function Task1 (str){

  var test = +str[0] + (+str[1]) + (+str[2]);
  var test1 = +str[3] + (+str[4]) + (+str[5]);
  if (test === test1){
    return 'YES';
  }else {
    return 'NO';
  }

}

var n = readline()

for(var i=0 ; i<n ; i++){
     var arr = readline()
    var sum1 = parseInt(arr[0])+parseInt(arr[1])+parseInt(arr[2]);
    var sum2 = parseInt(arr[3]) + parseInt(arr[4]) + parseInt(arr[5]);
    if(sum1 == sum2) print("YES");
    else print("NO")
}

//import { readline, print } from '@ip-algorithmics/codeforces-io';
var t = +readline();
while (t--) {
    var a = readline().split('').map(function (v) { return +v; });
    print(a[0] + a[1] + a[2] === a[3] + a[4] + a[5] ? 'YES' : 'NO');
}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var a = lines[i].split('').map(Number);
        var x = 0;
        var y = 0;
        for(j = 0; j < 6; j++){
            if(j >= 3){
                x += a[i];
            }else{
                y += a[i];
            }
        }
        console.log(x == y ? 'YES' : 'NO');
    }
});

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    for(i = 1; i <= t; i++){
        var a = lines[i].split(' ').map(Number);
        var x = 0;
        var y = 0;
        for(j = 0; j < 6; j++){
            if(j >= 3){
                x += a[i];
            }else{
                y += a[i];
            }
        }
        console.log(x == y ? 'YES' : 'NO');
    }
});

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 k = lines[1].split(' ').map(Number)
    var w = lines[1].split(' ').map(Number)
    var s = 0
    var d = 0
    var sa = true
    for(j = 0; j < n; j++){
        if(k[0] >= w[w.length - 1] && sa === true){
            sa = false
            s += w[0]
            w = ''
            for(b = 1; b < k.length; b++){
                w += k[b]
            }
        }

        else if(k[0] <= w[w.length - 1] && sa === true){
            sa = false
            s += w[w.length - 1]
            w = ''
            for(b = 1; b < k.length; b++){
                w += k[b]
            }
        }

        else if(k[0] >= w[w.length - 1] && sa === false){
            sa = false
            d += w[0]
            w = ''
            for(b = 1; b < k.length; b++){
                w += k[b]
            }
        }

        else if(k[0] <= w[w.length - 1] && sa === false){
            sa = false
            d += w[w.length - 1]
            w = ''
            for(b = 1; b < k.length; b++){
                w += k[b]
            }
        }
    }
    console.log(s, d)
});

'use-strict'

process.stdin.resume();
process.stdin.setEncoding('utf8');

let data = '';
let currentLine = 0;

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

process.stdin.on('end', () =>{
    data = data.replace(/\s*$/, '')
    .split('\n')
    .map(str => str.replace(/\s*$/, ''));

    let testCases = parseInt(data.shift());

    while(testCases--) {

        const s = readLine();

        const res = MY_FUNC(s);

        console.log(res[0],res[1])
    }
});

function get_ints() {
    return data.shift().split(' ').map(Number);
}

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

function MY_FUNC(s){
    ans = 'YES';
    a = 0;
    b = 0;
    for(let i = 0 ; i < s.length; i++){
        if(i < 3){
            a += parseInt(s[i]);
        } else {
            b += parseInt(s[i]);
        }
    }
   a == b ? ans = 'YES' : ans = 'NO';
    return ans;
}

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 t = readLine();
    t = parseInt(t);
    while(t--) {
        let line = readLine();
        line = line.split("");
       if(line[0]+line[1]+line[2]==line[line.length-3]+line[line.length-2]+line[line.length-1])
	   {console.log("YES");}
		else console.log("NO");

    }
}

var rows = readline();
while (rows--) {
	row = readline();
	print( Array.prototype.map.call(row, (c)=>parseInt(c)).map((i)=> (i[0]+i[1]+i[2] === i[3]+i[4]+i[5])?"YES":"NO"))
}

var rows = readline();
while (rows--) {
	print( Array.prototype.map.call(readline(), (c)=>parseInt(c)).map((i)=> (i[0]+i[1]+i[2] === i[3]+i[4]+i[5])?"YES":"NO"))
}

[...Array(readline()).keys()].forEach(()=>{
	print( Array.prototype.map.call(readline(), (c)=>parseInt(c)).map((i)=> (i[0]+i[1]+i[2] === i[3]+i[4]+i[5])?"YES":"NO"))
});


Devu being a small kid, likes to play a lot, but he only likes to play with arrays. While playing he came up with an interesting question which he could not solve, can you please solve it for him?Given an array consisting of distinct integers. Is it possible to partition the whole array into k disjoint non-empty parts such that p of the parts have even sum (each of them must have even sum) and remaining k - p have odd sum? (note that parts need not to be continuous).If it is possible to partition the array, also give any possible way of valid partitioning.

The first line will contain three space separated integers n, k, p (1 ≤ k ≤ n ≤ 105; 0 ≤ p ≤ k). The next line will contain n space-separated distinct integers representing the content of array a: a1, a2, ..., an (1 ≤ ai ≤ 109).

In the first line print "YES" (without the quotes) if it is possible to partition the array in the required way. Otherwise print "NO" (without the quotes). If the required partition exists, print k lines after the first line. The ith of them should contain the content of the ith part. Print the content of the part in the line in the following way: firstly print the number of elements of the part, then print all the elements of the part in arbitrary order. There must be exactly p parts with even sum, each of the remaining k - p parts must have odd sum. As there can be multiple partitions, you are allowed to print any valid partition.

if (!this.readline) print = console.log, readline = require('./readline');

print(function(n, k, p) {
	var a = readline().split(' ').map(Number);
	var ans = [];
	var s = [];

	var x = [];

	for (var i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (ans.length < p) {
				ans.push([a[i]]);
			} else {
				if (ans.length) {
					ans[0].push(a[i]);
				} else {
					x.push(a[i]);
				}
			}
		} else {
			s.push(a[i]);
		}
	}

	for (var i = 0, l = p - ans.length; i < l; i++) {
		if (s.length >= 2) {
			ans.push([s.pop(), s.pop()]);
		} else {
			return 'NO';
		}
	}
	for (var i = 0, l = k - ans.length; i < l; i++) {
		if (s.length > 0) {
			ans.push([s.pop()]);
		} else {
			return 'NO';
		}
	}
	while (s.length > 0) {
		if (s.length >= 2) {
			ans[0].push(s.pop(), s.pop());
		} else {
			return 'NO';
		}
	}

	while (x.length > 0) {
		ans[0].push(x.pop());
	}

	return 'YES\n' + ans.map(function(v) {
		return v.length + ' ' + v.join(' ');
	}).join('\n');

}.apply(0, readline().split(' ').map(Number)));

var info = readline().split(' ').map(Number);
var Arr = readline().split(' ').map(Number);
var md2 = Arr.filter(function (_) { return _%2==0;});
var mnd2 = Arr.filter(function (_) { return _%2==1;});
var result = [];
var nd2 = info[1] - info[2];
var pp = [];
while(mnd2.length > 1 && mnd2.length > nd2) {
    pp.push([mnd2.pop(), mnd2.pop()]);
}
if (mnd2.length != nd2 || (pp.length + md2.length) < info[2]) {
    print("NO");
}
else {
    for (var i=0; i<nd2; i++) {
        result.push([mnd2[i]]);
    }
    for (i=0; i<info[2]; i++) {
        if (md2.length) {
            result.push([md2.pop()]);
        }
        else {
            result.push(pp.pop());
        }
    }
    result[0] = result[0].concat(md2);
    while(pp.length) {
        var t = pp.pop();
        result[0].push(t[0], t[1]);
    }
    print("YES");
    for (i=0; i<result.length; i++)
    {
        print(result[i].length + ' ' + result[i].join(' '));
    }
}

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], wantPartitions = data[1], wantEven = data[2],
		wantOdd = wantPartitions - wantEven,
		input = tokenizeIntegers(readline()),
		items = new Array(n), odd = 0, even = 0;
	for (var i = 0; i < n; ++i) {
		var bit = input[i]%2;
		if (bit == 0) {
			even += 1;
		} else {
			odd += 1;
		}
		items[i] = { value: input[i], bit: bit };
	}
	if (wantOdd > odd || (odd - wantOdd) % 2 == 1 ||
			wantEven > even + (odd - wantOdd) / 2) {
		print('NO');
		return;
	}
	print('YES');
	items.sort(function (a, b) {
		return a.bit - b.bit;
	});
	var pos = n-1;
	for (var i = 1; i < wantOdd; ++i) {
		print('1 '+items[pos--].value);
	}
	if (wantEven != 0 && wantOdd != 0) {
		print('1 '+items[pos--].value);
	}
	while (wantEven > 1 && items[pos].bit == 1) {
		print('2 '+items[pos--].value+' '+items[pos--].value);
		--wantEven;
	}
	for (var i = 1; i < wantEven; ++i) {
		print('1 '+items[pos--].value);
	}
	if (pos != -1) {
		var parts = [pos+1];
		while (pos != -1) {
			parts.push(items[pos--].value);
		}
		print(parts.join(' '));
	}
}

main();

if (!this.readline) print = console.log, readline = require('./readline');

print(function(n, k, p) {
	var a = readline().split(' ').map(Number);
	var ans = [];
	var s = [];

	for (var i = 0; i < n; i++) {
		if (a[i] % 2 == 0) {
			if (ans.length < p) {
				ans.push([a[i]]);
			} else {
				ans[0] && ans[0].push(a[i]);
			}
		} else {
			s.push(a[i]);
		}
	}

	for (var i = 0, l = p - ans.length; i < l; i++) {
		if (s.length >= 2) {
			ans.push([s.pop(), s.pop()]);
		} else {
			return 'NO';
		}
	}
	for (var i = 0, l = k - ans.length; i < l; i++) {
		if (s.length > 0) {
			ans.push([s.pop()]);
		} else {
			return 'NO';
		}
	}
	while (s.length > 0) {
		if (s.length >= 2) {
			ans[0].push(s.pop(), s.pop());
		} else {
			return 'NO';
		}
	}

	return 'YES\n' + ans.map(function(v) {
		return v.length + ' ' + v.join(' ');
	}).join('\n');

}.apply(0, readline().split(' ').map(Number)));

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], wantPartitions = data[1], wantEven = data[2],
		wantOdd = wantPartitions - wantEven,
		input = tokenizeIntegers(readline()),
		items = new Array(n), odd = 0, even = 0;
	for (var i = 0; i < n; ++i) {
		var bit = input[i]%2;
		if (bit == 0) {
			even += 1;
		} else {
			odd += 1;
		}
		items[i] = { value: input[i], bit: bit };
	}
	if (wantOdd > odd || (odd - wantOdd) % 2 == 1 ||
			(wantEven == 0 && even + (odd - wantOdd) != 0) ||
			wantEven > even + (odd - wantOdd) / 2) {
		print('NO');
		return;
	}
	print('YES');
	items.sort(function (a, b) {
		return a.bit - b.bit;
	});
	var pos = n-1;
	for (var i = 0; i < wantOdd; ++i) {
		print('1 '+items[pos--].value);
	}
	while (wantEven > 1 && items[pos].bit == 1) {
		print('2 '+items[pos--].value+' '+items[pos--].value);
		--wantEven;
	}
	for (var i = 1; i < wantEven; ++i) {
		print('1 '+items[pos--].value);
	}
	if (pos != -1) {
		var parts = [pos+1];
		while (pos != -1) {
			parts.push(items[pos--].value);
		}
		print(parts.join(' '));
	}
}

main();

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], 10);
	};
	return tokens;
}

function main() {
	var data = tokenizeIntegers(readline()),
		n = data[0], wantPartitions = data[1], wantEven = data[2],
		wantOdd = wantPartitions - wantEven,
		input = tokenizeIntegers(readline()),
		items = new Array(n), odd = 0, even = 0;
	for (var i = 0; i < n; ++i) {
		var bit = input[i]%2;
		if (bit == 0) {
			even += 1;
		} else {
			odd += 1;
		}
		items[i] = { value: input[i], bit: bit };
	}
	if (wantOdd > odd || (odd - wantOdd) % 2 == 1 ||
			wantEven > even + (odd - wantOdd) / 2) {
		print('NO');
		return;
	}
	print('YES');
	items.sort(function (a, b) {
		return a.bit - b.bit;
	});
	var pos = n-1;
	for (var i = 1; i < wantOdd; ++i) {
		print('1 '+items[pos--].value);
	}
	while (wantEven > 1 && items[pos].bit == 1) {
		print('2 '+items[pos--].value+' '+items[pos--].value);
		--wantEven;
	}
	for (var i = 1; i < wantEven; ++i) {
		print('1 '+items[pos--].value);
	}
	if (pos != -1) {
		var parts = [pos+1];
		while (pos != -1) {
			parts.push(items[pos--].value);
		}
		print(parts.join(' '));
	}
}

main();


You are given a sequence $$$a_1, a_2, \dots, a_n$$$ consisting of $$$n$$$ pairwise distinct positive integers.Find $$$\left\lfloor \frac n 2 \right\rfloor$$$ different pairs of integers $$$x$$$ and $$$y$$$ such that:   $$$x \neq y$$$;  $$$x$$$ and $$$y$$$ appear in $$$a$$$;  $$$x~mod~y$$$ doesn't appear in $$$a$$$. Note that some $$$x$$$ or $$$y$$$ can belong to multiple pairs.$$$\lfloor x \rfloor$$$ denotes the floor function — the largest integer less than or equal to $$$x$$$. $$$x~mod~y$$$ denotes the remainder from dividing $$$x$$$ by $$$y$$$.If there are multiple solutions, print any of them. It can be shown that at least one solution always exists.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. The first line of each testcase contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$) — the length of the sequence. The second line of each testcase contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^6$$$). All numbers in the sequence are pairwise distinct. The sum of $$$n$$$ over all testcases doesn't exceed $$$2 \cdot 10^5$$$.

The answer for each testcase should contain $$$\left\lfloor \frac n 2 \right\rfloor$$$ different pairs of integers $$$x$$$ and $$$y$$$ such that $$$x \neq y$$$, $$$x$$$ and $$$y$$$ appear in $$$a$$$ and $$$x~mod~y$$$ doesn't appear in $$$a$$$. Print the pairs one after another. You can print the pairs in any order. However, the order of numbers in the pair should be exactly such that the first number is $$$x$$$ and the second number is $$$y$$$. All pairs should be pairwise distinct. If there are multiple solutions, print any of them.

NoteIn the first testcase there are only two pairs: $$$(1, 4)$$$ and $$$(4, 1)$$$. $$$\left\lfloor \frac 2 2 \right\rfloor=1$$$, so we have to find one pair. $$$1~mod~4=1$$$, and $$$1$$$ appears in $$$a$$$, so that pair is invalid. Thus, the only possible answer is a pair $$$(4, 1)$$$.In the second testcase, we chose pairs $$$8~mod~2=0$$$ and $$$8~mod~4=0$$$. $$$0$$$ doesn't appear in $$$a$$$, so that answer is valid. There are multiple possible answers for that testcase.In the third testcase, the chosen pairs are $$$9~mod~5=4$$$ and $$$7~mod~5=2$$$. Neither $$$4$$$, nor $$$2$$$, appears in $$$a$$$, so that answer is valid.

const readline = require('readline')

const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
})
const lines = []
rl.on('line', (input) => {
    lines.push(input);
})
rl.on('close', () => {
// (function() {
    // const lines = require('fs').readFileSync('test.in', 'utf8').split('\n')
    let l = 0;
    let t = +lines[l++]
    const output = []
    for (let i = 0; i < t; i++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    arr.sort((a, b) => b - a)
    // const map = arr.reduce((o, x) => {
    //     o[x] = 1
    //     return o
    // }, {})
// console.log(arr)
    const ans = Array(Math.floor(n / 2))
    let p = 0
    for (let i = 0; i < arr.length; i++) {
        const a = arr[i]
        // for (let j = i + 1; j < arr.length; j++) {
            const b = arr[n - 1]
            // if (!map[a % b]) {
                ans[p++] = [a, b].join(' ')
                if (p === ans.length) return ans.join('\n')
                // break
            // }
        // }
    }
    return ''
}

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 * 2
    } 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([n], arr) {
    const ans = []
    let count = 0;
    arr = arr.sort((a, b) => a - b)
    for (const i of arr) {
        if (i != arr[0]) {
            ans.push(i + ' ' + arr[0])
            count++
        }
        if (count >= (Math.floor(n / 2))) break;
    }
    console.log(ans.join('\n'))
}

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

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
    var t = lines[0];
    var n = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            n = lines[i];
        }else{
            var a = lines[i].split(' ').map(Number).sort(function(a, b){return a - b});
            var ans = '';
            for(j = 1; j <= n / 2; j++){
                console.log(a[j], a[0]);
            }
        }
    }
});

const solve = (arr)=>{
     let min = Infinity,cnt=0;
     for(let i=0;i<arr.length;i++) if(arr[i]<min) min = arr[i];
     for(let i=0;i<arr.length;i++){
          if(arr[i]!==min){
               console.log(arr[i]+" "+min);
               cnt++
          }
          if(cnt===Math.floor(arr.length/2)) break;
     }
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = parseInt(readline());
       let arr = readline().trim().split(" ").map(cur=>parseInt(cur));
       solve(arr);
  }
}
main();

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
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  let number = parseInt(readline());
  while (number--) {
    let a = parseInt(readline());
    let str = readline().split(" ").map(Number);
    let min = Math.min(...str);
    let count = 0;
    for (let i = 0; i < str.length; i++) {
      if (count == Math.floor(a / 2)) {
        break;
      }
      if (str[i] != min) {
        print(str[i] + " " + min);
        count++;
      }
    }
  }
}

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
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

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

// ********** Code Start **********
function main() {
  var number = parseInt(readline())
  while(number--){
    var a = parseInt(readline())
    var str = readline().split(' ').map(Number)
    var min  = Math.min(...str)
    var count = 0;
    for(let  i = 0; i < str.length;i++){
      if(count == Math.floor(a / 2)){
        break;
      }
        if(str[i] != min){
          print(str[i] + " " + min)
          count++
        }
    }
  }
}

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--) {
		let n = rn();
		let a = rna();

		const mn = Math.min(...a);

		for (let i = 0; i < Math.floor(n/2); i++) {
			if (a[i] != mn)
				console.log(a[i], mn);
			else
				console.log(a[n-1], mn);
		}

	}
}

const main = () => {

	// pick y as the smallest
	var t = readInt();
	var allans = [];
	while (t--) {
		var n = readInt();
		var a = readIntArr();
		var minI = 0;
		for (var i = 0; i < n; i++) {
			if (a[i] < a[minI])
				minI = i;
		}
		var cnts = 0;
		for (var i = 0; i < n; i++) {
			if (i != minI) {
				allans.push([a[i], a[minI]]);
				cnts++;
				if ((cnts + 1) * 2 > n)
					break;
			}
		}
	}
	multiLineArrayOfArraysPrint(allans);

	return;
}

const readInt = () => parseInt(readline());
const readString = () => readline();
const readIntArr = () => readline().split(" ").map(zzzz => parseInt(zzzz));
const parseLong = (string) => { // javascript's largest long is < (1<<62)
	var n = string.length;
	var res = 0;
	for (var i = 0; i < n; i++) {
		res *= 10;
		res += parseInt(string[i]);
	}
	return res;
}
const readLong = () => parseLong(readLong());
const readLongArr = () => readline().split(" ").map(zzzz => parseLong(zzzz));
const oneLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join(' '));
const multiLineArrayPrint = (arr) => print(arr.map(zzzz => zzzz.toString()).join('\n'));
const multiLineArrayOfArraysPrint = (arr) => print(arr.map(yyyy => yyyy.map(zzzz => zzzz.toString()).join(' ')).join('\n'));
const makeArr = (defaultVal, dimensionsArr) => {
	var n = dimensionsArr.length;
	if (n === 1) return Array(dimensionsArr[0]).fill(defaultVal);
	else {
		var temp = [];
		for (var i = 0; i < dimensionsArr[0]; i++)
			temp.push(makeArr(defaultVal, dimensionsArr.slice(1)));
		return temp;
	}
}

for (_ = 0; _ < 1; _++) {
	main();
}

// newline for testing
 //newline for testing
// codeforces js cannot use "let" keyword. use "var" instead
// codeforces js cannot destructure arrays


Leo Jr. draws pictures in his notebook with checkered sheets (that is, each sheet has a regular square grid printed on it). We can assume that the sheets are infinitely large in any direction.To draw a picture, Leo Jr. colors some of the cells on a sheet gray. He considers the resulting picture beautiful if the following conditions are satisfied: The picture is connected, that is, it is possible to get from any gray cell to any other by following a chain of gray cells, with each pair of adjacent cells in the path being neighbours (that is, sharing a side). Each gray cell has an even number of gray neighbours. There are exactly $$$n$$$ gray cells with all gray neighbours. The number of other gray cells can be arbitrary (but reasonable, so that they can all be listed).Leo Jr. is now struggling to draw a beautiful picture with a particular choice of $$$n$$$. Help him, and provide any example of a beautiful picture.To output cell coordinates in your answer, assume that the sheet is provided with a Cartesian coordinate system such that one of the cells is chosen to be the origin $$$(0, 0)$$$, axes $$$0x$$$ and $$$0y$$$ are orthogonal and parallel to grid lines, and a unit step along any axis in any direction takes you to a neighbouring cell.

The only line contains a single integer $$$n$$$ ($$$1 \leq n \leq 500$$$) — the number of gray cells with all gray neighbours in a beautiful picture.

In the first line, print a single integer $$$k$$$ — the number of gray cells in your picture. For technical reasons, $$$k$$$ should not exceed $$$5 \cdot 10^5$$$. Each of the following $$$k$$$ lines should contain two integers — coordinates of a gray cell in your picture. All listed cells should be distinct, and the picture should satisdfy all the properties listed above. All coordinates should not exceed $$$10^9$$$ by absolute value. One can show that there exists an answer satisfying all requirements with a small enough $$$k$$$.

NoteThe answer for the sample is pictured below:

function solve() {
   var n = Number(read());
   write(3 * (n - 1) + 7);
   write('0 0');
   write('0 1');
   write('1 0');
   write('1 1');
   for (var i = 0; i < n; ++i) {
      var i1 = i + 1;
      var i2 = i + 2;
      write('' + i1 + ' ' + i2);
      write('' + i2 + ' ' + i1);
      write('' + i2 + ' ' + i2);
   }
}

var isNode = typeof console !== 'undefined';
var MEMORY = [];
var MEMORY_INDEX = 0;
if (isNode) {
   var fs = require('fs');
   var path = require('path');

   var inTextName;
   var outTextName;
   if (process.argv.length === 5) {
      inTextName = process.argv[3];
      outTextName = process.argv[4];
   }

   if (inTextName) {
      fs.readFile(path.join(__dirname, inTextName), 'utf8', (err, data) => {
         MEMORY = data.split('\r\n');
         solve();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

      RL.on('line', (line) => {
         MEMORY.push(line);
      });

      RL.on('close', solve);
   }
} else {
   solve();
}

function write(value) {
   isNode ? console.log(value) : print(value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input = '';
process.stdin.on('data', function (line) {
    input += line;
});
process.stdin.on('end', function () {
    var lines = input.split('\n');
    var n = parseInt(lines.shift(), 10);
    var ans = [];
    ans.push([0, 0]);
    for (var i = 0; i <= n; i++) {
        ans.push([i, i + 1]);
        ans.push([i + 1, i]);
        ans.push([i + 1, i + 1]);
    }
    console.log(ans.length);
    ans.forEach(function (element) { return console.log.apply(console, element); });
});
// input helper
function lineToNumArray(line) {
    return line.split(' ').map(function (element) { return parseInt(element, 10); });
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input = '';
process.stdin.on('data', function (line) {
    input += line;
});
process.stdin.on('end', function () {
    var lines = input.split('\n');
    var n = parseInt(lines.shift(), 10);
    var ans = [[0, 0]];
    for (var i = 0; i <= n; i++) {
        ans.push([i, i + 1]);
        ans.push([i + 1, i]);
        ans.push([i + 1, i + 1]);
    }
    console.log(ans.length);
    ans.forEach(function (element) { return console.log.apply(console, element); });
});
// input helper
function lineToNumArray(line) {
    return line.split(' ').map(function (element) { return parseInt(element, 10); });
}

const process = require('process')
let input = ''
process.stdin.on('data', data => input += data)
process.stdin.on('end', () => main(input))

function main(input) {
    // let lines = input.trim().split('\n')
    // let n = +lines[0]
    // for(let i = 0; i < n; i++) {
    //     let [a, b, n] = lines[1 + i].split(' ')
    //     console.log(solution(+a, +b, +n))
    // }
    solution(+input.trim())
}

function solution(N) {
    let ans = [[0, 0], [0, 1], [1, 0]]

    let x = 1, y = 1
    for (let i = 0; i < N; i++) {
        ans.push([x, y], [x, y + 1], [x + 1, y])
        x++
        y++
    }
    ans.push([x, y])
    console.log(ans.length)
    for (let arr of ans) {
        console.log(arr[0], arr[1])
    }
}

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();
    });

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function C(){
    let n = pi(readline());
    let x = 7+(n-1)*3
    console.log(x);
    let j = 0;
    for(let i = 1; i <= x; i+=3){
        if(i === x){
            console.log(j,j);
            break;
        }
        console.log(j,j);
        console.log(j+1, j);
        console.log(j,j+1);
        j++;
    }
}

'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++];
}
/**
6
6 1
100010
6 2
000000
5 1
10101
3 1
001
2 2
00
1 1
0

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

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

    // for(let i=0;i<n;i++) {
    //     solve();
    // }

    let a = [];
    let x = 0;
    let y = 0
    for(let i=0;i<=n;i++) {
        a.push([x,y], [x+1,y], [x, y+1]);
        x++;
        y++;
    }
    a.push([x,y]);
    console.log(a.length);
    for(let i=0;i<a.length;i++) {
        console.log(a[i][0] + ' ' + a[i][1]);
    }

}

function solve() {
    let [n, m] = readline().split(" ").map(Number);
    let a = readline().split("");

    let count = 0;
    let i = 1;
    if(a.length === 1 && a[0] === "0") {
        console.log(1);
        return;
    }

    while(m > count && i < n) {
        if(i === 1 && a[i-1] === '0' && a[i] === '0') {
            count++;
            a[i-1] = "1";
            continue;
        }

        if(a[i + 1] === n) {
            if(a[i] === "0" && a[i-1] === "0") {
                count++;
            }

            continue;
        }

        if(a[i] === "0" && a[i-1] === "0" && a[i+1] === "0") {
            count++;
            a[i] = "1";
        }

        i++;
    }

    console.log(count);
}

var n = +readline()
while(n )
{
    print(0 + ' ' + parseInt(n/2))
     print(1 + ' ' + parseInt(n/2))
n-=2
}

var n = +readline()
while(n)
{
    print(0 + ' ' + parseInt(n/2))
     print(0 + ' ' + parseInt(n/2))
n-=1
}

var n = +readline()
while(n)
{
    print(0 + ' ' + parseInt(n/2))
     print(1 + ' ' + parseInt(n/2))
n-=1
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input = '';
process.stdin.on('data', function (line) {
    input += line;
});
process.stdin.on('end', function () {
    var lines = input.split('\n');
    var n = parseInt(lines.shift(), 10);
    var ans = [];
    for (var i = 0; i < n; i++) {
        ans.push([0, 2 * i + 1]);
    }
    for (var i = 0; i <= 2 * n; i++) {
        ans.push([1, i]);
    }
    for (var i = 0; i < n; i++) {
        ans.push([2, 2 * i + 1]);
    }
    console.log(ans.length);
    ans.forEach(function (element) { return console.log.apply(console, element); });
});
// input helper
function lineToNumArray(line) {
    return line.split(' ').map(function (element) { return parseInt(element, 10); });
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
var input = '';
process.stdin.on('data', function (line) {
    input += line;
});
process.stdin.on('end', function () {
    var lines = input.split('\n');
    var n = parseInt(lines.shift(), 10);
    var ans = [];
    for (var i = 0; i < n; i++) {
        ans.push([0, 4 * i]);
        ans.push([0, 4 * i + 1]);
        ans.push([1, 4 * i]);
        ans.push([1, 4 * i + 1]);
        ans.push([1, 4 * i + 2]);
        ans.push([2, 4 * i + 1]);
        ans.push([2, 4 * i + 2]);
    }
    console.log(ans.length);
    ans.forEach(function (element) { return console.log.apply(console, element); });
});
// input helper
function lineToNumArray(line) {
    return line.split(' ').map(function (element) { return parseInt(element, 10); });
}

'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++];
}
/**
6
6 1
100010
6 2
000000
5 1
10101
3 1
001
2 2
00
1 1
0

**/

function gcd(a, b) {
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
};

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

    // for(let i=0;i<n;i++) {
    //     solve();
    // }

    let a = [];
    let x = 1;
    let y = 1
    for(let i=0;i<n;i++) {
        a.push([x,y], [x+1,y], [x, y+1]);
        x++;
        y++;
    }

    console.log(a.length);
    for(let i=0;i<a.length;i++) {
        console.log(a[i][0] + ' ' + a[i][1]);
    }

}

function solve() {
    let [n, m] = readline().split(" ").map(Number);
    let a = readline().split("");

    let count = 0;
    let i = 1;
    if(a.length === 1 && a[0] === "0") {
        console.log(1);
        return;
    }

    while(m > count && i < n) {
        if(i === 1 && a[i-1] === '0' && a[i] === '0') {
            count++;
            a[i-1] = "1";
            continue;
        }

        if(a[i + 1] === n) {
            if(a[i] === "0" && a[i-1] === "0") {
                count++;
            }

            continue;
        }

        if(a[i] === "0" && a[i-1] === "0" && a[i+1] === "0") {
            count++;
            a[i] = "1";
        }

        i++;
    }

    console.log(count);
}


You are given $$$n$$$ chips on a number line. The $$$i$$$-th chip is placed at the integer coordinate $$$x_i$$$. Some chips can have equal coordinates.You can perform each of the two following types of moves any (possibly, zero) number of times on any chip:  Move the chip $$$i$$$ by $$$2$$$ to the left or $$$2$$$ to the right for free (i.e. replace the current coordinate $$$x_i$$$ with $$$x_i - 2$$$ or with $$$x_i + 2$$$);  move the chip $$$i$$$ by $$$1$$$ to the left or $$$1$$$ to the right and pay one coin for this move (i.e. replace the current coordinate $$$x_i$$$ with $$$x_i - 1$$$ or with $$$x_i + 1$$$). Note that it's allowed to move chips to any integer coordinate, including negative and zero.Your task is to find the minimum total number of coins required to move all $$$n$$$ chips to the same coordinate (i.e. all $$$x_i$$$ should be equal after some sequence of moves).

The first line of the input contains one integer $$$n$$$ ($$$1 \le n \le 100$$$) — the number of chips. The second line of the input contains $$$n$$$ integers $$$x_1, x_2, \dots, x_n$$$ ($$$1 \le x_i \le 10^9$$$), where $$$x_i$$$ is the coordinate of the $$$i$$$-th chip.

Print one integer — the minimum total number of coins required to move all $$$n$$$ chips to the same coordinate.

NoteIn the first example you need to move the first chip by $$$2$$$ to the right and the second chip by $$$1$$$ to the right or move the third chip by $$$2$$$ to the left and the second chip by $$$1$$$ to the left so the answer is $$$1$$$.In the second example you need to move two chips with coordinate $$$3$$$ by $$$1$$$ to the left so the answer is $$$2$$$.

if (process.env.ANT)
{
    global.print = this.print || function(){console.log([...arguments].join(' '))} || require('lol-io').print
    global.write = this.write || require('lol-io').write
    global.readline = this.readline || require('lol-io').readline
    global.debug = function(){console.log('debug:', [...arguments].join(' '))}
    main();
}
else
{
    const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
    global.print = console.log
    global.write = (...args) => {
        process.stdout.write(args.join(' '));
    }
    const lines = []
    rl.on('line', line =>{
        lines.push(line);
    });
    rl.on('close', main)
    let rli = 0;
    global.readline = ()=>lines[rli++];
    global.debug = ()=>{};
}

///////////// CODE

function main(){

var n = +readline();
let arr = readline().split(' ').map(n=>+n);
let to_check = {};
for (let x of arr)
    to_check[x-2] = to_check[x-1] = to_check[x] = to_check[x+1] = to_check[x+2] = true;

let min = Infinity;
for (let check in to_check)
{
    let res = 0;
    for (let x of arr)
        res += (x&1)==(check&1) ? 0 : 1;
    debug(check, res)
    min = Math.min(min, res);
}
print(min)

}

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 =>{
    return line.trim();
  });

  main();
})

function main(){

  //first line in input
  let [n] = readLine().split(' ').map(Number);

  let line = readLine().split(' ').map(Number);

let cnto = 0;
  for(let i =0; i<line.length; i++){
  //  if(i % 2 !== 0){
    //  console.log(line[i])
    let x = line[i];
    // line[i]
    cnto += x&1;
  //  }
  }

  console.log(Math.min(cnto, n - cnto));

}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    return;
  }

  const arr = d.split(' ').map(Number);
  let odd = 0;
  let even = 0;

  for (let i = 0; i < arr.length; i++) {
    if (arr[i] % 2) {
      odd++;
    }
    else {
      even++;
    }
  }

  const ans = Math.min(odd, even);

  console.log(ans);

  c++;
});

let i = '';
process.stdin.on('data', (c) => {
  i += c;
});
process.stdin.on('end', () => {
  const { EOL } = require('os');
  const lines = i.split(EOL);
  let chips = lines[1].split(' ');
  chips = chips.map(chip => parseInt(chip, 10));
  chipsMoving(chips);
});

function chipsMoving(chips) {
  let odd = 0;
  let even = 0;
  for (const chip of chips) {
    if (chip % 2 === 0) even++;
    else odd++;
  }
  console.log(Math.min(odd, even));
}

let lines = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', input => lines += input)
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  main()
})

function main() {
  const n = Number(lines[0])
  const x = lines[1].split(' ').map(Number)
  const even = x.filter(a => a % 2 === 0)
  const odd = x.filter(a => a % 2 === 1)

  if(odd.length > even.length) {
    console.log(even.length)
  } else {
    console.log(odd.length)
  }
}

'use strict'

readline();
let a = 0, b = 0;
const x = readline().split(' ').forEach(i => parseInt(i[i.length - 1]) % 2 ? a++ : b++);

write(Math.min(a, b));

var n = readline();
var chips = readline().split(' ');
var odd = 0;
var even = 0;
for (var index = 0; index < n; index++) {
    if((chips[index] % 2) == 1)
        odd++;
    else
        even++;
}
if(even !== 0  && odd !== 0){
    if(even < odd)
        print(Math.min(odd, even));
    else
        print(odd);
}
else
    print("0")

(function() {
var INPUT = ``;
var OUTPUT = ``;

var main = function() {"use strict";
    // TODO
    var n = rdN();
    var A = rdArN().map(v => v%2);
    var min = Infinity;
    for (var i = 0; i < n; ++i) {
        var price = 0;
        for (var j = 0; j < n; ++j) {
            if (j !== i) {
                price += Math.abs(A[i] - A[j]);
            }
        }
        min = Math.min(min, price);
    }
    wr(min);
};

if(INPUT){INPUT=INPUT.split('\n').reverse();
readline=()=>INPUT.pop();
write=(...s)=>{OUTPUT+=[...s].join(' ')};
print=(...s)=>{write(...s);OUTPUT+='\n'};}
const
rdS=readline,
rdN=()=>+rdS(),
rdArS=()=>rdS().split(' '),
rdArN=()=>rdArS().map(v=>+v),
wr=write,
pr=print,
prAr=(a)=>pr(...a),
prOb=(o)=>pr(JSON.stringify(o,null,4)),
crAr=function(length,...fillArgs){return new Array(length).fill(...fillArgs);},
getPrimes=function(n){var sieve=crAr(n+1,true),primes=[],i,j;for(i=2,j=4;j<sieve.length;j=Math.pow(++i,2)){if(sieve[j]){for(;j<sieve.length;j+=i){sieve[j]=false;}}}for(i=2;i<sieve.length;++i){if(sieve[i]){primes.push(i);}}return primes;},
getPrimeFactors=function(n){var primes=getPrimes(Math.floor(Math.sqrt(n))),last=primes.push(n)-1,factors=[],i,p;for(i=0,p=primes[0];primes[last]>1;){if(primes[last]%p===0){primes[last]/=p;factors.push(p);}else{p=primes[++i];}}return factors;},
defineProperty=(o,pN,v)=>Object.defineProperty(o,pN,{value:v,writable:true,enumerable:false,configurable:true});
defineProperty(Array.prototype,'sortLt',function(){return this.sort((a,b)=>a-b);});
defineProperty(Array.prototype,'sortGt',function(){return this.sort((a,b)=>b-a);});

main();
return OUTPUT;
})();

var t = Number(readline());
var inp = readline().split(' ').map(cur => Math.abs(Number(cur)));
var n = {
    odd: 0,
    even: 0
};

inp.forEach(cur => {
    cur % 2 === 0 ? n.even++ : n.odd++;
})

n.odd >= n.even ? print(n.even) : print(n.odd);

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 =>{
    return line.trim();
  });

  main();
})

function main(){

  //first line in input
  let [n] = readLine().split(' ').map(Number);

  let line = readLine().split(' ').map(Number);

let cnto = 0;
  for(let i =0; i<line.length; i++){
   if(i % 2 !== 0){
     cnto++;
   }
  }

  console.log(cnto);

}

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 =>{
    return line.trim();
  });

  main();
})

function main(){

  //first line in input
  let [n] = readLine().split(' ').map(Number);

  let line = readLine().split(' ').map(Number);

let cnto = 0;
  for(let i =1; i<line.length; i++){
  //  if(i % 2 !== 0){
    //  console.log(line[i])
    let x = line[i];
    // line[i]
    cnto += x&1;
  //  }
  }

  console.log(Math.min(cnto, n - cnto));

}

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 =>{
    return line.trim();
  });

  main();
})

function main(){

  //first line in input
  let [n] = readLine().split(' ').map(Number);

  let line = readLine().split(' ').map(Number);

let cnto = 0;
  for(let i =0; i<line.length; i++){
   if(i % 2 !== 0){
     cnto++;
   }
  }

  console.log(Math.min(cnto, n -cnto));

}

var n = readline();
var chips = readline().split(' ');
var odd = 0;
var even = 0;
for (var index = 0; index < n; index++) {
    if((chips[index] % 2) == 1)
        odd++;
    else
        even++;
}

if(even < odd)
    print(Math.min(even - odd));
else
    print(odd);

var n = readline();
var chips = readline().split(' ');
var odd = 0;
var even = 0;
for (var index = 0; index < n; index++) {
    if((chips[index] % 2) == 1)
        odd++;
    else
        even++;
}

if(even < odd)
    print(Math.abs(Math.min(even - odd)));
else
    print(odd);

var n = readline();
var chips = readline().split(' ');
var odd = 0;
var even = 0;
for (var index = 0; index < n; index++) {
    if((chips[index] % 2) === 1)
        odd++;
    else
        even++;
}

if(even < odd)
    print(Math.abs(even - odd));
else
    print(odd);

var n = readline();
var chips = readline().split(' ');
var odd = 0;
var even = 0;
for (var index = 0; index < n; index++) {
    if((chips[index] % 2) == 1)
        odd++;
    else
        even++;
}

if(even < odd)
    print(Math.abs(even - odd));
else
    print(odd);

var n = readline();
var chips = readline().split(' ');
var odd = 0;
var even = 0;
for (var index = 0; index < n; index++) {
    if((chips[index] % 2) == 1)
        odd++;
    else
        even++;
}
if(even !== 0  && odd !== 0){
    if(even < odd)
        print(Math.abs(odd - even));
    else
        print(odd);
}
else
    print("0")