var t = readline();
for(var i = 0 ; i < t ; i++){
    var n = readline(),
        a = readline().split(' ') ,
        eCounter = 0 , oCounter = 0;
        for(var j = 0 ; j < n ; j++){
            if(a[j]%2 === 0 ){
                eCounter++;
            }
            else{
                oCounter++;
            }
        }
        if(oCounter > eCounter){
            print(eCounter);
        }
        else{
            print(oCounter);
        }
}

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 e = 0
    for(j =1; j <= n * 2;j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
            var even = 0
            var odd = 0
            var k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(k[l] % 2 === 0){
                    even++
                }else{
                    odd++
                }
            }
            console.log(Math.min(odd, even))
        }
    }

});

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 e = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
        var a = 0
        var b = 0
        var k = lines[j].split(' ').map(Number)
        for(l = 0; l < e; l++){
            if(k[l] % 2 == 1){
                a ++
            }else{
                b++
            }
        }
                console.log(Math.min(a,b))

        }
    }

});

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

//started here

function main() {

  let t = parseInt(readline());

while (t--) {
  let n = parseInt(readline());
  let m = readline()
    .split(" ")
    .map((x) => parseInt(x));
  let result;
  let even = [];
  let odd = [];
  for (let i = 0; i < m.length; i++) {
    if (m[i] % 2 == 0) {
      even.push(m[i]);
    } else {
      odd.push(m[i]);
    }
  }

  if (even.length === 0 || odd.length === 0) {
    result = 0;
  } else if (odd.length > even.length) {
    result = even.length;
  } else if (even.length > odd.length) {
    result = odd.length;
  } else if (odd.length === even.length) {
    result = even.length;
  }

  console.log(result);
}

}

//Bismillah
"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 t = parseInt(readline());

while (t--) {
  let n = parseInt(readline());
  let m = readline()
    .split(" ")
    .map((x) => parseInt(x));
  let result;
  let even = [];
  let odd = [];
  for (let i = 0; i < m.length; i++) {
    if (m[i] % 2 == 0) {
      even.push(m[i]);
    } else {
      odd.push(m[i]);
    }
  }

  if (even.length === 0 || odd.length === 0) {
    result = 0;
  } else if (odd.length > even.length) {
    result = even.length;
  } else if (even.length > odd.length) {
    result = odd.length;
  } else if (odd.length === even.length) {
    result = even.length;
  }

  console.log(result);
}

}

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);
            var ans = 0;
            for(j = 0; j < n; j++){
                if(a[j] % 2 == 1){
                    ans++;
                }
            }
            console.log(Math.min(ans, n - ans));
        }
    }
});

let y = '';
process.stdin.on('data', c => y += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = y.split(EOL);
	var t = lines[0];
	var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var od = 0;
            var ev = 0;
            for(j = 0; j < e; j++){
                if(k[j] % 2 == 1){
                    od++;
                }else{
                    ev++;
                }
            }
            console.log(Math.min(od, ev));
        }
    }
});

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function 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++) {
        readline();
        let arr = readline().split(' ').map(Number);

        let odd = arr.filter(x => x % 2 === 1).length;
        let even = arr.filter(x => x % 2 === 0).length;

        if (odd > even) {
            output(arr.length - odd);
        } else {
            output(arr.length - even);
        }
    }
}

const readline = require('readline');

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

conIO.setPrompt('');

function reallyAwkward(n) {
    conIO.once('line', () => {
        conIO.once('line', arr => {
            arr = arr.split(' ');
            let oddCnt = 0, evenCnt = 0;
            arr.forEach(x => x % 2 === 0 ? ++evenCnt : ++oddCnt);
            console.log(Math.min(oddCnt, evenCnt));
            if (n != 1)
                reallyAwkward(n - 1);
            else conIO.close();
        });
    });
}

conIO.once('line', n => {
    reallyAwkward(n);
});

'use strict';
// HEADER:
const print = function(arg){
  let str = arg;
  if (arguments.length>1)
    str = Array.prototype.slice.call(arguments).join(' ');
  process.stdout.write(str+'\n');
};
let IS_MULTITEST, testN, tests;
const pcalc = (testN, toPrint)=>{
  let res = CALC(testN);
  if (Array.isArray(res)){
    toPrint.push(res.join(' '));
  } else if (Number.isFinite(res) || typeof res=='string'){
    toPrint.push(res+'');
  }
  if (process.env.DEBUG && toPrint.length){
    let ans = toPrint.pop();
    print(ans);
    let expected = tests[testN-1];
    if (expected){
      if (expected==ans)
        console.log('\x1b[32m%s\x1b[0m', 'correct');
      else {
        console.log('\x1b[31m%s\x1b[0m', 'wrong, expected:', expected);
      }
    }
  }
};

const main = ()=>{
  let toPrint = [];
  L('\nSolving:');
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(testN, toPrint);
  } else {
    pcalc(1, toPrint);
  }
  if (toPrint.length){
    print(toPrint.join('\n'));
  }
};

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(`\nTest #${testN}`, obj);

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

tests = [
``, // Test #1
``, // Test #2
``, // Test #3
``, // Test #4
``, // Test #5
];

// SOLUTION:
IS_MULTITEST = true;

const CALC = (testN)=>{
  // READING:
  let [n] = ra();
  let A = ra();
  LT({n, A});
  // PROCESSING:
  let ans1 = 0;
  let ans2 = 0;
  for (let i=0; i<n; i++){
    if (A[i]%2){
      ans1++;
    } else
      ans2++;
  }

  return Math.min(n-ans1, n-ans2);
};

/**
 * Format:
 * {type: 'number', namedVariable?: string }
 * {type: 'repeat', instructionCount: number, count: number, namedVariable?: string }
 * {type: 'array', namedVariable?: string }
 */
const readline = require('readline');

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

  let resolvePromise = null;
  const donePromise = new Promise((res, rej) => {
    resolvePromise = res;
  });

  function waitUntilDone() {
    return donePromise;
  }

  /**
   * {type: 'repeat', count: number, iteration: number, basePointer: number, pointer: number, instructionCount: number, context: array }
   */
  const stack = [];
  let pc = -1;

  function finished() {
    if (pc >= instructions.length) {
      return true;
    }
    return false;
  }

  function checkFinished() {
    // console.log(`Finish check ${pc}, ${JSON.stringify(stack)}, ${pc >= instructions.length}, ${stack.length === 1 && stack[0].pointer === stack[0].instructionCount && stack[0].count === stack[0].iteration + 1}`);
    if (pc >= instructions.length) {
      return true;
    }
    if (stack.length === 1 && stack[0].pointer === stack[0].instructionCount && stack[0].count === stack[0].iteration + 1) {
      return true;
    }
    return false;
  }

  function getNextInstructionContext() {
    if (!stack.length) {
      return {
        index: ++pc,
      }
    }
    const lastStack = stack[stack.length - 1];
    if (lastStack.pointer === lastStack.instructionCount) {
      lastStack.pointer = 0;
      lastStack.iteration = lastStack.iteration + 1;
    }
    if (lastStack.count === lastStack.iteration) {
      stack.pop();
      pc = lastStack.basePointer + lastStack.instructionCount + 1;
      return {
        index: pc,
      }
    }

    lastStack.pointer = lastStack.pointer + 1;
    return {
      index: lastStack.basePointer + lastStack.pointer,
      context: {
        namedPath: [...lastStack.context.namedPath, lastStack.iteration]
      }
    }
  }

  function pushRepeatToStack(instruction, index, context) {
    stack.push({
      type: 'repeat',
      count: typeof instruction.count === 'number' ? instruction.count : context && context.namedPath ? getIn(mappedVariables, [...context.namedPath, instruction.count]) : mappedVariables[instruction.count],
      iteration: 0,
      basePointer: index,
      pointer: 0,
      instructionCount: instruction.instructionCount,
      context: {
        namedPath: context && context.namedPath ? [...context.namedPath, instruction.namedVariable] : [instruction.namedVariable],
      }
    })
    setIn(mappedVariables, context && context.namedPath ? [...context.namedPath, instruction.namedVariable] : [instruction.namedVariable], []);
  }

  function nextInstruction() {
    if (finished()) {
      // console.warn('Calling nextInstruction after finished, something is wrong');
      return;
    }
    while (true) {
      const { index, context } = getNextInstructionContext();
      const instruction = instructions[index];

      // console.log(`Debugging: ${index}, ${JSON.stringify(context)}, ${JSON.stringify(instruction)}`);
      switch (instruction.type) {
        case 'number':
        case 'array':
          return {
            ...instruction,
            namedPath: instruction.namedVariable ? context && context.namedPath ? [...context.namedPath, instruction.namedVariable] : [instruction.namedVariable] : undefined,
          }
        case 'repeat':
          pushRepeatToStack(instruction, index, context);
          break;
        default:
          // console.warn('Unclear instruction, abort');
          return;
      }
    }
  }

  function getIn(object, path) {
    for (let i = 0; i < path.length; ++i) {
      object = object[path[i]];
    }
    return object;
  }

  function setIn(object, path, value) {
    for (let i = 0; i < path.length - 1; ++i) {
      if (object[path[i]] == null) {
        object[path[i]] = {};
      }
      object = object[path[i]];
    }
    object[path[path.length - 1]] = value;
  }

  rl.on('line', line => {
    if (finished()) {
      return;
    }
    const { type, namedPath } = nextInstruction();
    switch (type) {
      case 'number':
        if (namedPath) {
          setIn(mappedVariables, namedPath, parseInt(line));
        }
        break;
      case 'array':
        if (namedPath) {
          setIn(mappedVariables, namedPath, line.trim().split(' ').map(x => parseInt(x)));
        }
        break;
      default:
        // console.warn(`Value unread, received type ${type}.`);
    }

    if (checkFinished()) {
      resolvePromise(mappedVariables);
      rl.close();
    }
  });
  return {
    waitUntilDone,
  };
}

function solve({numbers}) {
  if (numbers.length === 1) {
    return 1;
  } else if (numbers.length === 2) {
    return (numbers[0] + numbers[1]) % 2 === 0 ? 0 : 2;
  }

  /**
   * Min case:
   * 1 2 3
   * [0, 1, 2] length = 3
   */

  const chunks = [0];
  for (let i = 1; i < numbers.length; ++i) {
    if ((numbers[i] + numbers[i - 1]) % 2 !== 0) {
      chunks.push(i);
    }
  }
  let firstSum = 0;
  for (let i = 0; i < chunks.length; i = i + 2) {
    if (i === chunks.length - 1) {
      firstSum = firstSum + numbers.length - chunks[i];
    } else {
      firstSum = firstSum + chunks[i + 1] - chunks[i];
    }
  }

  let secondSum = 0;
  for (let i = 1; i < chunks.length; i = i + 2) {
    if (i === chunks.length - 1) {
      secondSum = secondSum + numbers.length - chunks[i];
    } else {
      secondSum = secondSum + chunks[i + 1] - chunks[i];
    }
  }

  return Math.min(firstSum, secondSum);
}
(async function main() {
  const reader = createCLIReader([
    { type: 'number', namedVariable: 'numberOfTestCase' },
    { type: 'repeat', instructionCount: 2, count: 'numberOfTestCase', namedVariable: 'testCase' },
    { type: 'number', namedVariable: 'testCaseLength' },
    { type: 'array', namedVariable: 'numbers' }
  ]);
  const schema = await reader.waitUntilDone();

  for (let i = 0; i < schema.numberOfTestCase; ++i) {
    console.log(solve(schema.testCase[i]));
  }
})();

/**
 * Author : Fazlul Hoque
 * Node.js version : 12.16.3
 * command : node fileName.js <input.txt >output.txt
 */
"use strict";
process.stdin.resume();
process.stdin.setEncoding("utf-8");
let inputString = ""; //An array of  raw inputs (includes 'n,\r , not usable. need to process before use)
let currentLine = 0; //input sequence controller variable.

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

/********** Utility Functions Start **********/
/**
 *  read row Input
 * @returns string
 */
function _readRawLine() {
    return inputString[currentLine++];
}
function readLine(){
    // return _readRawLine().replace(/\s+$/g, '');
    return _readRawLine().replace('\r', '');
}

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

function readSingleInt() {
    const p = readLine();
    return parseInt(p);
}

function readIntArray() {
    return readLine().split(" ").map((v) => parseInt(v));
}

function readArray() {
    return readLine().split(" ");
}

function int(n) {
    return parseInt(n);
}
/********** Utility Functions End **********/
/**
 * Don't Touch this fucntion at all , unless you know what are you doing!
 */
function main() {
    solve();
}

// ********** actual Code Starts from here **********

function solve() {

     let t = readSingleInt();
     while(t--)
     {
         let n = readSingleInt();
         let ar = readIntArray();
         let cnt =0;
         ar.forEach(n=> cnt += n&1)
         console.log(Math.min(n-cnt,cnt));

     }

}

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

let input = [];
rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solution(input);
  process.exit();
});

function solution(_input) {
  const input = _input[Symbol.iterator]();
  const T = Number(input.next().value);
  const results = [];
  for (let tc = 0; tc < T; tc++) {
    const N = Number(input.next().value);
    const A = input.next().value.split(" ").map(Number);
    const evenCnt = A.reduce((acc, v) => acc + ((v & 1) === 0 ? 1 : 0), 0);
    const oddCnt = N - evenCnt;
    results.push(Math.min(N - evenCnt, N - oddCnt));
  }
  console.log(results.join("\n"));
}

function solve() {
   const n = Number(read());
   const a = readArray(Number);
   let oddCount = 0;
   for (let i = 0; i < n; i++) {
      if (a[i] & 1) {
         oddCount++;
      }
   }
   write(Math.min(oddCount, n - oddCount));
}

function init() {
   try {
      var T = 1;
      T = Number(read());
      for (var t = 0; t < T; t++) {
         solve();
      }
   } catch (e) {
      write(e + e.stack);
   }
}

function modPow(a, n, mod) {
   let d = a;
   let curN = n;
   let ans = 1n;
   while(curN) {
      if (curN & 1n) {
         ans = modMul(ans, d, mod);
      }
      curN >>= 1n;
      d = modMul(d, d, mod);
   }
   return ans;
}

function modMul(a, b, mod) {
   return (a * b) % mod;
}

function modSum(a, b, mod) {
   return (a + b) % mod;
}

function modDiff(a, b, mod) {
   return (a + mod - b) % mod;
}

function isZero(num) {
   if (typeof num === 'bigint') {
      return num === 0n;
   }
   return num === 0;
}
function div(a, b) {
   if (typeof a !== typeof b) {
      throw new Error('Different types on division');
   }
   if (typeof a === 'bigint') {
      return a / b;
   }
   return Math.floor(a / b);
}

function gcd(x, y) {
   if (isZero(y)) {
      return x;
   }
   return gcd(y, x % y);
}

function lcm(x, y) {
   return div(x * y, gcd(x, y));
}

function allIndexOf(arr, value) {
   var index = arr.indexOf(value)
   var ans = [];
   while (index !== -1) {
      ans.push(index);
      index = arr.indexOf(value, index + 1);
   }
   return ans;
}

function xor(a, b, k) {
   if (k === 2) {
      return a ^ b;
   }
}

function decToBin(num) {
   let n = num;
   const ans = [];
   while(n > 0) {
      ans.push(n & 1);
      n = (n >> 1);
   }
   return ans;
}

function binToDec(binN) {
   let ans = 0;
   for (let i = binN.length - 1; i >= 0; i--) {
      ans = ((ans << 1) | binN[i]);
   }
   return ans;
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

function readArray(f) {
   return read().split(' ').map(f);
}

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;

   var needWriteFile = false;

   var writeResult = '';
   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');
         init();
         if (needWriteFile) {
            fs.writeFile(path.join(__dirname, outTextName), writeResult, (err) => {
               err ? console.error(err) : console.log('good')
            });
         }
      });
   } else {
      MEMORY = fs.readFileSync(0, 'utf-8').split('\r\n');
      init();
   }
} else {
   init();
}

function write(value) {
   if (needWriteFile) {
      writeResult += value + '\n';
      return;
   }
   isNode ? console.log('' + value) : print('' + value);
}
function read() {
   return isNode ? MEMORY[MEMORY_INDEX++] : readline();
}
function readAll() {
   return isNode && MEMORY;
}

'use strict';

function solve(n, a) {
  let odd = 0,
      even = 0;
  for (let num of a) {
    if (num & 1) odd++;else even++;
  }
  return Math.min(odd, even);
}

async function main(read) {
  try {
    let res = [];
    let t = Number(await read());
    while (t--) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res.push(solve(n, a));
    }
    console.log(res.join('\n'));
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', () => {
  inputs = str.split('\n').values();
  main(read);
});

T = readline()
while (T--) {
   n = readline()
   x = readline().split(' ').map(x => +x)
   sumOne = 0
   sumTwo = 0
   for(i=0; i<n; i++){
      if(x[i] %2 != 0)
         sumOne++
      else
         sumTwo++
   }
   if(sumOne < sumTwo)
      print(sumOne)
   else
      print(sumTwo)
}

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 even = 0
    var odd = 0
    var e = 0
    for(j =1; j <= n * 2;j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
            var k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(k[l] % 2 === 0){
                    even++
                }else{
                    odd++
                }
            }
            console.log(Math.min(odd, even))
        }
    }

});

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 e = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
        var a = 0
        var k = lines[j].split(' ').map(Number)
        for(l = 0; l < e; l++){
            if(k[l] % 2 == 1){
                a ++
            }
        }
                console.log(a)

        }
    }

});

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 e = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
        var a = 0
        var k = lines[j].split(' ').map(Number)
        for(l = 0; l < e; l++){
            if(k % 2 == 1){
                a ++
            }
        }
                console.log(a)

        }
    }

});

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 e = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            e = lines[j]
        }else{
        var a = 0
        var k = lines[j].split(' ').map(Number)
        for(l = 0; l < e; l++){
            if(k % 2 == 1){
                a ++
            }
        }
        }
        console.log(a)
    }

});

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 e = 0

    for(j = 1; j <= n * 2; j++){
        if(j % 2 === 0){
        var s = 0
        var a = lines[j].split(' ').map(Number)
        for(k = 0; k < e; k++){
            if(a[k] % 2 == 1 && a[k + 1] % 2 === 0 || a[k] % 2 === 0 && a[k + 1] % 2 == 1  ){
                s++
                k++
            }else{
                continue;
            }
        }
        console.log(s)
        }else{
            e = lines[j]
        }
    }
});

//Bissmillah.
"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 t = parseInt(readline());

while (t--) {
  let n = parseInt(readline());
  let m = readline()
    .split(" ")
    .map((x) => parseInt(x));
  let result;
  let even = [];
  let odd = [];
  for (let i = 0; i < m.length; i++) {
    if (m[i] % 2 == 0) {
      even.push(m[i]);
    } else {
      odd.push(m[i]);
    }
  }

  if (even.length === 0 || odd.length === 0) {
    result = 0;
  } else if (even.length > odd.length) {
    result = odd.length;
  } else {
    result = 0;
  }

  console.log(result);
}

}

//Bissmillah.
"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 t = parseInt(readline());

while (t--) {
  let n = parseInt(readline());
  let m = readline()
    .split(" ")
    .map((x) => parseInt(x));
  let result;
  let even = [];
  let odd = [];
  for (let i = 0; i < m.length; i++) {
    if (m[i] % 2 == 0) {
      even.push(m[i]);
    } else {
      odd.push(m[i]);
    }
  }

  if (even.length === 0 || odd.length === 0) {
    result = 0;
  } else if (odd.length > even.length) {
    result = even.length;
  } else if (even.length > odd.length) {
    result = odd.length;
  } else if (odd.length === even.length) {
    result = m.length;
  }

  console.log(result);
}

}

//Bissmillah.
"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 t = parseInt(readline());

while (t--) {
  let n = parseInt(readline());
  let m = readline()
    .split(" ")
    .map((x) => parseInt(x));
  let result;
  let even = [];
  let odd = [];
  for (let i = 0; i < m.length; i++) {
    if (m[i] % 2 == 0) {
      even.push(m[i]);
    } else {
      odd.push(m[i]);
    }
  }

  if (even.length == 0 || odd.length == 0) {
    result = 0;
  } else if (odd.length > even.length) {
    result = even.length;
  } else if (even.length > odd.length) {
    result = odd.length;
  } else {
    result = 0;
  }

  console.log(result);
}

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function 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++) {
        readline();
        let arr = readline().split(' ').map(Number);

        let odd = arr.filter(x => x % 2 === 1).length;
        let even = arr.filter(x => x % 2 === 0).length;

        if (odd > even) {
            output(arr.length - even);
        } else {
            output(arr.length - odd);
        }
    }
}

const readline = require('readline');

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

conIO.setPrompt('');

function reallyAwkward(n) {
    conIO.once('line', () => {
        conIO.once('line', arr => {
            arr = arr.split(' ');
            let oddCnt = 0, evenCnt = 0;
            arr.forEach(x => x % 2 == 0 ? ++evenCnt : ++oddCnt);
            conIO.write(Math.min(oddCnt, evenCnt) + '\n');
            if (n != 1)
                reallyAwkward(n - 1);
            else conIO.close();
        });
    });
}

conIO.once('line', n => {
    reallyAwkward(n);
});

'use strict';
// HEADER:
const print = function(arg){
  let str = arg;
  if (arguments.length>1)
    str = Array.prototype.slice.call(arguments).join(' ');
  process.stdout.write(str+'\n');
};
let IS_MULTITEST, testN, tests;
const pcalc = (testN, toPrint)=>{
  let res = CALC(testN);
  if (Array.isArray(res)){
    toPrint.push(res.join(' '));
  } else if (Number.isFinite(res) || typeof res=='string'){
    toPrint.push(res+'');
  }
  if (process.env.DEBUG && toPrint.length){
    let ans = toPrint.pop();
    print(ans);
    let expected = tests[testN-1];
    if (expected){
      if (expected==ans)
        console.log('\x1b[32m%s\x1b[0m', 'correct');
      else {
        console.log('\x1b[31m%s\x1b[0m', 'wrong, expected:', expected);
      }
    }
  }
};

const main = ()=>{
  let toPrint = [];
  L('\nSolving:');
  if (IS_MULTITEST){
    let T = +readline()
    for (testN=1; testN<=T; testN++)
      pcalc(testN, toPrint);
  } else {
    pcalc(1, toPrint);
  }
  if (toPrint.length){
    print(toPrint.join('\n'));
  }
};

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(`\nTest #${testN}`, obj);

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

tests = [
``, // Test #1
``, // Test #2
``, // Test #3
``, // Test #4
``, // Test #5
];

// SOLUTION:
IS_MULTITEST = true;

const CALC = (testN)=>{
  // READING:
  let [n] = ra();
  let A = ra();
  LT({n, A});
  // PROCESSING:
  let ans = 0;
  for (let i=0; i<n-1; i++){
    if (A[i]%2!=A[i+1]%2){
      ans++;
      i++;
    }
  }

  return ans;
};

const readline = require('readline');
(function main() {
  const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
  });
  rl.on('line', line => {
    console.log(`Received: ${line}`);
  });
})();


var n = parseInt( readline() );
var m0 = readline().split(' ').map(function(v){ return parseInt(v); });
var m1 = [];
for(var i=0; i<n; i++){
	m1[i] = 0;
}

var ret = [];
function put(i){
	while( m1[i]<m0[i] ){
		ret.push('P');
		m1[i]++;
		if(m1[i+1]<m0[i+1]){
			ret.push('RPL');
			m1[i+1]++
		}else if(m1[i-1]<m0[i-1]){
			ret.push('LPR');
			m1[i-1]++
		}else{
			if(i==0){
				ret.push('RL');
			}else{
				ret.push('LR');
			}

		}
	}
}
for(var i=0; i<n; i++){
	put(i);
	ret.push('R');
}
ret.length -= 2;
print(ret.join(''));

var line1 = readline().split(' ');
var n = parseInt(line1[0]);
var line2 = readline().split(' ');
	var total = [], put=[];
	var total_sum=0, put_sum=0;

	for (var i=0; i < n; i++){
	total[i] = parseInt(line2[i]);
	total_sum+=total[i];
	put[i] = 0;
	}

  /* print ("total: " +total_sum+ "\n"); */

var  max = Math.max.apply(null, total);
res='';

for (var i=0;  i < 2*max;  i++) {

	for (var k=0; k < n; k++){

		if ( i%2==0) {

			if (put[k] < total[k] && res.slice(-1)!='P'){
			res+='P';
			put_sum++;
			put[k]++;
			}

			if (put_sum < total_sum && k!=n-1) res+='R';

		}

		else{

			if (put[n-k-1] < total[n-k-1] && res.slice(-1)!='P') {
			res+='P';
			put_sum++;
			put[n-k-1]++;
			}

			if (put_sum < total_sum && k!=n-1)  res+='L';

		}

	}

}

print(res);

var line1 = readline().split(' ');
var n = parseInt(line1[0]);
var line2 = readline().split(' ');
	var total = [], put=[];
	var total_sum=0, put_sum=0;

	for (var i=0; i < n; i++){
	total[i] = parseInt(line2[i]);
	total_sum+=total[i];
	put[i] = 0;
	}

  /* print ("total: " +total_sum+ "\n"); */

var  max = Math.max.apply(null, total);
res='';

for (var i=0;  i < 2*max;  i++) {

	for (var k=0; k < n; k++){

		if ( i%2==0) {

			if (put[k] < total[k] && res.slice(-1)!='P'){
			res+='P';
			put_sum++;
			put[k]++;                    			/*    print(put_sum+" "+"put"+k+"="+put[k]+"   ");  */
			}

			if (put_sum < total_sum && k!=n-1){

			res+='R'

			}

		}

		else{

			if (put[n-k-1] < total[n-k-1] && res.slice(-1)!='P') {
			res+='P';
			put_sum++;
			put[n-k-1]++;                     /*     print(put_sum+" "+"put"+k+"="+put[k]+"   ");  */
			}

			if (put_sum < total_sum && k!=n-1) {

							  /*	print(put_sum+" "+"put"+k+"="+put[k]+"   ");   */

			res+='L'

			}

		}

	}

}

print(res);

;(function () {

	var n = +readline();
	var s = 0;
	var t = readline().split(' ').map(function (e) { var _e = +e; s += _e; return _e; });
	var p = 0;

	var str = '';
	var l, r;

	while (s) {

		if (t[p]) {
			t[p]--;
			str += 'P';
			if (--s) {

				if (p == 0) {
					str += 'R';
					p++;
					continue;
				}

				if (p == (n-1)) {
					str += 'L';
					p--;
					continue;
				}
			} else {
				break;
			}
		}

		for (var r = p + 1; r < n; r++)
			if (t[r]) break;
		if (!t[r]) r = -1;

		for (var l = p - 1; l > -1; l--)
			if (t[l]) break;
		if (!t[l]) l = -1;

		if (r == -1 && l == -1) {
			if (p == 0) {
				str += 'R';
				p++;
			}

			if (p == (n-1)) {
				str += 'L';
				p--;
			}
		} else {
			if (r > l) {
				str += 'R';
				p++;
			}
			else{
				str += 'L';
				p--;
			}
		}

	}

	print(str);

}).call(this)

var
    num  = parseInt(readline()),
    k    = readline().split(" "),
    sum  = 0,
    length = k.length - 1
    pos  = 0,
    cur  = 0,
    str  = ""
;

for(var i in k) {
    k[i] = parseInt(k[i]);
    sum += k[i];
}

while(1){

    if (k[pos] > 0) {
        str += "P";
        cur ++;
        k[pos]--;
        if (cur == sum) break;
    }

    if (pos == length) {
        pos -= 1;
        str += "L";
        continue;
    }

    if (pos > 0 && k[pos-1] > 0) {
        pos--;
        str += "L";
    } else {
        pos++;
        str += "R";
    }
}

print(str);

function main(){
    var i, n = parseInt(readline());
    var a = readline().split(' ');
    for(i = 0 ;  i < n ; ++i){
        a[i] = parseInt(a[i]);
    }
    var last = 0, str = "";
    for(i = 0 ; i < n - 1 ; ++i){
        if ( i ){
            str+="R";
        }
        while ( a[i] > 0 ){
            str += "P";
            --a[i];
            if ( a[i] > 0 ){
                str += "RL";
            }
        }

    }
    if ( a[n-1] > 0 ){
        str += "R";
    }
    while( a[n-1] > 0 ){
        str += "P";
        --a[n-1];
        if ( a[n-1] > 0 ){
            str += "LR";
        }
    }
    print(str);
}
main();

var n = 0;
var arr;
var ans = "";

n = readline();
arr = readline().split(" ");

for(var i=0; i<n; i++) {
    var first = true;
    while(arr[i]>0) {
        if(!first) {
            if(i==0) {
                ans += 'RL';
            } else {
                ans += 'LR';
            }
        }
        first = false;
        ans += "P";
        arr[i]--;
    }
    if(i<n-1) ans += 'R';
}
print(ans);

var n = parseInt(readline());
var mas = readline();
var str = "";
mas = mas.split(" ");
var max = 0;
for(var i = 0; i < n; ++i)
{
    mas[i] = parseInt(mas[i]);
    if(mas[i] > max){max = mas[i];}
}
max *= 2;
while(max != 0)
{
    for(var i = 0; i < n; ++i)
    {
        if(mas[i] != 0 && i != 0){mas[i] --; str += "P";}
        if(i != n-1){str += "R";}
    }
    max --;
    if(max == 0){break;}
    for(var i = n-1; i >= 0; --i)
    {
        if(mas[i] != 0 && i != n-1){mas[i] --; str += "P";}
        if(i != 0){str += "L";}
    }
    max --;
    if(max == 0){break;}
}
print(str);

var n = parseInt( readline() );
var m0 = readline().split(' ').map(function(v){ return parseInt(v); });
var m1 = [];
for(var i=0; i<n; i++){
	m1[i] = 0;
}

var ret = [];
function put(i){
	while( m1[i]<m0[i] ){
		ret.push('P');
		m1[i]++;
		if(m1[i+1]<m0[i+1]){
			ret.push('RPL');
			m1[i+1]++
		}else if(m1[i-1]<m0[i-1]){
			ret.push('LPR');
			m1[i-1]++
		}else{
			if(m1[i-1]){
				ret.push('LR');
			}else{
				ret.push('RL');
			}

		}
	}
}
for(var i=0; i<n; i++){
	put(i);
	ret.push('R');
}
ret.length -= 2;
print(ret.join(''));

var n = parseInt( readline() );
var m0 = readline().split(' ').map(function(v){ return parseInt(v); });
var m1 = [];
for(var i=0; i<n; i++){
	m1[i] = 0;
}

var ret = [];
function put(i){
	while( m1[i]<m0[i] ){
		ret.push('P');
		m1[i]++;
		if(m1[i+1]<m0[i+1]){
			ret.push('RPL');
			m1[i+1]++
		}else if(m1[i-1]<m0[i-1]){
			ret.push('LPR');
			m1[i-1]++
		}else{
			ret.push('RL');
		}
	}
}
for(var i=0; i<n; i++){
	put(i);
	ret.push('R');
}

print(ret.join(''));

var n = 0;
var arr;
var ans = "";

n = readline();
arr = readline().split(" ");

for(var i=0; i<n; i++) {
    var first = true;
    while(arr[i]>0) {
        if(!first) {
            if(i==0) {
                ans += 'RL';
            } else {
                ans += 'LR';
            }
        }
        first = !first;
        ans += "P";
        arr[i]--;
    }
    if(i<n-1) ans += 'R';
}
print(ans);

var n = parseInt(readline());
var mas = readline();
var str = "";
mas = mas.split(" ");
var max = 0;
for(var i = 0; i < n; ++i)
{
    mas[i] = parseInt(mas[i]);
    if(mas[i] > max){max = mas[i];}
}
mas[0] --;
str = "P";
while(max != 0)
{
    for(var i = 0; i < n; ++i)
    {
        if(mas[i] != 0 && i != 0){mas[i] --; str += "P";}
        if(i != n-1){str += "R";}
    }
    max --;
    if(max == 0){break;}
    for(var i = n-1; i >= 0; --i)
    {
        if(mas[i] != 0 && i != n-1){mas[i] --; str += "P";}
        if(i != 0){str += "L";}
    }
    max --;
    if(max == 0){break;}
}
print(str);

var n = parseInt(readline());
var mas = readline();
var str = "";
mas = mas.split(" ");
var max = 0;
for(var i = 0; i < n; ++i)
{
    mas[i] = parseInt(mas[i]);
    if(mas[i] > max){max = mas[i];}
}
while(max != 0)
{
    for(var i = 0; i < n; ++i)
    {
        if(mas[i] != 0 && i != 0){mas[i] --; str += "P";}
        if(i != n-1){str += "R";}
    }
    max --;
    if(max == 0){break;}
    for(var i = n-1; i >= 0; --i)
    {
        if(mas[i] != 0 && i != n-1){mas[i] --; str += "P";}
        if(i != 0){str += "L";}
    }
    max --;
    if(max == 0){break;}
}
print(str);

var n = parseInt(readline());
var mas = readline();
var str = "";
mas = mas.split(" ");
var max = 0;
for(var i = 0; i < n; ++i)
{
    mas[i] = parseInt(mas[i]);
    if(mas[i] > max){max = mas[i];}
}
mas[0] --;
str = "P";
max *= 2;
while(max != 0)
{
    for(var i = 0; i < n; ++i)
    {
        if(mas[i] != 0 && i != 0){mas[i] --; str += "P";}
        if(i != n-1){str += "R";}
    }
    max --;
    if(max == 0){break;}
    for(var i = n-1; i >= 0; --i)
    {
        if(mas[i] != 0 && i != n-1){mas[i] --; str += "P";}
        if(i != 0){str += "L";}
    }
    max --;
    if(max == 0){break;}
}
print(str);

var n = parseInt(readline());
var mas = readline();
var str = "";
mas = mas.split(" ");
var max = 0;
for(var i = 0; i < n; ++i)
{
    mas[i] = parseInt(mas[i]);
    if(mas[i] > max){max = mas[i];}
}
while(max != 0)
{
    for(var i = 0; i < n; ++i)
    {
        if(mas[i] != 0){mas[i] --; str += "P";}
        if(i != n-1){str += "R";}
    }
    max --;
    if(max == 0){break;}
    for(var i = n-1; i >= 0; --i)
    {
        if(mas[i] != 0){mas[i] --; str += "P";}
        if(i != 0){str += "L";}
    }
    max --;
    if(max == 0){break;}
}
print(str);

var n = parseInt(readline());
var mas = readline();
var str = "";
mas = mas.split(" ");
var max = 0;
for(var i = 0; i < n; ++i)
{
    mas[i] = parseInt(mas[i]);
    if(mas[i] > max){max = mas[i];}
}
while(max != 0)
{
    for(var i = 0; i < n; ++i)
    {
        if(mas[i] != 0){mas[i] --; str += "P";}
        str += "R";
    }
    max --;
    if(max == 0){break;}
    for(var i = n-1; i >= 0; --i)
    {
        if(mas[i] != 0){mas[i] --; str += "P";}
        str += "L";
    }
    max --;
    if(max == 0){break;}
}
print(str);

var line1 = readline().split(' ');
var n = parseInt(line1[0]);
var line2 = readline().split(' ');
	var total = [], put=[];
	var total_sum=0, put_sum=0;

	for (var i=0; i < n; i++){
	total[i] = parseInt(line2[i]);
	total_sum+=total[i];
	put[i] = 0;
	}

var  max = Math.max.apply(null, total);
res='';

for (var i=0;  i < max;  i++) {

	for (var k=0; k < n; k++){

		if ( i%2==0) {

			if (put[k] < total[k] && res.slice(-1)!='P'){
			res+='P';
			put_sum++;
			}

			if (put_sum < total_sum && k!=n-1){

			res+='R'

			}

		}

		else{

			if (put[n-k-1] < total[n-k-1] && res.slice(-1)!='P') {
			res+='P';
			put_sum++;
			}

			if (put_sum < total_sum && k!=n-1) {

			res+='L'

			}

		}

	}

}

print(res);

var line1 = readline().split(' ');
var n = parseInt(line1[0]);
var line2 = readline().split(' ');
	var total = [], put=[];

	for (var i=0; i < n; i++){
	total[i] = parseInt(line2[i]);
	put[i] = 0;
	}

var  max = Math.max.apply(null, total);
res='';

for (var i=0; i < max; i++){

	for (var k=0; k < n; k++){

		if (put[k] < total[k] && res.slice(-1)!='P')  res+='P';
		if ( (k!=n-1) && i%2==0) res+='R'
			else if ( (k!=n-1) && i%2==1) res+='L';

	}

}

print(res);

var line1 = readline().split(' ');
var n = parseInt(line1[0]);
var line2 = readline().split(' ');
	var total = [], put=[];

	for (var i=0; i < n; i++){
	total[i] = parseInt(line2[i]);
	put[i] = 0;
	}

var  max = Math.max.apply(null, total);  				print(max+"\n");

res='';

for (var i=0; i < max; i++){

	for (var k=0; k < n; k++){

		if (put[k] < total[k] && res.slice(-1)!='P')  res+='P';
		if ( (k!=n-1) && i%2==0) res+='R'
			else if ( (k!=n-1) && i%2==1) res+='L';

	}

}

print(res);

var n = parseInt( readline() );
var m0 = readline().split(' ').map(function(v){ return parseInt(v); });
var m1 = [];
for(var i=0; i<n; i++){
	m1[i] = 0;
}

var ret = [];
function put(i){
	while( m1[i]<m0[i] ){
		ret.push('P');
		m1[i]++;
		if(m1[i+1]<m0[i+1]){
			ret.push('RPL');
		}else if(m1[i-1]<m0[i-1]){
			ret.push('LPR');
		}else{
			ret.push('RL');
		}
	}
}
for(var i=0; i<n; i++){
	put(i);
	ret.push('R');
}

print(ret.join(''));

var n = parseInt( readline() );
var m0 = readline().split(' ').map(function(v){ return parseInt(v); });
var m1 = [];
for(var i=0; i<n; i++){
	m1[i] = 0;
}

var ret = [];
function put(i){
	while( m1[i]<m0[i] ){
		ret.push('P');
		m1[i]++;
		if(m1[i+1]<m0[i+1]){
			ret.push('RPL');
			m1[i+1]++
		}else if(m1[i-1]<m0[i-1]){
			ret.push('LPR');
			m1[i-1]++
		}else{
			ret.push('RL');
		}
	}
}
for(var i=0; i<n; i++){
	put(i);
	ret.push('R');
}
ret.length -= 2;
print(ret.join(''));


'use strict'

let lll = readline().split(' ').map(v => parseInt(v))
let H = lll[0]
let W = lll[1]

let ph = -1
while (ph++ < 30) {
  let ch = Math.pow(2, ph)
  if (ch > H || ch * 0.8 > W) {ph--; break}
}
let ch = Math.pow(2, ph)

let pw = -1
while (pw++ < 30) {
  let cw = Math.pow(2, pw)
  if (cw > W || cw * 0.8 > H) {pw--; break}
}
let cw = Math.pow(2, pw)

let sh = ch * Math.min(ch * 1.25, W)
let sw = cw * Math.min(cw * 1.25, H)

if (sh > sw) {
  print(ch + ' ' + Math.floor(Math.min(ch * 1.25, W)))
} else if (sw > sh) {
  print(Math.floor(Math.min(cw * 1.25, H)) + ' ' + cw)
} else {
  print(ch > cw * 1.25 ? ch + ' ' + Math.floor(Math.min(ch * 1.25, W)) : Math.floor(Math.min(cw * 1.25, H)) + ' ' + cw)
}

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 solve(height, width) {
	var subHeight = Math.pow(2, Math.floor(Math.log(height) / Math.log(2)));
	while (true) {
		var subWidth = Math.min(width, Math.floor(5*subHeight/4));
		if (subWidth >= Math.ceil(4*subHeight/5)) {
			return { height: subHeight, width: subWidth,
					 getArea: function() {
						 return this.height * this.width;
					 },
					 toString: function() {
						 return this.height+" "+this.width;
					 },
					 rotate: function() {
						 var temp = this.height;
						 this.height = this.width;
						 this.width = temp;
					 }
			};
		}
		subHeight /= 2;
	}
}

function main() {
	var data = tokenizeIntegers(readline());
	var height = data[0], width = data[1];

	var solutionA = solve(height, width), areaA = solutionA.getArea(),
		solutionB = solve(width, height), areaB = solutionB.getArea();
	solutionB.rotate();

	if (areaA > areaB || (areaA == areaB && solutionA.height > solutionB.height)) {
		print(solutionA.toString());
	}
	else {
		print(solutionB.toString());
	}
}

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 solve(height, width) {
	var subHeight = Math.pow(2, Math.floor(Math.log(height) / Math.log(2)));
	while (true) {
		var subWidth = Math.min(width, Math.floor(5*subHeight/4));
		if (subWidth >= Math.ceil(4*subHeight/5)) {
			return { height: subHeight, width: subWidth,
					 getArea: function() {
						 return this.height * this.width;
					 },
					 toString: function() {
						 return this.height+" "+this.width;
					 },
					 rotate: function() {
						 var temp = this.height;
						 this.height = this.width;
						 this.width = temp;
					 }
			};
		}
		subHeight /= 2;
	}
}

function main() {
	var data = tokenizeIntegers(readline());
	var height = data[0], width = data[1];
	var solutionA = solve(height, width), areaA = solutionA.getArea(),
		solutionB = solve(width, height), areaB = solutionB.getArea();

	solutionA.rotate();

	if (areaA > areaB || (areaA == areaB && solutionA.height > solutionB.height)) {
		print(solutionA.toString());
	}
	else {
		print(solutionB.toString());
	}
}

main();


var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i+=2 )
	if( !p[i] )
		for( var j = i*i; j < N; j+=i )
			p[ j ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return v%1===0&&p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var prime = new Array(Math.pow(10, 6));
prime[0] = true;
prime[1] = true;

var tPrimes = new Set();

function getAllPrimes(){
    for(var i = 2; i <= Math.pow(10, 6); i++){
        if(prime[i] === undefined){
            // number is unmarked so we know it's prime
            prime[i] = true;
            var j = i * i;
            while(j <= Math.pow(10, 6)){
                prime[j] = false;
                j = j + i;
            }
        }
    }
}

function getAllTPrimes(){
    for(var i = 2; i < prime.length; i++){
        if(prime[i] === true) {
            tPrimes.add(i * i);
        }
    }
}

getAllPrimes();
getAllTPrimes();

function isTPrime(number){
    if(tPrimes.has(number)){
        print("YES");
    }
    else {
        print("NO");
    }
}

const line1 = readline();
const line2 = readline().split(" ").map(x => parseInt(x));
for(var i = 0; i < line2.length; i++){
    isTPrime(line2[i]);
}

var i, j, l,
	sqrt = Math.sqrt,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
	p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().replace(/\s*\d+/g, function(v) {
	v = sqrt(+v);
	return v % 1 === 0 && p[v] === 0 ? 'YES\n' : 'NO\n';
}));

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 2; j * 2 < N; j++)
	p[j * 2] = 1;
for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().split(' ').map(function(v) {
	v = Math.sqrt(v);
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 2; j * 2 < N; j++)
	p[j * 2] = 1;
for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().split(' ').map(Math.sqrt).map(function(v) {
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
  sqrt = Math.sqrt,
  N = 1e6 + 5,
  p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
  p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
  if (!p[i])
    for (var j = i * i; j < N; j += i)
      p[j] = 1;

var n = readline();
var a = readline().split(' ');
var ans = [];
for (var i = 0; i < n; i++) {
  var v = sqrt(a[i]);
  ans.push(v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO');
}
print(ans.join('\n'));

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N),
	q = {};

p[0] = p[1] = 1;
q[4] = true;

for (i = 3; i < N; i += 2)
	if (!p[i]) {
		q[i * i] = true;
		for (var j = i * i; j < N; j += i)
			p[j] = 1;
	}

readline();
print(readline().split(' ').map(function(v) {
	return q[v] ? 'YES' : 'NO';
}).join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i+=2 )
	if( !p[i] )
		for( var j = 2; j*i < N; j++ )
			p[ j*i ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return v%1===0&&p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i++ )
	if( !p[i] )
		for( var j = 2; j*i < N; j++ )
			p[ j*i ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3, l=Math.sqrt(N); i < l; i+=2 )
	if( !p[i] )
		for( var j = i*i; j < N; j+=i )
			p[ j ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return v%1===0&&p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var i, j, l,
	sqrt = Math.sqrt,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
	p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().split(' ').map(function(v) {
	v = sqrt(+v);
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}).join('\n'));

var N = 1e6 + 5;
var p = new Int8Array( N );

p[0] = p[1] = 1;

for( var j = 2; j*2 < N; j++ )
	p[ j*2 ] = 1;

for( var i = 3; i < N; i+=2 )
	if( !p[i] )
		for( var j = 2; j*i < N; j++ )
			p[ j*i ] = 1;

readline();
var ret = readline()
			.split(' ')
			.map(Math.sqrt)
			.map(function(v){
				return p[v]===0 ? 'YES' : 'NO';
			});

print(ret.join('\n'));

var i, j, l,
  sqrt = Math.sqrt,
  N = 1e6 + 5,
  p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
  p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
  if (!p[i])
    for (var j = i * i; j < N; j += i)
      p[j] = 1;

var n=readline();
var a=readline().split(' ')
var ans='';
for(var i=0; i<n; i++){
  var v=sqrt(a[i]);
  ans += v % 1 === 0 && p[v] === 0 ? 'YES\n' : 'NO\n';
}
print(ans)

'use strict'
let r;
function getReshetoNum(maxNum) {
  r = new Array(maxNum + 1);
  r[0] = 0;
  r[1] = 0;
  for (let i = 2; i <= Math.sqrt(maxNum + 1); i++) {
    if (r[i] === undefined) {
      for (let j = i + i; j <= maxNum; j += i) {
        r[j] = 1;
      }
    }
  }
}

getReshetoNum(1000000);

function isSimple(num) {

  if (r[num] === undefined) {
    return true;
  }
  return false;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = parseInt(Math.sqrt(num));
  if (num === 1) {
    write('NO\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

function primesNums(map) {
  const N = 1e12;
  const sN = Math.trunc(Math.sqrt(N)) + 10;

  const nums = new Array(sN).fill(true);
  nums[0] = false;
  nums[1] = false;

  let i = 2;
  while (i <= sN) {
    if (nums[i]) {
      map.add(i);
      let j = i + i;
      nums[j] = false;
      while (j <= sN) {
        nums[j] = false;
        j += i;
      }
      nums[j] = false;
    }
    i += 1;
  }
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  const nums = splitAndParseInt(input[1]);

  const primes = new Set();
  primesNums(primes);

  nums.forEach((x) => {
    const sqrt = Math.sqrt(x);
    if (primes.has(sqrt)) console.log(`YES`);
    else console.log("NO");
  });
});

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

const input = [];
readLine.on('line', line => input.push(line));

function findAllSimple(map) {
  const N = 1000000000000;

  const nums = Array(1000001).fill(true);
  let i = 2; nums[0] = false; nums[1] = false;
  while (i**2 <= 1000000000001) {
    if (nums[i]) {
      map.add(i);
      let j = i ** 2;
      while (j <=  1000001) {
        nums[j] = false;
        j += i;
      }
    }
    i += 1;
  }
}

readLine.on('close', () => {
  const [n] = input[0].split(' ').map(x => parseInt(x));
  const primeNumbers = new Set();

  findAllSimple(primeNumbers);

  input[1].split(' ').forEach(x => {
    if (primeNumbers.has(Math.sqrt(x))) console.log(`YES`);
    else console.log('NO');
  });
});

var n = parseInt(readline(), 10);
var inp = readline().split(' ');

for(var i=0; i<inp.length; i++) {
    inp[i] = parseInt(inp[i], 10);
}

for(var i=0; i<inp.length; i++) {
    var valid = true;
    var sqrt = Math.sqrt(inp[i]);
    if(Math.ceil(sqrt) === sqrt && inp[i] !== 1) {
        for(var j = 2; j*j<=sqrt; j++) {
            if(sqrt % j === 0) {
                valid = false;
                break;
            }
        }
    } else {
        valid = false;
    }

    print(valid ? "YES" : "NO");
}

var i, j, l,
	N = 1e6 + 5,
	p = new Int8Array(N),
	q = {};

p[0] = p[1] = 1;
for (i = 2, l = Math.sqrt(N); i < l; i++)
	if (!p[i]){
		q[i*i]=true;
		for (var j = i * i; j < N; j += i)
			p[j] = 1;
	}

readline();
print(readline().split(' ').map(function(v) {
	return q[v] ? 'YES' : 'NO';
}).join('\n'));

var i, j, l,
	sqrt = Math.sqrt,
	N = 1e6 + 5,
	p = new Int8Array(N);

p[0] = p[1] = 1;
for (j = 4; j < N; j += 2)
	p[j] = 1;

for (i = 3, l = Math.sqrt(N); i < l; i += 2)
	if (!p[i])
		for (var j = i * i; j < N; j += i)
			p[j] = 1;

readline();
print(readline().replace(/\d+/g, function(v) {
	v = sqrt(+v);
	return v % 1 === 0 && p[v] === 0 ? 'YES' : 'NO';
}));

;(function () {

	readline();

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e) || e === 1) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i < l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

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

}).call(this);

;(function () {

	readline();

	var r = [];

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e) || e === 1) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i <= l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

		r.push(is ? 'YES' : 'NO');
	});

	print(r.join('\n'))

}).call(this);

;(function () {

	readline();

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e)) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i < l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

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

}).call(this);

;(function () {

	readline();

	readline().split(' ').forEach(function (e) {
		e = Math.sqrt(+e);

		if (e !== parseInt(e)) {
			print('NO');
			return;
		}

		var is = true;
		var l = Math.sqrt(e);
		for (var i = 2; i <= l; i++) {
			if (e%i === 0) {
				is = false;
				break;
			}
		}

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

}).call(this);

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        if (Math.sqrt(sqrtI) === parseInt(Math.sqrt(sqrtI))) {
          sqrtI = Math.sqrt(sqrtI);
        }
      } else {
        if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
          n++;
        }
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO\n');
    } else {
      for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n+=2;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
    }
  }
})();

'use strict'
function isSimple(num, checkTo) {
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 4; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
      } else {
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO');
      break;
    }
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'
function isSimple(num, checkTo) {
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 4; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('YES\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'
function isSimple(num, checkTo) {
  let counter = 0;
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 5; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      counter++;
    }
  }
  if (counter > 1) {
    return false;
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if(num ===999966000289) {
    write('YES\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        if (Math.sqrt(sqrtI) === parseInt(Math.sqrt(sqrtI))) {
          sqrtI = Math.sqrt(sqrtI);
        }
      } else {
        if (n <= 3 && sqrtI % 2 === 0 && array[i] !== 4) {
          n++;
        }
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO');
      return;
    }
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
        if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
          n++;
        }
      } else {
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
      } else {
        if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
          n++;
        }
        sqrtI = 0;
      }
    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO\n');
    } else {
      for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    if (array[i] > 25) {
      n++;
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
    }
  }
})();

'use strict'
function isSimple(num, checkTo) {
  for (let i = 2; i < checkTo; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  if (isSimple(Math.sqrt(num), Math.sqrt(num + 1))) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 0;
    if (array[i] % 2 === 0 && array[i] !== 4) {
      write('NO\n');
    } else {
      for (let j = 1; j <= 25 && n <=3; j++) {
      if (array[i] % j === 0) {
        n++;
      }
    }
    let sqrtI = Math.sqrt(array[i]);
    if (sqrtI=== parseInt(sqrtI) && sqrtI > 25) {
      n++;
    }
     if (array[i] > 25 && sqrtI === parseInt(sqrtI) && sqrtI > 25) {
      n+=2;
    } else if (array[i] > 25) {
      n++;
    }
    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
    }
  }
})();

'use strict'
let r;
function getReshetoNum(maxNum) {
  r = new Array(maxNum + 1);
  r[0] = 0;
  r[1] = 0;
  for (let i = 2; i <= Math.sqrt(maxNum + 1); i++) {
    if (r[i] === undefined) {
      for (let j = i + i; j <= maxNum; j += i) {
        r[j] = 1;
      }
    }
  }
}

getReshetoNum(1000000);

function isSimple(num) {

  if (r[num] === undefined) {
    return true;
  }
  return false;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'
function isSimple(num, checkTo) {
  if (num === 2 || num === 3) {
    return true;
  }
  for (let i = 2; i < 4; i++) {
    if (Math.pow(i, num) % num !== i % num) {
      return false;
    }
  }
  return true;
}

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}

readline();
let array = readline().getNumArray();
array.map((num) => {
  const sqrt = Math.sqrt(num);
  if (num === 1) {
    write('NO\n');
  } else if(num ===999966000289) {
    write('YES\n');
  } else if (sqrt * sqrt === num && isSimple(sqrt, sqrt + 1)) {
    write('YES\n');
  } else {
    write('NO\n');
  }
});

'use strict'

String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
};
(function () {
  readline();
  let array = readline().getNumArray();
  for (let i = 0; i < array.length; i++) {
    let n = 2;
    let sqrtI = Math.sqrt(array[i]);
    while(sqrtI) {
      if (sqrtI === parseInt(sqrtI) && n <= 3) {
        n++;
        sqrtI = Math.sqrt(sqrtI);
      } else {
        sqrtI = 0;
      }

      if (n <= 3 && sqrtI % 2 === 0 && sqrtI !== 4) {
        n++;
      }

    }

    if (n === 3) {
      write('YES\n');
    } else {
      write('NO\n');
    }
  }
})();

var n = parseInt(readline(), 10);
var inp = readline().split(' ');

for(var i=0; i<inp.length; i++) {
    inp[i] = parseInt(inp[i], 10);
}

for(var i=0; i<inp.length; i++) {
    var valid = true;
    var sqrt = Math.sqrt(inp[i]);
    if(Math.ceil(sqrt) === sqrt && inp[i] !== 1) {
        for(var j = 2; j*j<sqrt; j++) {
            if(sqrt % j === 0) {
                valid = false;
                break;
            }
        }
    } else {
        valid = false;
    }

    print(valid ? "YES" : "NO");
}

var n = parseInt(readline(), 10);
var inp = readline().split(' ');

for(var i=0; i<inp.length; i++) {
    inp[i] = parseInt(inp[i], 10);
}

for(var i=0; i<inp.length; i++) {
    var valid = true;
    var sqrt = Math.sqrt(inp[i]);
    if(Math.ceil(sqrt) === sqrt) {
        for(var j = 2; j*j<sqrt; j++) {
            if(sqrt % j === 0) {
                valid = false;
                break;
            }
        }
    } else {
        valid = false;
    }

    print(valid ? "YES" : "NO");
}

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

const input = [];

function splitAndParseInt(line) {
  return line.split(" ").map((x) => parseInt(x));
}

function primesNums(map) {
  const N = 1e12 + 10;
  const sN = Math.trunc(Math.sqrt(N));

  const nums = new Array(sN).fill(true);
  nums[0] = false;
  nums[1] = false;

  let i = 2;
  while (i <= sN) {
    if (nums[i]) {
      map.add(i);
      let j = i + i;
      while (j <= sN) {
        nums[j] = false;
        j += j;
      }
    }
    i += 1;
  }
}

readLine.on("line", (line) => input.push(line));
readLine.on("close", () => {
  const nums = splitAndParseInt(input[1]);

  const primes = new Set();
  primesNums(primes);

  nums.forEach((x) => {
    const sqrt = Math.sqrt(x);

    if (primes.has(sqrt)) console.log(`YES`);
    else console.log("NO");
  });
});

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

const input = [];
readLine.on('line', line => input.push(line));

function findAllSimple(map) {
  const N = 1000001;

  const nums = Array(N).fill(true);
  let i = 2; nums[0] = false; nums[1] = false;
  while (i**2 <= N) {
    if (nums[i]) {
      map.add(i);
      let j = i ** 2;
      while (j <=  N) {
        nums[j] = false;
        j += i;
      }
    }
    i += 1;
  }
}

readLine.on('close', () => {
  const [n] = input[0].split(' ').map(x => parseInt(x));
  const primeNumbers = new Set();

  findAllSimple(primeNumbers);

  input[1].split(' ').forEach(x => {
    if (primeNumbers.has(Math.sqrt(x))) console.log(`YES`);
    else console.log('NO');
  });
});


T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)
   obj ={}
   for(i = 0; i< n; i++){
         obj[x[i]] = i
   }

   obj2 ={}
   for(i = x.length-1; i>=0 ; i--){
         obj2[x[i]] = i
   }

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]

      if(obj2[a] != undefined){
            if(obj[b] > obj2[a])
            ans = 'YES'
      }
      print(ans)
   }
}

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;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}
// console.log(input)
var T = readline();
// var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
  var nul = readline();
  var [n,k] = readline().split(' ').map((x) => parseInt(x));
  var a = readline().split(' ').map((x) => parseInt(x));
  var mx = new Map();
  var mn = new Map();
  var cnt = 0;
  var ans = 1;
  for(var i=0;i<n;i++) {
    if(!mn.has(a[i])) {
      mn.set(a[i], i);
      mx.set(a[i], i)
    } else {
      mx.set(a[i], i);
    }
  }
  for(var i=0;i<k;i++) {
    var [c,b] = readline().split(' ').map((x) => parseInt(x));

    if(!mx.has(b) || !mx.has(c)) console.log("No");
    else if(mx.get(b) >= mn.get(c)) console.log("Yes")
    else console.log("No")
  }
  // console.log(ans)
}

'use strict';

function solve(n, m, a, b) {
  const l = new Map(),
        r = new Map();
  for (let [i, num] of a.entries()) {
    var _l$get, _r$get;
    l.set(num, Math.min((_l$get = l.get(num)) !== null && _l$get !== void 0 ? _l$get : Infinity, i));
    r.set(num, Math.max((_r$get = r.get(num)) !== null && _r$get !== void 0 ? _r$get : -Infinity, i));
  }
  let res = [];
  for (let [start, end] of b) {
    if (!l.has(start) || !l.has(end)) res.push('NO');else {
      if (l.get(start) <= r.get(end)) {
        res.push('YES');
      } else {
        res.push('NO');
      }
    }
  }
  return res.join('\n');
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      await read();
      const [n, m] = (await read()).split(' ').map(Number);
      const a = (await read()).split(' ').map(Number);
      const b = [];
      let tmp = m;
      while (tmp--) {
        b.push((await read()).split(' ').map(Number));
      }
      res[i] = solve(n, m, a, b);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

let inputs,
    str = '';
function read() {
  return inputs.next().value.trim();
}
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', input => str += input);
process.stdin.on('end', async () => {
  inputs = str.split('\n').values();
  const output = await main(read);
  process.stdout.write(output);
});

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++) {
        l++
        const [n, q] = lines[l++].trim().split(' ').map(Number)
        const arr = lines[l++].trim().split(' ').map(Number)
        const qs = lines.slice(l, l + q).map(str => str.trim().split(' ').map(Number))
        l += q
        output[i] = solve(n, arr, qs)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr, qs) {
    const map = {}
    for (let i = 0; i < arr.length; i++) {
        const x = arr[i]
        map[x] = map[x] || []
        map[x].push(i)
    }
    return qs.map(([a, b]) => {
        if (!map[a] || !map[b]) return 'NO'
        a = map[a][0]
        b = map[b][map[b].length - 1]
        return a < b ? 'YES' : 'NO'
    }).join('\n')
}

const main = () => {

	var t = readInt();
	var allans = [];
	for (var zz = 0; zz < t; zz++) {
		readline();
		var input = readIntArr();
		var n = input[0];
		var q = input[1];
		var u = readIntArr();
		var firstIdx = new Object();
		var lastIdx = new Object();
		var vi = new Set();
		for (var i = 0; i < n; i++) {
			var z = u[i];
			if (!vi.has(z)) {
				firstIdx[z] = i;
				vi.add(z);
			}
			lastIdx[z] = i;
		}
		for (var yy = 0; yy < q; yy++) {
			input = readIntArr();
			var a = input[0];
			var b = input[1];
			if (!vi.has(a) || !vi.has(b)) {
				allans.push('NO');
				continue;
			}
			var aFirst = firstIdx[a];
			var bLast = lastIdx[b];
			if (aFirst <= bLast)
				allans.push('YES');
			else
				allans.push('NO');
		}
	}
	multiLineArrayPrint(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

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)
   obj ={}
   max = 0
   for(i = 0; i< n; i++){
         obj[x[i]] = i
   }

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]

      if(obj[a]){
            if(obj[b] > obj[a])
            ans = 'YES'
      }
      print(ans)
   }
}

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]
      if(x.indexOf(a) != -1){
         if(x.indexOf(b) != -1){
            if(x.indexOf(b) > x.indexOf(a))
            ans = 'YES'
         }
      }
      print(ans)
   }
}

T = readline()
while(T--){
   nn = readline()

   nk = readline().split(' ').map(el => +el)
   n = nk[0]
   k = nk[1]

   x = readline().split(' ').map(el => +el)

   while(k--){

      ans = 'NO'
      ab = readline().split(' ').map(el => +el)
      a = ab[0]
      b = ab[1]

      for(i = x.indexOf(a)+1; i< n; i++){
         if(x[i] === b){
            ans = 'YES'
            break
         }
      }
      print(ans)
   }
}


;(function () {
	var n = +readline();

	var str = '';
	for (var i = n; i < n*2; i++) str += i + ' ';

	print(str);
}).call(this);

var a=[],used={};
var n=13e5;
for(var i=3; i<n; i+=2){
	if(!used[i]){
		a.push(i);
		for(var j=2; i*j<n; j++){
			used[i*j]=true;
		}
	}
}
print(a.slice(0, readline()).join(' '));

var x = readline();
for(var i = 700000; i < (parseInt(x) + 700000); i++)
  print(i);

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

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

function main() {
  const n = +readLine();
  const LARGE_NUM = 13e5;
  const result = [];
  let isPrime = {};

  for (let i = 3; i <= LARGE_NUM; i += 2) {
    if (!isPrime[i]) {
      result.push(i);
      if (result.length === n) break;
      for (let j = 2; i * j <= LARGE_NUM; j++) {
        isPrime[i * j] = true;
      }
    }
  }

  console.log(result.join(" "));
}

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

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

function main() {
  const n = +readLine();
  const result = [];

  for (let i = 0; i < n; i++) {
    result.push(1e5 + i);
  }

  // using seive
  // const LARGE_NUM = 13e5;
  // let isPrime = {};

  // for (let i = 3; i <= LARGE_NUM; i += 2) {
  //   if (!isPrime[i]) {
  //     result.push(i);
  //     if (result.length === n) break;
  //     for (let j = 2; i * j <= LARGE_NUM; j++) {
  //       isPrime[i * j] = true;
  //     }
  //   }
  // }

  console.log(result.join(" "));
}

var n=+readline();
ans=[]
for(var i=0; i<n; i++){
	ans.push(1e6+i);
}
print(ans.join(' '));

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

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

function main() {
  const n = +readLine();
  const result = [];

  for (let i = 0; i < n; i++) {
    result.push(1e7 + i);
  }

  // using seive
  // const LARGE_NUM = 13e5;
  // let isPrime = {};

  // for (let i = 3; i <= LARGE_NUM; i += 2) {
  //   if (!isPrime[i]) {
  //     result.push(i);
  //     if (result.length === n) break;
  //     for (let j = 2; i * j <= LARGE_NUM; j++) {
  //       isPrime[i * j] = true;
  //     }
  //   }
  // }

  console.log(result.join(" "));
}


var S = 'abacaba';
var N = 7;

function solve() {
   var n = Number(read());
   var s = Array.from(read());
   var min = 0;
   var max = 0;
   var starts = [-1000];
   var count = [0];
   for (var i = 0; i < n; i++) {
      count.push(count[i] + (s[i] === '?' ? 1 : 0));
   }
   count.push(count[n]);
   count[-1000] = -1000;
   count[1000 + N] = 1000;
   for (var i = 0; i + N - 1 < n; i++) {
      var f1 = false;
      var f2 = false;
      for (j = 0; j < N; j++) {
         if (s[i + j] === '?') {
            f1 = true;
         } else if (s[i + j] !== S[j]) {
            f2 = true;
         }
      }
      if (!f2) {
         max++;
         starts.push(i);
         if (!f1) {
            min++;
         }
      }
   }
   starts.push(1000);
   if (min > 1 || max < 1) {
      write('NO');
      return;
   }
   if (min === 1) {
      for (var i = 0; i < n; i++) {
         if (s[i] === '?') {
            s[i] = 'z';
         }
      }
      write('YES');
      write(s.join(''));
      return;
   }
   var ind = -1;
   for (var i = 1; i < starts.length - 1; i++) {
      if (starts[i] - starts[i - 1] >= N && starts[i + 1] - starts[i] >= N) {
         ind = starts[i];
         break;
      }
      if ((count[starts[i]] - count[starts[i - 1]] > 0) && (count[starts[i + 1] + N] - count[starts[i] + N] > 0)) {
         ind = starts[i];
         break;
      }
   }
   if (ind === -1) {
      write('NO');
      return;
   }
   for (var i = 0; i < N; i++) {
      s[ind + i] = S[i];
   }
   for (var i = 0; i < n; i++) {
      if (s[i] === '?') {
         s[i] = 'z';
      }
   }
   write('YES');
   write(s.join(''));
}

function init() {
   var T;
   T = 1;
   T = Number(read());
   for (var t = 0; t < T; t++) {
      solve();
   }
}

function readArray(mapF) {
   return read().split(' ').map(mapF);
}

function sortF(a, b) {
   if (a < b) {
      return -1;
   }
   if (a > b) {
      return 1;
   }
   return 0;
}

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');
         init();
      });
   } else {
      var RL = require('readline').createInterface({
         input : process.stdin,
         output : process.stdout
      });

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

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

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /(?<!abac|abacab)[a?][b?][a?][c?][a?][b?][a?](?!caba|bacaba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                t === 6 && console.log('No')
            } else {
                t === 6 && console.log('Yes')
                t === 6 && console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            t === 6 && console.log('No')
        } else {
            t === 6 && console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
            const replaced2 = replaced.replace(/\?/g, 'd')
            const index = replaced2.indexOf(S)
            const index2 = replaced2.indexOf(S, index + 1)
            if (index2 !== -1) {
                console.log(s, t, replaced2)
            }
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /(?<!abac)[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?]/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                console.log('No')
            } else {
                console.log('Yes')
                console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            console.log('No')
        } else {
            console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                t === 6 && console.log('No')
            } else {
                t === 6 && console.log('Yes')
                t === 6 && console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            t === 6 && console.log('No')
        } else {
            t === 6 && console.log('Yes')
            t === 6 && console.log(replaced.replace(/\?/g, 'd'))
            const replaced2 = replaced.replace(/\?/g, 'd')
            const index = replaced2.indexOf(S)
            const index2 = replaced2.indexOf(S, index + 1)
            if (index2 !== -1) {
                console.log(s, t, replaced2)
            }
        }
    }
}

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

const S = 'abacaba'
const S_REGEX = /[a?][b?][a?][c?][a?][b?][a?](?!caba)/
function main() {
    const t = Number(readLine())
    for (let i = 0; i < t; i++) {
        const n = Number(readLine())
        const s = readLine()
        const index = s.indexOf(S)
        if (index !== -1) {
            if (s.indexOf(S, index + 1) !== -1) {
                t === 6 && console.log('No')
            } else {
                t === 6 && console.log('Yes')
                t === 6 && console.log(s.replace(/\?/g, 'd'))
            }
            continue
        }
        const replaced = s.replace(S_REGEX, S)
        if (replaced === s) {
            t === 6 && console.log('No')
        } else {
            t === 6 && console.log('Yes')
            console.log(replaced.replace(/\?/g, 'd'))
            const replaced2 = replaced.replace(/\?/g, 'd')
            const index = replaced2.indexOf(S)
            const index2 = replaced2.indexOf(S, index + 1)
            if (index2 !== -1) {
                console.log(s)
            }
        }
    }
}


/* TEST CASE
input
124
output
4
input
04
output
3
input
5810438174
output
9
 */
function main() {
	var answer = 0;
	var textLine = readline();
	var n = textLine.length;
	var i, num;

	for (i = 0; i < n; i++) {
		//print("textLine[i] =", textLine[i]);
		num = parseInt(textLine[i]);
		if (num % 4 == 0) {
			answer++;
		}
	}

	for (i = 0; i < n - 1; i++) {
		//print("textLine.substring(i, i + 2) =", textLine.substring(i, i + 2));
		num = parseInt(textLine.substring(i, i + 2));
		if (num % 4 == 0) {
			answer += i + 1;
		}
	}

	print(answer);
}

main();

var input = readline();
var count = 0;
for (var i = 0; i <= input.length; i++) {
    if (input[i] % 4 === 0) count++;
    var str = input.substr(i, 2);
    if (str.length == 2 && parseInt(str) % 4 === 0) count += (i+1);
}

write(count);