Sho has an array $$$a$$$ consisting of $$$n$$$ integers. An operation consists of choosing two distinct indices $$$i$$$ and $$$j$$$ and removing $$$a_i$$$ and $$$a_j$$$ from the array.For example, for the array $$$[2, 3, 4, 2, 5]$$$, Sho can choose to remove indices $$$1$$$ and $$$3$$$. After this operation, the array becomes $$$[3, 2, 5]$$$. Note that after any operation, the length of the array is reduced by two.After he made some operations, Sho has an array that has only distinct elements. In addition, he made operations such that the resulting array is the longest possible. More formally, the array after Sho has made his operations respects these criteria:   No pairs such that ($$$i < j$$$) and $$$a_i = a_j$$$ exist.  The length of $$$a$$$ is maximized. Output the length of the final array.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^3$$$) — the number of test cases. The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 50$$$) — the length of the array. The second line of each test case contains $$$n$$$ integers $$$a_i$$$ ($$$1 \leq a_i \leq 10^4$$$) — the elements of the array.

For each test case, output a single integer — the length of the final array. Remember that in the final array, all elements are different, and its length is maximum.

NoteFor the first test case Sho can perform operations as follows:   Choose indices $$$1$$$ and $$$5$$$ to remove. The array becomes $$$[2, 2, 2, 3, 3, 3] \rightarrow [2, 2, 3, 3]$$$.  Choose indices $$$1$$$ and $$$4$$$ to remove. The array becomes $$$[2, 2, 3, 3] \rightarrow [2, 3]$$$.  The final array has a length of $$$2$$$, so the answer is $$$2$$$. It can be proven that Sho cannot obtain an array with a longer length.For the second test case Sho can perform operations as follows:   Choose indices $$$3$$$ and $$$4$$$ to remove. The array becomes $$$[9, 1, 9, 9, 1] \rightarrow [9, 1, 1]$$$.  Choose indices $$$1$$$ and $$$3$$$ to remove. The array becomes $$$[9, 1, 1] \rightarrow [1]$$$.  The final array has a length of $$$1$$$, so the answer is $$$1$$$. It can be proven that Sho cannot obtain an array with a longer length.

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 = Number(lines[i]);
        }else{
            var a = lines[i].split(' ').map(Number);
            var s = new Map();
            for(j = 0; j < n; j++){
                if(s.has(a[j])){
                    var te = s.get(a[j]);
                    te++;
                    s.set(a[j], te);
                }else{
                    s.set(a[j], 1);
                }
            }
            console.log(s.size - ((n - s.size) % 2));
        }
    }
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
let data = [];
let dataIdx = 0;

rl.on('line', function (line) {
  //input,
  data.push(...line.trim().split(' '));
}).on('close', function () {
  //output
  main();
  process.exit();
});

function input() {
  return data[dataIdx++];
}

function output(value) {
  // try {
  process.stdout.write(String(value));
  // } catch (err) {
  //   process.stdout.write(value.toString());
  // }
}
//////////////////////////////////////////////////////////

function main() {
  let t = Number(input());
  while (t--) {
    let n = Number(input());
    const set = new Set();

    let rest = 0;
    for (let i = 0; i < n; i++) {
      const value = Number(input());

      if (set.has(value)) {
        rest++;
      } else {
        set.add(value);
      }
    }

    output(set.size - (rest % 2));
    output('\n');
  }
}

function Solution() {
  let t = 0;
  const n = Number(lines[t++]);
  const res = [];
  for (let i = 0; i < n; i++) {
    const num = Number(lines[t++]);
    const arr = lines[t++].split(' ').map((item) => Number(item));
    const set = new Set(arr);
    res[i] =  (num - set.size) % 2 === 0 ? set.size : set.size - 1;
  }
  return res.join('\n');
}

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', () => {
  console.log(Solution());
});

function Solution() {
  let t = 0;
  const n = Number(lines[t++]);
  const res = [];
  for (let i = 0; i < n; i++) {
    const num = Number(lines[t++]);
    const arr = lines[t++].split(' ').map((item) => Number(item));
    const set = new Set(arr);
    const last = num - set.size;
    if (last % 2 === 0) res[i] = set.size;
    else res[i] = set.size - 1;
  }
  return res.join('\n');
}

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', () => {
  console.log(Solution());
});

const rdline = require('readline');

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

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

let line = 0;
const readline = () => lines[line++];

solve = () => {
    const t = parseInt(readline());
    for (let i = 0; i < t; i++) {
        const n = parseInt(readline());
        const b = readline().split(" ").map(Number);
        var c = {};
        var d = 0; //количество уникальных чисел в строке входных данных
        var ans;
        for (let j = b.length - 1; j >= 0; j--) {
            if (!c[b[j]]) {
                c[b[j]] = true;
                d++;
            }
        }
        if (d % 2 !== n % 2) {
            ans = d - 1;
        } else {
            ans = d;
        }
        console.log(ans);
    }
}

/*
** 799B
*/

// Common Template Starts //
//*
process.stdin.resume();
process.stdin.setEncoding("utf-8");

let is = "";
let cl = 0;

process.stdin.on("data", (inp) => {
    is += inp;
});

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

const readline = () => is[cl++];

// Common Template Ends //

function main() {
    let nLines = parseInt(readline());
    while (nLines--) {
        const dataLength = parseInt(readline());
        const data = readline().split(' ');
        const unique = data.filter((n, i) => data.indexOf(n) === i).length;
        console.log(unique % 2 === dataLength % 2 ? unique : unique - 1);
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function findKthLargest(nums, k) {
    k = nums.length - k;
    const quickSelect = (l, r) => {
        let pivot = nums[r];
        let p = l;
        for (let i = l; i < r; i++) {
            if (nums[i] <= pivot) {
                swapper(nums, p, i);
                p++;
            }
        }
        swapper(nums, p, r);

        if (p > k) return quickSelect(l, p - 1);
        else if (p < k) return quickSelect(p + 1, r);
        else return nums[p];
    };

    return quickSelect(0, nums.length - 1);
};

function swapper(array, a, b) {
    const temp = array[b];
    array[b] = array[a];
    array[a] = temp;
};

function main() {
    const n = parseInt(readline());
    for(var i=0; i<n; i++){
        const m = (readline());
        const s = new Set();
        var c =0;
        const d = readline();
        d.split(" ").map(r => {
            const x = parseInt(r);
            if(s.has(x)){
                c++;
            }
            s.add(x);
        });
        if(c % 2){
            c++;
        }
        foo(String(m-c));
    }
}
function foo(x) {
    process.stdout.write(x);   // without auto '\n' (newline)
    console.log();  // with auto '\n' (newline)
}

const main = (input) => {
  input = input.split('\n')

  const t = Number(input[0])
  for (let i = 0; i < t; i++) {
    const n = parseInt(input[1 + i * 2])
    const a = input[1 + i * 2 + 1].split(' ').map((x) => parseInt(x))

    const mySet = new Set(a)
    const ans = mySet.size - ((n - mySet.size) & 1)

    console.log(ans)
  }
}

main(require('fs').readFileSync(0).toString())

let ryan = '';//.map(Numaer).sort(function(a, a){return a - a})
process.stdin.on('data', c => ryan += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = ryan.split(EOL);
    var n = lines[0]
    for(j = 1; j <= n * 2; j++){
        if(j % 2 == 1){
            var e = lines[j], a = new Map()
        }else{
            k = lines[j].split(' ').map(Number)
            a = new Map()
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    te = a.get(k[l]);
                    te++;
                    a.set(k[l], te);
                }else{
                    a.set(k[l], 1);
                }
            }
                console.log(a.size - ((e - a.size) % 2));

        }
    }

});

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

        let hash = {};
        for (let i = 0; i < arr.length; i++) {
            hash[arr[i]] = true;
        }

        let uniq = Object.keys(hash).length;
        let diff = arr.length - uniq;
        let res;
        if (diff % 2 === 0) {
            res = uniq;
        } else {
            res = uniq - 1;
        }
        output(res);
    }
}

const solve = (arr)=>{
     let obj = {},cnt = 0;
     for(let i=0;i<arr.length;i++){
          if(obj[arr[i]]) cnt++;
          else obj[arr[i]] = 1;
     }
     if(cnt===0) return arr.length;
     else return (arr.length-cnt) - cnt%2;

}

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

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = nextIntArray(N);
		var map = getCountMap(list);
		for(var i = 0; i < N; i++){
			for(var j = i + 1; j < N; j++){
				if(list[i] != -1 && list[j] != -1 && list[i] != list[j]){
					if(map[list[i]] > 1 && map[list[j]] > 1){
						map[list[i]]--;
						map[list[j]]--;
						list[i] = -1;
						list[j] = -1;
					}
				}
			}
		}
		for(var i = 0; i < N; i++){
			for(var j = i + 1; j < N; j++){
				if(list[i] != -1 && list[j] != -1 && list[i] == list[j]){
					if(map[list[i]] >= 2){
						map[list[i]] -= 2;
						list[i] = -1;
						list[j] = -1;
					}
				}
			}
		}
		var output = 0;
		for(var i = 0; i < N; i++){
			if(list[i] != -1){
				output++;
			}
		}
		myout(output);
	}
}

/**
 * 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 cnt = 0;
        let cntEven = 0;
        let n  = readSingleInt();
        let tempAr = readIntArray();
        let arMap = {};

        tempAr.forEach( v=>{
            if(arMap[v]){
                arMap[v]++;
            }else{
                arMap[v]=1;
            }
        })

        for(let a in arMap){
            // console.log(`${a} = ${arMap[a]}`) key = value

            if(arMap[a]==1 || arMap[a]&1){
                cnt++;
            }
            if(arMap[a]%2==0){
                cntEven++;
            }
        }
        if(cntEven){
            if(cntEven&1){
                cntEven--;
            }
            cnt += cntEven;
        }
        console.log(cnt);

    }

}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
//
let standardInputString = "";
let currentLine = 0;
//
process.stdin.on("data", (rawData) => {
  standardInputString += rawData;
});
process.stdin.on("end", (_) => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map((line) => {
      return line.trim();
    });
  main();
});

function readline() {
  return standardInputString[currentLine++];
}
function print(data) {
  console.log(data);
}

//line to array of integers
//readline().split(' ').map(Number)
//  let iter=parseInt(readline())
//multiple integer construction->const [a,b,c]=integer array

function main() {
  let q = parseInt(readline());
  for (let i = 0; i < q; i++) {
    let n = readline();
    let input = readline().split(" ").map(Number);
    print(R(input));
  }
}

function R(arr) {
  let set = new Set();
  let dup = 0;
  for (let item of arr) {
    if (!set.has(item)) set.add(item);
    else dup++;
  }
  if (dup & 1) dup++;
  return arr.length - dup;
}

'use strict';

function solve(n, a) {
  const map = new Map();
  for (let num of a) {
    var _map$get;
    map.set(num, ((_map$get = map.get(num)) !== null && _map$get !== void 0 ? _map$get : 0) + 1);
  }
  let even = 0;
  for (let [, count] of map) {
    if (count > 1 && !(count & 1)) even++;
  }
  if (even & 1) {
    return map.size - 1;
  } else {
    return map.size;
  }
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      const a = (await read()).split(' ').map(Number);
      res[i] = solve(n, a);
    }
    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++) {
        const n = +lines[l++]
        const arr = lines[l++].trim().split(' ').map(Number)
        output[i] = solve(n, arr)
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const map = arr.reduce((o, x) => {
        o[x] = (o[x] || 0) + 1
        return o
    }, {})
    let ans = 0
    for (let k in map) {
        const v = map[k]
        if (v > 1) {
            ans += v - 1
        }
    }
    return n - 2 * Math.ceil(ans / 2)
}

var input1 = Array();
var limitString = readline();
var limit = parseInt(limitString) * 2;
for (var i = 0; i < limit; i++) {
    input1.push(readline());
}
var output1 = calc(input1);
output1.forEach(function (value) { print(value); });
function calc(input) {
    var result = Array();
    for (var i = 0; i < input.length; i += 2) {
        var caseLength = parseInt(input[i]);
        var caseArray = input[i + 1].split(" ");
        var caseMap = new Map();
        for (var j = 0; j < caseLength; j++) {
            var currentValue = parseInt(caseArray[j]);
            if (caseMap.has(currentValue)) {
                var count = caseMap.get(currentValue);
                count++;
                caseMap.set(currentValue, count);
            }
            else {
                caseMap.set(currentValue, 1);
            }
        }
        var resultValue = 0;
        if ((caseLength % 2) == 0) {
            if (caseMap.size % 2 == 0) {
                resultValue = caseMap.size;
            }
            else {
                resultValue = (caseMap.size - 1);
            }
        }
        else {
            if (caseMap.size % 2 == 0) {
                resultValue = caseMap.size - 1;
            }
            else {
                resultValue = caseMap.size;
            }
        }
        result.push(resultValue);
    }
    return result;
}

var test_cases = readline();
var nbr,arrayy;
var _set = new Set();
var zdeg = [];

while(test_cases--){
    _set.clear();
    nbr = readline();
    zdeg = readline().split(" ").map((el)=> {
        _set.add(parseInt(el))
        return 1;
        });
    if(_set.size == 1)
        if( nbr % 2 == 0) print(0)
        else print(1)
    else if(nbr == _set.size) print(_set.size)
    else if(nbr % 2 == 0)
        if(_set.size % 2 == 0) print(_set.size)
        else print(_set.size - 1)
    else if(nbr % 2 != 0)
        if(_set.size % 2 == 0) print(_set.size - 1)
        else print(_set.size)
}

T = readline()

while(T--){
  n = readline()
  h = readline().split(' ').map(el => +el)

  set = new Set(h)
    ans = set.size
  if((n - set.size)%2 != 0)
    ans --
  print(ans)
}

var t = +readline();

for(var i = 0; i< t; i ++) {
    var a = readline();
    var b = readline().split(' ').map((t) => +t);

    print(Task2(b));
}

function Task2 (arr){

   var obj = {};
   for(var each of arr){
      if (obj.hasOwnProperty(each)) {
         obj[each]++;
      }else {
         obj[each] = 1;
      }
   }

   var count = 0;
   var extras = 0;
   for(var n in obj){
      count++;
      extras += obj[n]-1;
   }

   return extras % 2 === 0 ? arr.length - extras : arr.length-extras-1;

}

let stop = '';
process.stdin.on('data', c => stop += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = stop.split(EOL);
	var t = lines[0];
	var n = 0;
	for(i = 1; i <= t * 2; i++){
	    if(i % 2 == 1){
	        n = lines[i];
	    }else{
	        var m = new Map();
	        var a = lines[i].split(' ').map(Number);
	        for(j = 0; j < n; j++){
	            m.set(a[j], 1);
	        }
	        if(n - m.size > 1 && n % 2 == 1){
	            console.log(m.size - 1);
	        }else{
	            console.log(m.size);
	        }
	    }
	}
});

const readline = require('readline');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
});
let data = [];
let dataIdx = 0;

rl.on('line', function (line) {
  //input,
  data.push(...line.trim().split(' '));
}).on('close', function () {
  //output
  main();
  process.exit();
});

function input() {
  return data[dataIdx++];
}

function output(value) {
  try {
    process.stdout.write(value);
  } catch (err) {
    process.stdout.write(value.toString());
  }
}
//////////////////////////////////////////////////////////

function main() {
  let t = Number(input());
  while (t--) {
    let n = Number(input());
    const set = new Set();

    let rest = 0;
    for (let i = 0; i < n; i++) {
      const value = Number(input());

      if (set.has(value)) {
        rest++;
      } else {
        set.add(value);
      }
    }

    output(set.size - (rest % 2));
    output('\n');
  }
}

const rdline = require('readline');

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

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

let line = 0;
const readline = () => lines[line++];
/**
 * План подзадачи:
 *
 * идя по циклу удалять одинаковые значения
 */
solve = () => {
    const t = parseInt(readline());
    for (let i = 0; i < t; i++) {
        const n = parseInt(readline());
        const b = readline().split(" ").map(Number);
        var c = [];
        for (let i = 0; i < n; i++) {
            b.sort(function(a, b) {
                return a - b;
              });
            if (b[i] !== b[i + 1]) {
                c.push(b[i]);
            }
        }
            if (c.length % 2 !== n % 2){
                ans = 1
            } else {
            ans = c.length;}

        console.log(ans);
    }
}

const readline = require('readline');
async function main() {

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

  let n = 0;
  let dataLength = 0;
  let data = [];
  for await (const line of rl) {
    if (!n) {
        n = parseInt(line);
        continue;
    }

    if (!dataLength) {
        dataLength = parseInt(line);
    } else {
        data = line.split(' ').map((n) => parseInt(n));
        const unique = data.filter((n, i) => data.indexOf(n) === i).length;
        process.stdout.write(`${unique - dataLength % 2}\n`);
        dataLength = 0;
    }
  }
}

main();

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function findKthLargest(nums, k) {
    k = nums.length - k;
    const quickSelect = (l, r) => {
        let pivot = nums[r];
        let p = l;
        for (let i = l; i < r; i++) {
            if (nums[i] <= pivot) {
                swapper(nums, p, i);
                p++;
            }
        }
        swapper(nums, p, r);

        if (p > k) return quickSelect(l, p - 1);
        else if (p < k) return quickSelect(p + 1, r);
        else return nums[p];
    };

    return quickSelect(0, nums.length - 1);
};

function swapper(array, a, b) {
    const temp = array[b];
    array[b] = array[a];
    array[a] = temp;
};

function main() {
    const n = parseInt(readline());
    for(var i=0; i<n; i++){
        const m = (readline());
        const s = new Set();
        var c =0;
        const d = readline();
        console.log(d);
        d.split(" ").map(r => {
            const x = parseInt(r);
            if(s.has(x)){
                c++;
            }
            s.add(x);
        });
        if(c % 2){
            c++;
        }
        foo(String(m-c));
    }
}
function foo(x) {
    process.stdout.write(x);   // without auto '\n' (newline)
    console.log();  // with auto '\n' (newline)
}

var input1 = Array();
var limitString = readline();
var limit = parseInt(limitString) * 2
for (var i = 0; i < limit; i++) {
    input1.push(readline());
}
var output1 = calc(input1);
output1.forEach(function (value) { print(value); });
function calc(input) {
    var result = Array();
    for (var i = 0; i < input.length; i += 2) {
        var caseLength = parseInt(input[i]);
        var caseArray = input[i + 1].split(" ");
        var caseMap = new Map();
        for (var j = 0; j < caseLength; j++) {
            var currentValue = parseInt(caseArray[j]);
            if (caseMap.has(currentValue)) {
                var count = caseMap[currentValue];
                count++;
                caseMap[currentValue] = count;
            }
            else {
                caseMap[currentValue] = 1;
            }
        }
        var resultValue = 0;
        if ((caseLength % 2) == 0) {
            if (caseMap.size % 2 == 0) {
                resultValue = caseMap.size;
            }
            else {
                resultValue = (caseMap.size - 1);
            }
        }
        else {
            if (caseMap.size % 2 == 0) {
                resultValue = caseMap.size - 1;
            }
            else {
                resultValue = caseMap.size;
            }
        }
        result.push(resultValue);
    }
    return result;
}

var test_cases = readline();
var nbr,arrayy;
var _set = new Set();
var zdeg = [];

while(test_cases--){
    _set.clear();
    nbr = readline();
    zdeg = readline().split(" ").map((el)=> {
        _set.add(parseInt(el))
        return 1;
        });

    print(_set.size == 1 ? nbr % 2 == 0 ? 0 : 1 : nbr == _set.size || nbr % 2 == 0 ? _set.size : _set.size - 1 )
}

var test_cases = readline();
var nbr,arrayy;
var _set = new Set();
var zdeg = [];

while(test_cases--){
    _set.clear();
    nbr = readline();
    zdeg = readline().split(" ").map((el)=> {
        _set.add(parseInt(el))
        return 1;
        });

    print(nbr === _set.size || nbr % 2 === 0 ? _set.size : _set.size - 1 )
}

var test_cases = 4
var nbr,arrayy;
var _set = new Set();
var zdeg = [];

while(test_cases--){
    nbr = readline();
    zdeg = readline().split(" ").map((el)=> {
        _set.add(el)
        return 1;
        });
    print(zdeg.length === _set.size || zdeg.length % 2 === 0 ? _set.size : _set.size -1 )
}

var test_cases = readline();
var nbr,arrayy;
var _set = new Set();
var zdeg = [];

while(test_cases--){
    nbr = readline();
    zdeg = readline().split(" ").map((el)=> {
        _set.add(el)
        return 1;
        });
    print(zdeg.length % 2 === 0 ? _set.size : _set.size -1 )
}

T = readline()
while (T--) {
   n = readline()
   x = readline().split(' ').map(x => +x)

   result = {}

   for( i=0; i<n; i++){
      a = x[i]
      if(result[a] != undefined)
         ++result[a]
      else
         result[a] = 1
   }

   maxKey = 0

   for(key in result){
      maxKey = Math.max(result[key], maxKey)
   }

   if(maxKey!= 1)
       ans = n - (maxKey-1) * 2
   else
      ans = n
   print(ans)
}

T = readline()
while (T--) {
   n = readline()
   x = readline().split(' ').map(x => +x)

   result = {}

   for( i=0; i<n; i++){
      a = x[i]
      if(result[a] != undefined)
         ++result[a]
      else
         result[a] = 1
   }

   maxKey = 0

   for(key in result){
      maxKey = Math.max(result[key], maxKey)
   }

   if(maxKey!= 1)
       ans = n - (maxKey-1) * 2
   else
      ans = 0
   print(ans)
}

T = readline()
while (T--) {
   n = readline()
   x = readline().split(' ').map(x => +x)

   result = {}

   for( i=0; i<n; i++){
      a = x[i]
      if(result[a] != undefined)
         ++result[a]
      else
         result[a] = 1
   }

   maxKey = 0

   for(key in result){
      maxKey = Math.max(result[key], maxKey)
   }

   ans = n - (maxKey-1) * 2
   print(ans)
}


Ilya is working for the company that constructs robots. Ilya writes programs for entertainment robots, and his current project is "Bob", a new-generation game robot. Ilya's boss wants to know his progress so far. Especially he is interested if Bob is better at playing different games than the previous model, "Alice". So now Ilya wants to compare his robots' performance in a simple game called "1-2-3". This game is similar to the "Rock-Paper-Scissors" game: both robots secretly choose a number from the set {1, 2, 3} and say it at the same moment. If both robots choose the same number, then it's a draw and noone gets any points. But if chosen numbers are different, then one of the robots gets a point: 3 beats 2, 2 beats 1 and 1 beats 3. Both robots' programs make them choose their numbers in such a way that their choice in (i + 1)-th game depends only on the numbers chosen by them in i-th game. Ilya knows that the robots will play k games, Alice will choose number a in the first game, and Bob will choose b in the first game. He also knows both robots' programs and can tell what each robot will choose depending on their choices in previous game. Ilya doesn't want to wait until robots play all k games, so he asks you to predict the number of points they will have after the final game.

The first line contains three numbers k, a, b (1 ≤ k ≤ 1018, 1 ≤ a, b ≤ 3).  Then 3 lines follow, i-th of them containing 3 numbers Ai, 1, Ai, 2, Ai, 3, where Ai, j represents Alice's choice in the game if Alice chose i in previous game and Bob chose j (1 ≤ Ai, j ≤ 3).  Then 3 lines follow, i-th of them containing 3 numbers Bi, 1, Bi, 2, Bi, 3, where Bi, j represents Bob's choice in the game if Alice chose i in previous game and Bob chose j (1 ≤ Bi, j ≤ 3).

Print two numbers. First of them has to be equal to the number of points Alice will have, and second of them must be Bob's score after k games.

NoteIn the second example game goes like this:The fourth and the seventh game are won by Bob, the first game is draw and the rest are won by Alice.

 var playScores = [
        [0, 1, -1],
        [-1, 0, 1],
        [1, -1, 0]
    ];

    function strip(array) {
        while (!array[0] && array.length > 1) {
            array.shift();
        }

        return array;
    }

    function toArray(str) {
        var r = [];
        for (var i = 0; i < str.length; i++) {
            r.push(parseInt(str[i]));
        }

        return r;
    }

    function subtractDigit(x, y) {
        var result = x.map(e => e);
        var i = x.length - 1;
        result[i] = result[i] - y;

        if (result[i] < 0) {
            result[i] += 10;
            var j = i - 1;
            while (j >= 0 && !result[j]) {
                result[j] = 9;
                j--;
            }

            result[j]--;
        }

        return strip(result);
    }

    function divide(x, y) {
        var result = [];
        var remainder = 0;
        for (var i = 0; i < x.length; i++) {
            var current = x[i] + 10 * remainder;

            remainder = current % y;
            result.push((current - remainder) / y);
        }

        strip(result);
        return {
            result,
            remainder
        };
    }

    function multiply(x, y) {
        var result = [];
        var carry = 0;

        for (var i = x.length - 1; i >= 0; i--) {
            var r = x[i] * y + carry;
            carry = Math.floor(r / 10);
            result.unshift(r % 10);
        }

        while (carry) {
            result.unshift(carry % 10);
            carry = Math.floor(carry / 10);
        }

        return strip(result);
    }

    function add(x, y) {
        var result = [];

        for (var i = x.length - 1; i >= 0; i--) {
            if (y) {
                var r = x[i] + y;
                y = Math.floor(r / 10);
                result.unshift(r % 10);
            } else {
                result.unshift(x[i]);
            }
        }

        while (y) {
            result.unshift(y % 10);
            y = Math.floor(y / 10);
        }

        return strip(result);
    }

    // read input
    var gameParams = readline().split(' ');

    var gamesToPlay = parseInt(gameParams[0]);
    var aliceStart = parseInt(gameParams[1]);
    var bobStart = parseInt(gameParams[2]);

    var gameStages = [];

    for (var i = 0; i < 3; i++) {
        gameStages.push([]);
        var line = readline().split(' ');
        for (var j = 0; j < line.length; j++) {
            gameStages[i].push({
                playedGames: 0,
                alice: parseInt(line[j])
            });
        }
    }

    for (var i = 0; i < 3; i++) {
        var line = readline().split(' ');
        for (var j = 0; j < line.length; j++) {
            var stage = gameStages[i][j];
            stage.bob = parseInt(line[j]);

            var score = playScores[stage.alice - 1][stage.bob - 1];
            stage.score = {
                alice: -Math.min(0, score),
                bob: Math.max(0, score)
            };
        }
    }

    // play
    var firstScore = playScores[aliceStart - 1][bobStart - 1];

    var stage = gameStages[aliceStart - 1][bobStart - 1];
    stage.accumulatedScore = {
        alice: -Math.min(0, firstScore),
        bob: Math.max(0, firstScore)
    };

    var accumulatedScore = stage.accumulatedScore;
    var playedGames = 1;

    while (playedGames < gamesToPlay && !stage.playedGames) {
        // play stage
        stage.playedGames = playedGames;
        stage.accumulatedScore = accumulatedScore;

        accumulatedScore = {
            alice: accumulatedScore.alice + stage.score.alice,
            bob: accumulatedScore.bob + stage.score.bob
        };

        stage = gameStages[stage.alice - 1][stage.bob - 1];
        playedGames++;
    }

    var finalScore;
    if (playedGames === gamesToPlay) {
        finalScore = accumulatedScore;
    } else {
        finalScore = {
            alice: stage.accumulatedScore.alice,
            bob: stage.accumulatedScore.bob
        };

        var loopGames = playedGames - stage.playedGames;

        if (gamesToPlay <= Number.MAX_SAFE_INTEGER) {
            gamesToPlay -= stage.playedGames;

            var beforeLoopScore = stage.accumulatedScore;
            var loopScore = {
                alice: accumulatedScore.alice - stage.accumulatedScore.alice,
                bob: accumulatedScore.bob - stage.accumulatedScore.bob
            };

            var reps = Math.floor(gamesToPlay / loopGames);
            finalScore.alice += loopScore.alice * reps;
            finalScore.bob += loopScore.bob * reps;

            var rem = gamesToPlay % loopGames;
            while (rem >= 1) {
                if (rem === 1) {
                    finalScore.alice += stage.accumulatedScore.alice - beforeLoopScore.alice + stage.score.alice;
                    finalScore.bob += stage.accumulatedScore.bob - beforeLoopScore.bob + stage.score.bob;
                    break;
                } else {
                    stage = gameStages[stage.alice - 1][stage.bob - 1];
                    rem--;
                }
            }
        } else {
            var gamesToPlayBig = subtractDigit(toArray(gameParams[0]), stage.playedGames);

            var beforeLoopScore = stage.accumulatedScore;
            var loopScore = {
                alice: accumulatedScore.alice - stage.accumulatedScore.alice,
                bob: accumulatedScore.bob - stage.accumulatedScore.bob
            };

            var reps = divide(gamesToPlayBig, loopGames);

            finalScore.alice = add(multiply(reps.result, loopScore.alice), finalScore.alice);
            finalScore.bob = add(multiply(reps.result, loopScore.bob), finalScore.bob);

            while (reps.remainder >= 1) {
                if (reps.remainder === 1) {
                    finalScore.alice = add(finalScore.alice, stage.accumulatedScore.alice - beforeLoopScore.alice + stage.score.alice);
                    finalScore.bob = add(finalScore.bob, stage.accumulatedScore.bob - beforeLoopScore.bob + stage.score.bob);
                    break;
                } else {
                    stage = gameStages[stage.alice - 1][stage.bob - 1];
                    reps.remainder--;
                }
            }

            finalScore.alice = finalScore.alice.join('');
            finalScore.bob = finalScore.bob.join('');
        }
    }

    print(finalScore.alice + ' ' + finalScore.bob);

  var scores = [
        [0, 1, -1],
        [-1, 0, 1],
        [1, -1, 0]
    ];

    var score = (a, b) => {
        var s = scores[a - 1][b - 1];
        return {
            alice: -Math.min(0, s),
            bob: Math.max(0, s)
        };
    };

    // read input
    var gameParams = readline().split(' ');

    var gamesToPlay = parseInt(gameParams[0]) - 1; // first game is special
    var aliceStart = parseInt(gameParams[1]);
    var bobStart = parseInt(gameParams[2]);

    var gameStages = [];

    for (var i = 0; i < 3; i++) {
        gameStages.push([]);
        var line = readline().split(' ');
        for (var j = 0; j < line.length; j++) {
            gameStages[i].push({
                aliceStrategy: parseInt(line[j]),
                played: 0
            });
        }
    }

    for (var i = 0; i < 3; i++) {
        var line = readline().split(' ');
        for (var j = 0; j < line.length; j++) {
            gameStages[i][j].bobStrategy = parseInt(line[j]);
            gameStages[i][j].score = score(gameStages[i][j].aliceStrategy, gameStages[i][j].bobStrategy);
        }
    }

    // play
    var scoresLog = [];
    var lastScore = {
        alice: 0,
        bob: 0
    };

    var stage = gameStages[aliceStart - 1][bobStart - 1];
    while (scoresLog.length < gamesToPlay && !stage.played) {
        stage.played = scoresLog.length;
        scoresLog.push({
            alice: lastScore.alice + stage.score.alice,
            bob: lastScore.bob + stage.score.bob
        });

        stage = gameStages[stage.aliceStrategy - 1][stage.bobStrategy - 1];
        lastScore = scoresLog[scoresLog.length - 1];
    }

    var gamesPlayed = scoresLog.length;
    var finalScore;
    if (gamesPlayed === gamesToPlay) {
        finalScore = lastScore;
    } else {
        var beforeLoop = scoresLog[stage.played - 1];
        finalScore = {
            alice: beforeLoop.alice,
            bob: beforeLoop.bob
        };

        gamesPlayed -= stage.played;
        gamesToPlay -= stage.played;

        var reps = Math.floor(gamesToPlay / gamesPlayed);
        finalScore.alice += (lastScore.alice - beforeLoop.alice) * reps;
        finalScore.bob += (lastScore.bob - beforeLoop.bob) * reps;

        var rem = gamesToPlay % gamesPlayed;
        if (rem > 0) {
            finalScore.alice += scoresLog[stage.played + rem - 1].alice;
            finalScore.bob += scoresLog[stage.played + rem - 1].bob;
        }
    }

    var firstScore = score(aliceStart, bobStart);
    finalScore.alice += firstScore.alice;
    finalScore.bob += firstScore.bob;

    print(finalScore.alice + ' ' + finalScore.bob);

  var scores = [
        [0, 1, -1],
        [-1, 0, 1],
        [1, -1, 0]
    ];

    var score = (a, b) => {
        var s = scores[a - 1][b - 1];
        return {
            alice: -Math.min(0, s),
            bob: Math.max(0, s)
        }
    };

    // read input
    var gameParams = readline().split(' ');

    var gamesToPlay = parseInt(gameParams[0]) - 1; // first game is special
    var aliceStart = parseInt(gameParams[1]);
    var bobStart = parseInt(gameParams[2]);

    var gameStages = [];

    for (var i = 0; i < 3; i++) {
        gameStages.push([]);
        readline().split(' ').forEach(e => {
            gameStages[i].push({
                aliceStrategy: parseInt(e),
                played: false
            })
        });
    }

    for (var i = 0; i < 3; i++) {
        readline().split(' ').forEach((e, j) => {
            gameStages[i][j].bobStrategy = parseInt(e);
            gameStages[i][j].score = score(gameStages[i][j].aliceStrategy, gameStages[i][j].bobStrategy)
        });
    }

    // play
    var scoresLog = [];
    var lastScore = {
        alice: 0,
        bob: 0
    };

    var stage = gameStages[aliceStart - 1][bobStart - 1];
    while (scoresLog.length < gamesToPlay && !stage.played) {
        scoresLog.push({
            alice: lastScore.alice + stage.score.alice,
            bob: lastScore.bob + stage.score.bob

        });

        stage.played = true;

        stage = gameStages[stage.aliceStrategy - 1][stage.bobStrategy - 1];
        lastScore = scoresLog[scoresLog.length - 1];
    }

    var gamesPlayed = scoresLog.length;
    var finalScore;
    if (gamesPlayed === gamesToPlay) {
        finalScore = lastScore;
    } else {
        var reps = Math.floor(gamesToPlay / gamesPlayed);
        var finalScore = {
            alice: lastScore.alice * reps,
            bob: lastScore.bob * reps
        };
        var rem = gamesToPlay % gamesPlayed;
        if (rem > 0) {
            finalScore.alice += scoresLog[rem - 1].alice;
            finalScore.bob += scoresLog[rem - 1].bob;
        }
    }

    var firstScore = score(aliceStart, bobStart);
    finalScore.alice += firstScore.alice;
    finalScore.bob += firstScore.bob;

    print(finalScore.alice + ' ' + finalScore.bob);

  var scores = [
        [0, 1, -1],
        [-1, 0, 1],
        [1, -1, 0]
    ];

    var score = (a, b) => {
        var s = scores[a - 1][b - 1];
        return {
            alice: -Math.min(0, s),
            bob: Math.max(0, s)
        };
    };

    // read input
    var gameParams = readline().split(' ');

    var gamesToPlay = parseInt(gameParams[0]) - 1; // first game is special
    var aliceStart = parseInt(gameParams[1]);
    var bobStart = parseInt(gameParams[2]);

    var gameStages = [];

    for (var i = 0; i < 3; i++) {
        gameStages.push([]);
        var line = readline().split(' ');
        for (var j = 0; j < line.length; j++) {
            gameStages[i].push({
                aliceStrategy: parseInt(line[j]),
                played: 0
            });
        }
    }

    for (var i = 0; i < 3; i++) {
        var line = readline().split(' ');
        for (var j = 0; j < line.length; j++) {
            gameStages[i][j].bobStrategy = parseInt(line[j]);
            gameStages[i][j].score = score(gameStages[i][j].aliceStrategy, gameStages[i][j].bobStrategy);
        }
    }

    // play
    var scoresLog = [];
    var lastScore = {
        alice: 0,
        bob: 0
    };

    var stage = gameStages[aliceStart - 1][bobStart - 1];
    while (scoresLog.length < gamesToPlay && !stage.played) {
        stage.played = scoresLog.length;
        scoresLog.push({
            alice: lastScore.alice + stage.score.alice,
            bob: lastScore.bob + stage.score.bob
        });

        stage = gameStages[stage.aliceStrategy - 1][stage.bobStrategy - 1];
        lastScore = scoresLog[scoresLog.length - 1];
    }

    var gamesPlayed = scoresLog.length;
    var finalScore;
    if (gamesPlayed === gamesToPlay) {
        finalScore = lastScore;
    } else {
        var beforeLoop = scoresLog[stage.played - 1];
        finalScore = {
            alice: beforeLoop.alice,
            bob: beforeLoop.bob
        };

        gamesPlayed -= stage.played;
        gamesToPlay -= stage.played;

        var reps = Math.floor(gamesToPlay / gamesPlayed);
        finalScore.alice += (lastScore.alice - beforeLoop.alice) * reps;
        finalScore.bob += (lastScore.bob - beforeLoop.bob) * reps;

        var rem = gamesToPlay % gamesPlayed;
        if (rem > 0) {
            finalScore.alice += scoresLog[stage.played - 1 + rem - 1].alice;
            finalScore.bob += scoresLog[stage.played - 1 + rem - 1].bob;
        }
    }

    var firstScore = score(aliceStart, bobStart);
    finalScore.alice += firstScore.alice;
    finalScore.bob += firstScore.bob;

    print(finalScore.alice + ' ' + finalScore.bob);


The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct. A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case?

The first line contains a positive integer n (1 ≤ n ≤ 100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1 ≤ ai ≤ 109), the number of answer variants to question i.

Print a single number — the minimal number of clicks needed to pass the test it the worst-case scenario.  Please do not use the %lld specificator to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specificator.

NoteNote to the second sample. In the worst-case scenario you will need five clicks:   the first click selects the first variant to the first question, this answer turns out to be wrong.  the second click selects the second variant to the first question, it proves correct and we move on to the second question;  the third click selects the first variant to the second question, it is wrong and we go back to question 1;  the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question;  the fifth click selects the second variant to the second question, it proves correct, the test is finished.

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 printValues() {
	var parts = [];
	for (var i = 0; i < arguments.length; i += 2) {
		parts.push(arguments[i]+' = '+arguments[i+1]);
	}
	print(parts.join(', '));
}

function main() {
  var n = parseInt(readline(), 10),
      data = tokenizeIntegers(readline()),
      total = 0;
  for (var i = 0; i < n; ++i) {
    var count = data[i];
    total += 1 + (count-1)*(i+1);
  }
  print(total);
}

main();


Given an array of $$$n$$$ positive integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 1000$$$). Find the maximum value of $$$i + j$$$ such that $$$a_i$$$ and $$$a_j$$$ are coprime,$$$^{\dagger}$$$ or $$$-1$$$ if no such $$$i$$$, $$$j$$$ exist.For example consider the array $$$[1, 3, 5, 2, 4, 7, 7]$$$. The maximum value of $$$i + j$$$ that can be obtained is $$$5 + 7$$$, since $$$a_5 = 4$$$ and $$$a_7 = 7$$$ are coprime.$$$^{\dagger}$$$ Two integers $$$p$$$ and $$$q$$$ are coprime if the only positive integer that is a divisor of both of them is $$$1$$$ (that is, their greatest common divisor is $$$1$$$).

The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains an integer $$$n$$$ ($$$2 \leq n \leq 2\cdot10^5$$$) — the length of the array. The following line contains $$$n$$$ space-separated positive integers $$$a_1$$$, $$$a_2$$$,..., $$$a_n$$$ ($$$1 \leq a_i \leq 1000$$$) — the elements of the array. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$2\cdot10^5$$$.

For each test case, output a single integer  — the maximum value of $$$i + j$$$ such that $$$i$$$ and $$$j$$$ satisfy the condition that $$$a_i$$$ and $$$a_j$$$ are coprime, or output $$$-1$$$ in case no $$$i$$$, $$$j$$$ satisfy the condition.

NoteFor the first test case, we can choose $$$i = j = 3$$$, with sum of indices equal to $$$6$$$, since $$$1$$$ and $$$1$$$ are coprime.For the second test case, we can choose $$$i = 7$$$ and $$$j = 5$$$, with sum of indices equal to $$$7 + 5 = 12$$$, since $$$7$$$ and $$$4$$$ are coprime.

'use strict';

var fs = require('fs');

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

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

function solve(read) {
  const [rn, rb, rns, re, rbs] = convertInput(read);
  const n = rn(),
        N = 1005;
  let res = -1,
      cnt = new Array(N);
  for (let i = 1; i <= n; i++) {
    cnt[rn()] = i;
  }
  for (let i = 0; i <= N; i++) {
    if (cnt[i] === undefined) continue;
    for (let j = i; j <= N; j++) {
      if (cnt[j] === undefined) continue;
      if (gcd(i, j) === 1) res = Math.max(res, cnt[i] + cnt[j]);
    }
  }
  return res;
}
function gcd(a, b) {
  return b ? gcd(b, a % b) : a;
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn();
    return res;
  };
  const re = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rn() - 1;
    return res;
  };
  const rbs = n => {
    let res = new Array(n);
    for (let i = 0; i < n; i++) res[i] = rb();
    return res;
  };
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  const [rn, rb, rns, re, rbs] = convertInput(r);
  try {
    let t = rn();
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      var _solve;
      const s = (_solve = solve(r)) !== null && _solve !== void 0 ? _solve : '';
      if (t < limit) {
        process.stdout.write(s.toString());
        process.stdout.write('\n');
      } else {
        res[i] = s;
      }
    }
    if (t >= limit) {
      return res.join('\n');
    } else {
      return '';
    }
  } catch (error) {
    console.log(error);
  }
}

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

let buf='';

process.stdin.on('readable',function(){
    let chunk=process.stdin.read();
    if(chunk) buf+=chunk.toString();
})

process.stdin.on('end',function(){
    const {EOL}=require('os');
    let line=buf.split(EOL);
    let t=parseInt(line[0]);
    // console.log(line);
    let gcd=(a,b) => {
        if(!b) return a;
        return gcd(b,a%b);
    }
    for(let i=1;i<=t;i++)
    {
        let n=parseInt(line[2*i-1]);
        let a=line[2*i].split(' ').map(x=>{ return parseInt(x); });
        let ans=-1;
        let pos=new Array(1010);
        for(let i=0;i<n;i++) pos[a[i]]=i+1;
        for(let k=1;k<=1000;k++) {
            let x=k;
            if(!pos[k]) continue;
            for(let i=1;i<=1000;i++) {
                if(pos[i]&&gcd(x,i)===1) {
                    ans=Math.max(ans,pos[k]+pos[i]);
                }
            }
        }
        console.log(ans);
    }
})

const readline = require('readline')

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

function solve(n, arr) {
    const m = arr.reduce((o, x, i) => {
        o[x] = i
        return o
    }, {})
    const cp = Array(1e3 + 1)
    for (let i = 1; i <= 1e3; i++) {
        cp[i] = -1
        for (let j = 1; j <= 1e3; j++) {
            if ((j in m) && gcd(i, j) === 1) {
                cp[i] = Math.max(cp[i], m[j])
            }
        }
    }
    let r = -1
    for (let i = 0; i < arr.length; i++) {
        const x = arr[i]
        if (cp[x] >= 0) {
            r = Math.max(r, i + cp[x] + 2)
        }
    }
    return r
}
function gcd(a, b) {
    if (a === 0) return b
    if (b === 0) return a

    while (a) {
        const r = b % a
        b = a
        a = r
    }
    return b
}

/*
* auther yeling
*
*
*/
'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 print(str) {
    console.log(str);
}

//TLE o(n^2)
function begin2(n, nums) {
    var gcd = function (a, b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

    let max = -1;
    for(let i = 0; i < n; i++) {
        for(let j = 0; j < n; j++) {
            if(gcd(nums[i], nums[j]) == 1) {
                max = Math.max(max, i+j+2);
            }
        }
    }
    print(max);
}

function begin(n, nums) {
    var gcd = function (a, b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
    let cache = new Array(1001).fill(-1);
    for(let i = 0; i < n; i++) {
        cache[nums[i]] = Math.max(cache[nums[i]], i+1);
    }

    let max = -1
    for(let i = 1; i <= 1000; i++) {
        for(let j = 1; j <= 1000; j++) {
            if(cache[i] != -1 && cache[j] != -1 && gcd(i, j) == 1) {
                max = Math.max(max, cache[i]+cache[j]);
            }
        }
    }
    print(max);
}

function main() {
    var caseNum = parseInt(readline(), 10);
    for (var i = 0; i < caseNum; i++) {
        var n = parseInt(readline(), 10);
        var x = readline()
            .trim()
            .split(' ')
            .map((y) => parseInt(y, 10));
        begin(n, x);
    }
}

/**
 * 10/13/22 morning
 * https://codeforces.com/contest/1742/problem/D
 */

const pr = console.log;

const gcd = (a, b) => b == 0 ? a : gcd(b, a % b);

const solve = (n, a) => {
    let m = new Map(), res = -1;
    for (let i = 0; i < n; i++) {
        if (!m.has(a[i])) m.set(a[i], []);
        m.get(a[i]).push(i + 1);
    }
    for (const [x, ax] of m) {
        for (let y = 1; y <= 1000; y++) {
            if (m.has(y) && gcd(x, y) == 1) {
                let ay = m.get(y), i = ax[ax.length - 1], j = ay[ay.length - 1];
                // pr(x, ax, y, ay);
                res = Math.max(res, i + j);
            }
        }
    }
    pr(res);
};

const main = () => {
    const readLine = () => input[currentLine++];
    const ni = () => readLine() - '0';
    const nas = () => readLine().split(" ");
    const nai = () => nas().map(Number);
    const nal = () => nas().map(BigInt);
    let input = '', currentLine = 0;
    process.stdin.on('data', (stdin) => input += stdin)
    process.stdin.on('end', () => {
        input = input.split('\n');
        let t = ni();
        while (t--) {
            let n = ni(), a = nai();
            solve(n, a);
        }
    });
};

main()

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var map = {};
	for(var i = 1; i <= 1000; i++){
		for(var j = 1; j <= 1000; j++){
			if(gcd(i, j) == 1){
				if(map[i] == null){
					map[i] = [];
				}
				map[i].push(j);
			}
		}
	}
	while(hasNext()){
		var N = nextInt();
		var list = nextStrArray(N);
		var index = {};
		for(var i = 0; i < N; i++){
			if(index[list[i]] == null){
				index[list[i]] = 0;
			}
			index[list[i]] = i + 1;
		}
		var output = -1;
		for(var i = 0; i < N; i++){
			var s = map[list[i]];
			for(var j = 0; j < s.length; j++){
				if(index[s[j]] != null){
					output = Math.max(output, i + 1 + index[s[j]]);
				}
			}
		}
		myout(output);
	}
}
function gcd(m, n) {return n != 0 ? gcd(n, m % n) : m;}


$$$n$$$ students attended the first meeting of the Berland SU programming course ($$$n$$$ is even). All students will be divided into two groups. Each group will be attending exactly one lesson each week during one of the five working days (Monday, Tuesday, Wednesday, Thursday and Friday), and the days chosen for the groups must be different. Furthermore, both groups should contain the same number of students.Each student has filled a survey in which they told which days of the week are convenient for them to attend a lesson, and which are not. Your task is to determine if it is possible to choose two different week days to schedule the lessons for the group (the first group will attend the lesson on the first chosen day, the second group will attend the lesson on the second chosen day), and divide the students into two groups, so the groups have equal sizes, and for each student, the chosen lesson day for their group is convenient.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of testcases. Then the descriptions of $$$t$$$ testcases follow. The first line of each testcase contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of students. The $$$i$$$-th of the next $$$n$$$ lines contains $$$5$$$ integers, each of them is $$$0$$$ or $$$1$$$. If the $$$j$$$-th integer is $$$1$$$, then the $$$i$$$-th student can attend the lessons on the $$$j$$$-th day of the week. If the $$$j$$$-th integer is $$$0$$$, then the $$$i$$$-th student cannot attend the lessons on the $$$j$$$-th day of the week.  Additional constraints on the input: for each student, at least one of the days of the week is convenient, the total number of students over all testcases doesn't exceed $$$10^5$$$.

For each testcase print an answer. If it's possible to divide the students into two groups of equal sizes and choose different days for the groups so each student can attend the lesson in the chosen day of their group, print "YES" (without quotes). Otherwise, print "NO" (without quotes).

NoteIn the first testcase, there is a way to meet all the constraints. For example, the first group can consist of the first and the third students, they will attend the lessons on Thursday (the fourth day); the second group can consist of the second and the fourth students, and they will attend the lessons on Tuesday (the second day).In the second testcase, it is impossible to divide the students into groups so they attend the lessons on different days.

const solve = (n,arr)=>{
     for(let i=0;i<5;i++){
          for(let j=0;j<5;j++){
               let cnt = 0,cnt1 = 0,cnt2 = 0;
               if(i!==j){
                    for(let k=0;k<n;k++){
                         if(arr[k][i]===1) cnt1++;
                         if(arr[k][j]===1) cnt2++;
                         if(arr[k][i]===0 && arr[k][j]===0) cnt=1;
                    }
                    if((cnt1>=n/2)&&(cnt2>=n/2)&&(cnt===0)) return "YES";
               }
          }
     }
     return "NO";
}
function main() {
  const fs = require("fs");
  const input = fs.readFileSync(0, "utf8").trim().split("\n");
  let line = 0;
  function readline() {
    return input[line++];
  }
  let t = parseInt(readline());
  for(let i=0;i<t;i++){
       let n = parseInt(readline());
       let arr =  [];
       for(let i=0;i<n;i++){
            arr.push(readline().trim().split(" ").map(cur=>parseInt(cur)));
       }
       console.log(solve(n,arr));
  }
}
main();

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const avl = [];
		for (let i = 0; i < n; i++)
			avl[i] = rna();

		let ans;
		for (let i = 0; i < 5; i++) {
			for (let j = i + 1; j < 5; j++) {
				let cnt1 = 0, cnt2 = 0, ok = true;
				for (let k = 0; ok && k < n; k++) {
					cnt1 += avl[k][i];
					cnt2 += avl[k][j];

					ok = avl[k][i] || avl[k][j];
				}
				ans = ans || ok && n%2==0 && cnt1 >= n/2 && cnt2 >= n/2;
			}
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

// dist/FinalCode/Common/InputOutputClass.js
var Input = function() {
  function Input2(inputData) {
    var _this = this;
    this.SettleStream = function() {
      var re = /\s+/;
      _this.inputWords = _this.inputStream.split(re);
      _this.inputWordsLength = _this.inputWords.length;
    };
    this.getLength = function() {
      return _this.inputWordsLength;
    };
    this.getEveryWord = function() {
      return _this.inputWords;
    };
    this.getNextWord = function() {
      _this.inputWordsCount++;
      if (_this.inputWordsLength < _this.inputWordsCount) {
        return "";
      }
      return _this.inputWords[_this.inputWordsCount - 1];
    };
    this.getNextString = function() {
      return _this.getNextWord();
    };
    this.getNextBigInt = function() {
      return BigInt(_this.getNextWord());
    };
    this.getNextNumber = function() {
      return Number(_this.getNextWord());
    };
    this.getNextInt = function() {
      return parseInt(_this.getNextWord(), 10);
    };
    this.getNextFloat = function() {
      return parseFloat(_this.getNextWord());
    };
    this.inputWordsCount = 0;
    this.inputStream = inputData;
  }
  Input2.prototype.SetStream = function(chunk) {
    this.inputStream += chunk;
  };
  return Input2;
}();
var InputOutputClass_default = Input;
var writeLine = function(outputElement) {
  var _internalWrite = function(_internalOutputElement) {
    process.stdout.write(_internalOutputElement);
  };
  _internalWrite(String(outputElement) + "\n");
};

// dist/main.js
var rw = new InputOutputClass_default("");
process.stdin.resume();
process.stdin.setEncoding("utf-8");
process.stdin.on("data", function(chunk) {
  rw.SetStream(chunk);
});
process.stdin.on("end", function() {
  rw.SettleStream();
  mainFunc();
});
var mainFunc = function() {
  testCases();
};
var testCases = function() {
  var test = rw.getNextInt();
  for (var i = 0; i < test; i++) {
    solveCase();
  }
};
var createArray = function(initSize) {
  var result = new Array(initSize);
  for (var i = 0; i < initSize; i += 1) {
    result[i] = new Array();
  }
  return result;
};
var solveCase = function() {
  var num = rw.getNextInt();
  var week = createArray(num);
  for (var i = 0; i < num; i++) {
    for (var j = 0; j < 5; j++) {
      week[i].push(rw.getNextInt());
    }
  }
  for (var i = 0; i < 5; i++) {
    for (var j = i + 1; j < 5; j++) {
      var a = 0;
      var b = 0;
      var c = 0;
      for (var k = 0; k < num; k++) {
        if (week[k][i] === 1 && week[k][j] === 1) {
          c += 1;
          continue;
        }
        a += week[k][i];
        b += week[k][j];
      }
      if (a < num / 2 && c >= num / 2 - a) {
        c -= num / 2 - a;
        a = num / 2;
      }
      if (b < num / 2 && c >= num / 2 - b) {
        c -= num / 2 - b;
        b = num / 2;
      }
      if (a >= num / 2 && b >= num / 2) {
        writeLine("YES");
        return;
      }
    }
  }
  writeLine("NO");
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	while(hasNext()){
		var N = nextInt();
		var list = new Array(N);
		for(var i = 0; i < N; i++){
			list[i] = nextIntArray(5);
		}
		var isOK = false;
		for(var i = 0; i < 4; i++){
			for(var j = i + 1; j < 5; j++){
				var ato = 0;
				var L = 0;//i
				var R = 0;//j
				var isNG = false;
				for(var k = 0; k < N; k++){
					if(list[k][i] == 1 && list[k][j] == 1){
						ato++;
					}else if(list[k][i] == 1 && list[k][j] == 0){
						L++;
					}else if(list[k][i] == 0 && list[k][j] == 1){
						R++;
					}else{
						isNG = true;//no select
						break;
					}
				}
				if(!isNG){
					if(L <= (N / 2) && R <= (N / 2) && L + R + ato == N){
						isOK = true;
					}
				}
			}
		}
		myout((isOK) ? "YES" : "NO");
	}
}

const readline = require('readline')

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

function solve(n, grid) {
    for (let i = 0; i < 5; i++) {
        for (let j = i + 1; j < 5; j++) {
            if (check(n, grid, i, j)) return 'YES'
        }
    }
    return 'NO'
}
function check(n, grid, a, b) {
    let both = 0
    let ca = 0
    let cb = 0
    for (let i = 0; i < n; i++) {
        if (grid[i][a] && grid[i][b]) {
            both++
        } else if (grid[i][a]) {
            ca++
        } else if (grid[i][b]) {
            cb++
        } else {
            return false
        }
    }
    // console.log(both, ca, cb)
    return both + ca >= n / 2 && both + cb >= n / 2
}

const solve = (n,arr1)=>{
     let arr = [];
     for(let i=0;i<n;i++){
          let flag = 0;
          for(let j=0;j<5;j++){
               if(arr1[i][j]===1){
                    flag = 1;
                    break;
               }
          }
          if(flag) arr.push(arr1[i]);
     }
     if(arr.length%2===1) return "NO";
     n = arr.length;
     let d = {};
     for(let i=0;i<5;i++){
          let t=[];
          for(let j=0;j<n;j++){
               if(arr[j][i]===1) t.push(j+1);
          }
          if(t.length>=n/2) d[i+1] = t;
     }
     let t = Object.keys(d);
     if(t.length<2) return "NO";
     let r = new Set();
     for(let i=0;i<t.length;i++){
          let k = d[t[i]];
          for(let j=0;j<k.length;j++) r.add(k[j]);
     }
     let cnt = 0;
     for(let i=1;i<=n;i++) if(r.has(i)===true) cnt++;
     if(cnt%2===0) return "YES";
     else return "NO";

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

const solve = (n,arr)=>{
     let d = {};
     for(let i=0;i<5;i++){
          let t=[];
          for(let j=0;j<n;j++){
               if(arr[j][i]===1) t.push(j+1);
          }
          if(t.length>=n/2) d[i+1] = (t);
     }
     let t = Object.keys(d);
     if(t.length<2) return "NO";
     let r = new Set();
     for(let i=0;i<t.length;i++){
          let k = d[t[i]];
          for(let j=0;j<k.length;j++) r.add(k[j]);
     }
     for(let i=1;i<=n;i++) if(r.has(i)===false) return "NO";
     return "YES";

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

const solve = (n,arr)=>{
     let d = {};
     for(let i=0;i<5;i++){
          let t=[];
          for(let j=0;j<n;j++){
               if(arr[j][i]===1) t.push(j+1);
          }
          if(t.length>=n/2) d[i+1] = (t);
     }
     let t = Object.keys(d);
     if(t.length<2) return "NO";
     let r = new Set();
     for(let i=0;i<t.length;i++){
          let k = d[t[i]];
          for(let i=0;i<k.length;i++) r.add(k[i]);
     }
     for(let i=1;i<=n;i++) if(r.has(i)===false) return "NO";
     return "YES";

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

const solve = (n,arr)=>{
     let d = {};
     for(let i=0;i<5;i++){
          let t=[];
          for(let j=0;j<n;j++){
               if(arr[j][i]===1) t.push(j+1);
          }
          if(t.length>=n/2) d[i+1] = (t);
     }
     let t = Object.keys(d);
     if(t.length<2) return "NO";
     let r = new Set();
     for(let i=0;i<t.length;i++){
          let k = d[t[i]];
          for(let i=0;i<n;i++) r.add(k[i]);
     }
     for(let i=1;i<=n;i++) if(r.has(i)===false) return "NO";
     return "YES";

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

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const avl = [];
		for (let i = 0; i < n; i++)
			avl[i] = rna();

		let ans;
		for (let i = 0; i < 5; i++) {
			for (let j = i + 1; j < 5; j++) {
				let cnt1 = 0, cnt2 = 0, ok = true;
				for (let k = 0; k < n; k++) {
					cnt1 += avl[k][i];
					cnt2 += avl[k][j];

					ok = ok && !avl[k][i] && !avl[k][j];
				}
				ans = ans || ok && n%2==0 && cnt1 >= n/2 && cnt2 >= n/2;
			}
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const avl = [];
		for (let i = 0; i < n; i++)
			avl[i] = rna();

		let ans;
		for (let i = 0; i < 5; i++) {
			for (let j = i + 1; j < 5; j++) {
				let cnt1 = 0, cnt2 = 0, ok = true;
				for (let k = 0; k < n; k++) {
					if (avl[k][i])
						cnt1++;
					else if (avl[k][j])
						cnt2++;
					else
						ok = false;
				}
				ans = ans || (ok && n%2==0 && cnt1 >= n/2 && cnt2 >= n/2);
			}
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const avl = [];
		for (let i = 0; i < n; i++)
			avl[i] = rna();

		let ans;
		for (let i = 0; i < 5; i++) {
			for (let j = i + 1; j < 5; j++) {
				let cnt1 = 0, cnt2 = 0, ok = true;
				for (let k = 0; k < n; k++) {
					if (avl[k][i])
						cnt1++;
					else if (avl[k][j])
						cnt2++;
					else
						ok = false;
				}
				ans = ans || ok && n%2==0 && cnt1 >= n/2 && cnt2 >= n/2;
			}
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

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

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

function main () {
	let T = rn();
	while (T--) {
		const n = rn();
		const avl = [];
		for (let i = 0; i < n; i++)
			avl[i] = rna();

		let ans;
		for (let i = 0; i < 5; i++) {
			for (let j = i + 1; j < 5; j++) {
				let cnt1 = 0, cnt2 = 0;
				for (let k = 0; k < n; k++) {
					if (avl[k][i])
						cnt1++;
					if (avl[k][j])
						cnt2++;
				}
				ans = ans || n%2==0 && cnt1 >= n/2 && cnt2 >= n/2;
			}
		}

		console.log(ans ? 'YES' : 'NO');
	}
}

// dist/FinalCode/Common/InputOutputClass.js
var Input = function() {
  function Input2(inputData) {
    var _this = this;
    this.SettleStream = function() {
      var re = /\s+/;
      _this.inputWords = _this.inputStream.split(re);
      _this.inputWordsLength = _this.inputWords.length;
    };
    this.getLength = function() {
      return _this.inputWordsLength;
    };
    this.getEveryWord = function() {
      return _this.inputWords;
    };
    this.getNextWord = function() {
      _this.inputWordsCount++;
      if (_this.inputWordsLength < _this.inputWordsCount) {
        return "";
      }
      return _this.inputWords[_this.inputWordsCount - 1];
    };
    this.getNextString = function() {
      return _this.getNextWord();
    };
    this.getNextBigInt = function() {
      return BigInt(_this.getNextWord());
    };
    this.getNextNumber = function() {
      return Number(_this.getNextWord());
    };
    this.getNextInt = function() {
      return parseInt(_this.getNextWord(), 10);
    };
    this.getNextFloat = function() {
      return parseFloat(_this.getNextWord());
    };
    this.inputWordsCount = 0;
    this.inputStream = inputData;
  }
  Input2.prototype.SetStream = function(chunk) {
    this.inputStream += chunk;
  };
  return Input2;
}();
var InputOutputClass_default = Input;
var writeLine = function(outputElement) {
  var _internalWrite = function(_internalOutputElement) {
    process.stdout.write(_internalOutputElement);
  };
  _internalWrite(String(outputElement) + "\n");
};

// dist/main.js
var rw = new InputOutputClass_default("");
process.stdin.resume();
process.stdin.setEncoding("utf-8");
process.stdin.on("data", function(chunk) {
  rw.SetStream(chunk);
});
process.stdin.on("end", function() {
  rw.SettleStream();
  mainFunc();
});
var mainFunc = function() {
  testCases();
};
var testCases = function() {
  var test = rw.getNextInt();
  for (var i = 0; i < test; i++) {
    solveCase();
  }
};
var createArray = function(initSize) {
  var result = new Array(initSize);
  for (var i = 0; i < initSize; i += 1) {
    result[i] = new Array();
  }
  return result;
};
var solveCase = function() {
  var num = rw.getNextInt();
  var week = createArray(num);
  for (var i = 0; i < num; i++) {
    for (var j = 0; j < 5; j++) {
      week[i].push(rw.getNextInt());
    }
  }
  for (var i = 0; i < 5; i++) {
    for (var j = i + 1; j < 5; j++) {
      var a = 0;
      var b = 0;
      var c = 0;
      for (var k = 0; k < num; k++) {
        if (week[k][i] === 1 && week[k][j] === 1) {
          c += 1;
        }
        a += week[k][i];
        b += week[k][j];
      }
      a -= c;
      b -= c;
      if (a < num / 2 && c > 0) {
        c -= num / 2 - a;
        a = num / 2;
      }
      if (b < num / 2 && c > 0) {
        c -= num / 2 - b;
        b = num / 2;
      }
      if (a >= num / 2 && b >= num / 2) {
        writeLine("YES");
        return;
      }
    }
  }
  writeLine("NO");
};