const main = (data) => {
  const testsCount = data[0];

  for (let i = 1; i <= testsCount; i++) {
    let [n, k] =  data[i * 2 - 1].split(' ');
    const arr    =  data[i * 2].split(' ');

    let index = 1;
    let result = 0;

    while (k > 0 && index < arr.length) {
      while (arr[index] > 0 && k > 0) {
        k -= index;
        arr[index]--;
        result++;
      }

      index++;
    }

    if (k < 0) { result-- };

    console.log(+arr[0] + result);
  }
}

let data = '';

process.stdin.on('data', input => data += input);
process.stdin.on('end', () => {
  data = data.split('\n');

  main(data);
});

t = +readline();
while (t-->0){
    ar = readline().split(' ').map(Number);
    n = ar[0], m = ar[1];
    sum = 0;
    readline().split(' ').map(Number).forEach((x,ind)=>{
        if (m >= x*ind){
            m -= x*ind;
            sum += x;
        } else {
            sum += Math.floor(m / ind);
            m = 0;
        }
    });
    print(sum);
}

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

    function foo (arr, days) {
        let first = arr[0];
        let rest = days;

        for (let i = 1; i < arr.length; i++) {
            if (rest <= 0) return first;
            for (let c = 1; c <= arr[i]; c++) {
                if (rest <= 0) return first;
                if (i <= rest ) {
                    first++;
                    rest = rest - i;
                }
            }
        }

        return first;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let days = lines[testCount * 2 - 1].split(' ').map(Number)[1];
        let arr = lines[testCount * 2].split(' ').map(Number);

        let result = foo(arr, days);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var N = one[0];
        var d = one[1];
        var list = myconv(next(),4);
        for(var j = 1; j < N; j++){
            if(d >= list[j] * j){
                list[0] += list[j];
                d -= list[j] * j;
            }else{
                //d:5 list[j]:3 * 2
                list[0] += Math.floor(d / j);
                d = 0;
            }
        }
        output[i] = list[0];
    }
    myout(myconv(output,9));
}

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

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

  if (c % 2 === 1) {
    c++;
    [n, d] = data.split(' ').map(Number);
    return;
  }

  const arr = data.split(' ').map(Number);

  while (d > 0) {
    for (let i = 1; i < arr.length; i++) {
      if (arr[i] !== 0) {
        arr[i - 1] += 1;
        arr[i] -= 1;
        break;
      }
    }

    d--;
  }

  console.log(arr[0]);

  c++;
});

(function () {
    var inp = "";
    process.stdin.on("data", function (d) { return inp += d.toString(); });
    process.stdin.on("end", function () { return main(inp); });
    process.stdin.resume();
})();
function main(rawInput) {
    var lines = rawInput.split("\n");
    var Ntests = parseInt(lines.shift(), 10);
    for (var i = 0; i < Ntests; i++) {
        var _a = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); }), numPiles = _a[0], days = _a[1];
        var piles = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); });
        console.log(solve(days, piles));
    }
}
function solve(days, piles) {
    for (var i = 1; i < piles.length && i <= days; i++) {
        if (piles[i] > 0) {
            piles[i]--;
            piles[0]++;
            days -= i;
            i--;
        }
    }
    return piles[0];
}

t = +readline();
while (t-->0){
    ar = readline().split(' ').map(Number);
    n = ar[0], m = ar[1];
    sum = 0;
    readline().split(' ').map(Number).forEach((x,ind)=>{
        if (m >= x*ind){
            m -= x*ind;
            sum += x;
        } else {
            sum += Math.floor(m / ind);
        }
    });
    print(sum);
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var N = one[0];
        var d = one[1];
        var list = myconv(next(),4);
        for(var j = 1; j < N; j++){
            if(d > list[j] * j){
                list[0] += list[j];
                d -= list[j] * j;
            }else{
                //d:5 list[j]:3 * 2
                list[0] += Math.floor(d / j * list[j]);
                d = 0;
            }
        }
        output[i] = list[0];
    }
    myout(myconv(output,9));
}

Main();
function myout(t){print(t);}//standard output
function next(){return readline();}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//6:1文字に分割  7:1文字に分割し、数値配列へ
//8:半角SPで結合　9:改行で結合　0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));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() {
    var t = myconv(next(),1);
    var output = new Array(t);
    for(var i = 0; i < t; i++){
        var one = myconv(next(),4);
        var N = one[0];
        var d = one[1];
        var list = myconv(next(),4);
        for(var j = 1; j < N; j++){
            if(d >= list[j] * j){
                list[0] += list[j];
                d -= list[j] * j;
            }else{
                //d:5 list[j]:3 * 2
                list[0] += Math.floor(d % list[j]);
                d = 0;
            }
        }
        output[i] = list[0];
    }
    myout(myconv(output,9));
}

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

    function foo (arr, days) {
        let first = arr[0];
        let rest = days;

        for (let i = 1; i < arr.length; i++) {
            if (rest <= 0) return first;
            for (let c = 1; c <= arr[i]; c++) {
                if (rest <= 0) return first;
                if (i + 1 <= rest ) {
                    first++;
                    rest = rest - i;
                }
            }
        }

        return first;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let days = lines[testCount * 2 - 1].split(' ').map(Number)[1];
        let arr = lines[testCount * 2].split(' ').map(Number);

        let result = foo(arr, days);
        answer += result +"\n";
        testCount++;
    }
    console.log(answer);
})

(function () {
    var inp = "";
    process.stdin.on("data", function (d) { return inp += d.toString(); });
    process.stdin.on("end", function () { return main(inp); });
    process.stdin.resume();
})();
function main(rawInput) {
    var lines = rawInput.split("\n");
    var Ntests = parseInt(lines.shift(), 10);
    for (var i = 0; i < Ntests; i++) {
        var _a = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); }), numPiles = _a[0], days = _a[1];
        var piles = lines.shift().split(" ").map(function (v) { return parseInt(v, 10); });
        console.log(solve(days, piles));
    }
}
function solve(days, piles) {
    for (var i = 1; i < piles.length && i < days; i++) {
        if (piles[i] > 0) {
            piles[i]--;
            piles[0]++;
            days -= i;
            i--;
        }
    }
    return piles[0];
}


// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, key, newState, state, value, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      for (key in newState) {
        value = newState[key];
        newState[key] = value % 1000000007;
      }
      state = newState;
    }
    return (state.norequire + state.bomb) % 1000000007;
  };

  print(sweep(readline()));

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, key, newState, state, value, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      for (key in newState) {
        value = newState[key];
        newState[key] = value % 1000000007;
      }
      state = newState;
    }
    return state.norequire + state.bomb;
  };

  print(sweep(readline()));

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, newState, state, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      state = newState;
      console.log(char, state);
    }
    return state.norequire + state.bomb;
  };

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);

// Generated by CoffeeScript 1.7.1
(function() {
  var sweep;

  sweep = function(str) {
    var char, i, newState, state, _i, _len;
    state = {
      require: 1,
      norequire: 1,
      bomb: 0
    };
    for (i = _i = 0, _len = str.length; _i < _len; i = ++_i) {
      char = str[i];
      newState = {};
      if (char === '?') {
        newState.require = state.bomb + state.norequire;
        newState.norequire = state.bomb + state.norequire;
        newState.bomb = state.bomb + state.require;
      } else if (char === '*') {
        newState.bomb = state.require + state.bomb;
        newState.require = newState.norequire = 0;
      } else if (char === '0') {
        newState.norequire = state.norequire;
        newState.require = newState.bomb = 0;
      } else if (char === '1') {
        newState.norequire = state.bomb;
        newState.require = state.norequire;
        newState.bomb = 0;
      } else if (char === '2') {
        newState.require = state.bomb;
        newState.bomb = newState.norequire = 0;
      }
      state = newState;
    }
    return state.norequire + state.bomb;
  };

  print(sweep(readline()));

  'readline = require \'readline\'\nreadline.createInterface(\n  input: process.stdin\n  output: process.stdout\n  terminal: false\n).on \'line\', (str) ->\n  console.log sweep str';

}).call(this);


'use strict';

// var inpArr = `
// 12
// `.trim().split('\n').map(x => x.trim()), inpLine = 0;
// function readline() {
//   return inpArr[inpLine++];
// }
// function print(x) {
//   console.log(x);
// }

var str = readline().trim();

print(str + str.split('').reverse().join(''))

var n = readline();
print(n + [...n].reverse().join(''));

var n = readline();
var n_ = n.split('').reverse().join('');

print(n+n_);

var print = this.print || require('lol-io').print; //print --> outputs result and adds (enter)
var write = this.write || require('lol-io').write; //write --> creates output.txt with output
var readline = this.readline || require('lol-io').readline; //readline --> reads unread line of input.txt

var n, reverse;

n = readline();
answer = n + n.split('').reverse().join('');

write(answer);

var s = readline();
var s_ = "";
for (var i in s) {
	s_ = s[i] + s_;
}
write(s+s_);

// načtu číslo
var number = readline();

var result = number;
var t = result;

for (var i = t.length-1; i >= 0; i--) {
	result += t[i];
}

write(result);

var str = readline().trim();
str += str.split('').reverse().join('');
print(str);

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

function main() {
	let n = readLine().split('');
	let res = n.join('') + n.reverse().join('');
	console.log(res);
}

var n = readline();

write(n);
n = n.split("").reverse().join("");
write(n);

// načtu číslo
var number = Number(readline());

var result = String(number);
var t = result;

for (var i = t.length-1; i >= 0; i--) {
	result += t[i];
}

write(result);


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

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

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


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

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

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

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


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])
}

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 ''
}

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


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

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

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

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

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


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")

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

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

'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));

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

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")