You are given an array $$$a$$$ consisting of $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$.In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array $$$[2, 1, 4]$$$ you can obtain the following arrays: $$$[3, 4]$$$, $$$[1, 6]$$$ and $$$[2, 5]$$$.Your task is to find the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing this operation an arbitrary (possibly, zero) number of times.You have to answer $$$t$$$ independent queries.

The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of queries. The first line of each query contains one integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each query contains $$$n$$$ integers $$$a_1, a_2, \dots , a_n$$$ ($$$1 \le a_i \le 10^9$$$).

For each query print one integer in a single line — the maximum possible number of elements divisible by $$$3$$$ that are in the array after performing described operation an arbitrary (possibly, zero) number of times.

NoteIn the first query of the example you can apply the following sequence of operations to obtain $$$3$$$ elements divisible by $$$3$$$: $$$[3, 1, 2, 3, 1] \rightarrow [3, 3, 3, 1]$$$.In the second query you can obtain $$$3$$$ elements divisible by $$$3$$$ with the following sequence of operations: $$$[1, 1, 1, 1, 1, 2, 2] \rightarrow [1, 1, 1, 1, 2, 3] \rightarrow [1, 1, 1, 3, 3] \rightarrow [2, 1, 3, 3] \rightarrow [3, 3, 3]$$$.

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  let count1 = 0;
  let count2 = 0;

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
    } else if (rest === 1) {
      count1 += 1;
    } else {
      count2 += 1;
    }
  }

  count += Math.min(count1, count2) + Math.floor(Math.abs(count2 - count1) / 3);

  return count;
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

(function () {
    var read = {
        number: function () {
            return +readline();
        },
        arr: function (divider) {
            return readline().split(divider ? divider : '');
        },
        arrNumber: function (divider) {
            return readline()
                .split(divider ? divider : '')
                .map(item => +item);
        }
    };

    var t = read.number();

    for(var i = 0; i < t; i++) {
        var n = read.number();
        var a = read.arrNumber(' ').filter(i => i % 3);
        var res = n - a.length;
        n = a.length;

        var c2 = 0;
        var c1 = 0;
        for(var j = 0; j < n;j++) {
           if(a[j] % 3 === 1) {
               c1 ++;
           }
           else if(a[j] %3 === 2) {
               c2++;
           }
        }
        res+= Math.min(c1,c2);
        res += Math.floor(Math.abs(c1 - c2) / 3);
        print(res);
    }

}());

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne;

  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo;

  return count + restOne + restTwo + Math.min(...Object.values(rests));
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restCopy = { ...rests };
  let minTogether = Math.min(...Object.values(restCopy));
  const togetherOne = Math.max(restCopy[1] - minTogether * 3, 0);
  const togetherTwo = Math.max(restCopy[2] - minTogether * 3, 0);

  minTogether += togetherOne + togetherTwo;

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;
  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  const minRest = restOne + restTwo + Math.min(...Object.values(rests));

  return count + (minTogether > minRest ? minTogether : minRest);
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;

  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  return count + restOne + restTwo + Math.min(...Object.values(rests));
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const minTogether = Math.min(...Object.values(rests));

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;
  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  const minRest = restOne + restTwo + Math.min(...Object.values(rests));

  return count + (minTogether > minRest ? minTogether : minRest);
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});

/* eslint-disable no-continue */
/* eslint-disable no-param-reassign */
const readline = require('readline').createInterface({
  input: process.stdin,
});

const lines = [];

readline.on('line', (line) => {
  if (lines.length === 0) {
    lines.push(Number(line));
  } else {
    lines.push(line);
  }
});

const proccessLine = (len, arr) => {
  let count = 0;
  const rests = {
    1: 0,
    2: 0,
  };

  for (let i = 0; i < len; i += 1) {
    const v = arr[i];
    const rest = v % 3;
    if (rest === 0) {
      count += 1;
      continue;
    }

    rests[rest] += 1;
  }

  const restCopy = { ...rests };
  let minTogether = Math.min(...Object.values(restCopy));
  const togetherOne = Math.max(Math.floor((restCopy[1] - minTogether * 3) / 3), 0);
  const togetherTwo = Math.max(Math.floor((restCopy[2] - minTogether * 3) / 3), 0);

  minTogether += togetherOne + togetherTwo;

  const restOne = Math.floor(rests[1] / 3);
  rests[1] -= restOne * 3;
  const restTwo = Math.floor(rests[2] / 3);
  rests[2] -= restTwo * 3;

  const minRest = restOne + restTwo + Math.min(...Object.values(rests));

  return count + (minTogether > minRest ? minTogether : minRest);
};

readline.on('close', () => {
  const [_, ...vars] = lines;

  for (let i = 0; i < vars.length; i += 2) {
    const len = Number(vars[i]);
    const numbers = vars[i + 1].split(' ').map(Number);

    console.log(proccessLine(len, numbers));
  }
});


The Olympic Games have just started and Federico is eager to watch the marathon race.There will be $$$n$$$ athletes, numbered from $$$1$$$ to $$$n$$$, competing in the marathon, and all of them have taken part in $$$5$$$ important marathons, numbered from $$$1$$$ to $$$5$$$, in the past. For each $$$1\le i\le n$$$ and $$$1\le j\le 5$$$, Federico remembers that athlete $$$i$$$ ranked $$$r_{i,j}$$$-th in marathon $$$j$$$ (e.g., $$$r_{2,4}=3$$$ means that athlete $$$2$$$ was third in marathon $$$4$$$).Federico considers athlete $$$x$$$ superior to athlete $$$y$$$ if athlete $$$x$$$ ranked better than athlete $$$y$$$ in at least $$$3$$$ past marathons, i.e., $$$r_{x,j}<r_{y,j}$$$ for at least $$$3$$$ distinct values of $$$j$$$.Federico believes that an athlete is likely to get the gold medal at the Olympics if he is superior to all other athletes.Find any athlete who is likely to get the gold medal (that is, an athlete who is superior to all other athletes), or determine that there is no such athlete.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of each test case contains a single integer $$$n$$$ ($$$1\le n\le 50\,000$$$) — the number of athletes. Then $$$n$$$ lines follow, each describing the ranking positions of one athlete. The $$$i$$$-th of these lines contains the $$$5$$$ integers $$$r_{i,1},\,r_{i,2},\,r_{i,3},\,r_{i,4},\, r_{i,5}$$$ ($$$1\le r_{i,j}\le 50\,000$$$) — the ranking positions of athlete $$$i$$$ in the past $$$5$$$ marathons. It is guaranteed that, in each of the $$$5$$$ past marathons, the $$$n$$$ athletes have distinct ranking positions, i.e., for each $$$1\le j\le 5$$$, the $$$n$$$ values $$$r_{1,j},\, r_{2, j},\, \dots,\, r_{n, j}$$$ are distinct. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$50\,000$$$.

For each test case, print a single integer — the number of an athlete who is likely to get the gold medal (that is, an athlete who is superior to all other athletes). If there are no such athletes, print $$$-1$$$. If there is more than such one athlete, print any of them.

NoteExplanation of the first test case: There is only one athlete, therefore he is superior to everyone else (since there is no one else), and thus he is likely to get the gold medal.Explanation of the second test case: There are $$$n=3$$$ athletes.   Athlete $$$1$$$ is superior to athlete $$$2$$$. Indeed athlete $$$1$$$ ranks better than athlete $$$2$$$ in the marathons $$$1$$$, $$$2$$$ and $$$3$$$.  Athlete $$$2$$$ is superior to athlete $$$3$$$. Indeed athlete $$$2$$$ ranks better than athlete $$$3$$$ in the marathons $$$1$$$, $$$2$$$, $$$4$$$ and $$$5$$$.  Athlete $$$3$$$ is superior to athlete $$$1$$$. Indeed athlete $$$3$$$ ranks better than athlete $$$1$$$ in the marathons $$$3$$$, $$$4$$$ and $$$5$$$. Explanation of the third test case: There are $$$n=3$$$ athletes.   Athlete $$$1$$$ is superior to athletes $$$2$$$ and $$$3$$$. Since he is superior to all other athletes, he is likely to get the gold medal.  Athlete $$$2$$$ is superior to athlete $$$3$$$.  Athlete $$$3$$$ is not superior to any other athlete. Explanation of the fourth test case: There are $$$n=6$$$ athletes.   Athlete $$$1$$$ is superior to athletes $$$3$$$, $$$4$$$, $$$6$$$.  Athlete $$$2$$$ is superior to athletes $$$1$$$, $$$4$$$, $$$6$$$.  Athlete $$$3$$$ is superior to athletes $$$2$$$, $$$4$$$, $$$6$$$.  Athlete $$$4$$$ is not superior to any other athlete.  Athlete $$$5$$$ is superior to athletes $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$, $$$6$$$. Since he is superior to all other athletes, he is likely to get the gold medal.  Athlete $$$6$$$ is only superior to athlete $$$4$$$.

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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

function shuffle(array) {
	let currentIndex = array.length,  randomIndex;

	// While there remain elements to shuffle...
	while (currentIndex != 0) {

		// Pick a remaining element...
		randomIndex = Math.floor(Math.random() * currentIndex);
		currentIndex--;

		// And swap it with the current element.
		[array[currentIndex], array[randomIndex]] = [
			array[randomIndex], array[currentIndex]];
	}

	return array;
}

const M = 5;

function main () {
	let T = rn();
	while (T--) {
		const n = rn();

		const r = [];
		for (let i = 0; i < n; i++) r[i] = rna();

		const ord = [];
		for (let i = 0; i < n; i++) ord[i] = i;

		shuffle(ord);
		let w = -1;
		for (let i = 0; i < n; i++) {
			let works = 1;
			for (let j = 0; j < n && works; j++) {
				let cnt = 0;
				for (let k = 0; k < M; k++) cnt += r[ord[i]][k] <= r[ord[j]][k];
				if (cnt < 3) works = 0;
			}
			if (works) { w = ord[i] + 1; break; }
		}

		console.log(w);
	}
}

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

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

var deb; const log = msg => (typeof deb != "undefined") && console.log("DEBUG", msg);

function main () {
	let T = rn();
	while (T--) {
		const n = rn();

		const r = [];
		for (let i = 0; i < n; i++) {
			r[i] = rna();
		}

		let w = 0;
		for (let i = 0; i < n; i++) {
			let cnt = 0;
			for (let j = 0; j < 5; j++) cnt += r[w][j] <= r[i][j];
			if (cnt < 3) w = i;
		}

		let ok = 1;
		for (let i = 0; i < n; i++) {
			let cnt = 0;
			for (let j = 0; j < 5; j++) cnt += r[w][j] <= r[i][j];
			if (cnt < 3) ok = 0;
		}

		console.log(ok ? w + 1 : -1);
	}
}


For god's sake, you're boxes with legs! It is literally your only purpose! Walking onto buttons! How can you not do the one thing you were designed for?Oh, that's funny, is it? Oh it's funny? Because we've been at this for twelve hours and you haven't solved it either, so I don't know why you're laughing. You've got one hour! Solve it!  Wheatley decided to try to make a test chamber. He made a nice test chamber, but there was only one detail absent — cubes.For completing the chamber Wheatley needs $$$n$$$ cubes. $$$i$$$-th cube has a volume $$$a_i$$$.Wheatley has to place cubes in such a way that they would be sorted in a non-decreasing order by their volume. Formally, for each $$$i>1$$$, $$$a_{i-1} \le a_i$$$ must hold.To achieve his goal, Wheatley can exchange two neighbouring cubes. It means that for any $$$i>1$$$ you can exchange cubes on positions $$$i-1$$$ and $$$i$$$.But there is a problem: Wheatley is very impatient. If Wheatley needs more than $$$\frac{n \cdot (n-1)}{2}-1$$$ exchange operations, he won't do this boring work.Wheatly wants to know: can cubes be sorted under this conditions?

Each test contains multiple test cases. The first line contains one positive integer $$$t$$$ ($$$1 \le t \le 1000$$$), denoting the number of test cases. Description of the test cases follows. The first line of each test case contains one positive integer $$$n$$$ ($$$2 \le n \le 5 \cdot 10^4$$$) — number of cubes. The second line contains $$$n$$$ positive integers $$$a_i$$$ ($$$1 \le a_i \le 10^9$$$) — volumes of cubes. It is guaranteed that the sum of $$$n$$$ over all test cases does not exceed $$$10^5$$$.

For each test case, print a word in a single line: "YES" (without quotation marks) if the cubes can be sorted and "NO" (without quotation marks) otherwise.

NoteIn the first test case it is possible to sort all the cubes in $$$7$$$ exchanges.In the second test case the cubes are already sorted.In the third test case we can make $$$0$$$ exchanges, but the cubes are not sorted yet, so the answer is "NO".

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 main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    let arr = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    let ok = false;

    for (let i = 0; i < len - 1; i++) {
      if (arr[i] <= arr[i + 1]) {
        console.log("YES");
        ok = true;
        break;
      }
    }

    if (!ok) console.log("NO");
  }
}

//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
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';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//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 output = new Array(t);
  for(var i = 0; i < t; i++){
    var N = nextInt();
    var list = nextIntArray();
    var isOK = false;
    for(var j = 0; j < N - 1; j++){
      if(list[j] <= list[j + 1]){
        isOK = true;
      }
    }
    output[i] = (isOK) ? "YES" : "NO";
  }
  myout(myconv(output, 9));
}

let input = '';
let inputResolve;
let inputPromise = new Promise(resolve => inputResolve = resolve);
process.stdin.on('data', c => input += c);
process.stdin.on('end', () => inputResolve());

function For(a, b, fn) {
  let res;
  if (a < b) {
    for (let i = a; i <= b; i++) {
      if ((res = fn(i)) !== undefined) return res;
    }
  } else {
    for (let i = a; i >= b; i--) {
      if ((res = fn(i)) !== undefined) return res;
    }
  }
}

function Arr(a, b, fn, prev) {
  let p = prev || 0;
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => fn ? (p = fn(a + i, p)) : a + i);
  return Array(a - b + 1).fill(0).map((v, i) => fn ? (p = fn(a - i, p)) : a - i);
}

Object.defineProperty(Object.prototype, '$k', {
  value: function () { return Object.keys(this) }
});
Object.defineProperty(Object.prototype, '$v', {
  value: function () { return Object.values(this) }
});
Object.defineProperty(Object.prototype, '$kv', {
  value: function () { return Object.entries(this) }
});
Array.prototype.sum = function (fn) { return this.reduce((p, v) => p + (fn ? fn(v) : v), 0) }
Array.prototype.uniq = function (fn) {
  var set = new Set();
  return this.filter(v => {
    var newValue = !set.has(fn ? fn(v) : v);
    set.add(fn ? fn(v) : v);
    return newValue;
  });
}
Array.prototype.toObj = function (fn) {
  return this.map(v => fn(v)).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = Math.min(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == min : v == min);
  return [this[i], i, min];
}
Array.prototype.max = function (fn) {
  let max = Math.max(...this.map((v, i) => fn ? fn(v, i) : v));
  let i = this.findIndex((v, i) => fn ? fn(v, i) == max : v == max);
  return [this[i], i, max];
}

function gcd(a, b) {
  if (!b) return a;
  return gcd(b, a % b);
}
function mod(a, n, m) {
  if (n == 0n) return 1n;
  if (n % 2n == 0n) return mod(a * a % m, n / 2n, m);
  return a * mod(a, n - 1n, m) % m;
}
function extendedEuclid(a, b) {
  if (!b) return [1, 0];
  else {
    let [x, y] = extendedEuclid(b, a % b);
    return [y, x - (a / b | 0) * y];
  }
}
// [m] = extendedEuclid(a, 998244353);

(async () => {
  await inputPromise;
  let inp = input.split(/\s+/).map(v => +v); r = 0;
  let t = inp[r++];
  while (t--) {
    let n = inp[r++];
    let a = inp.slice(r, r = r + n);
    console.log(For(0, n - 2, i => a[i] <= a[i + 1] ? 1 : undefined) ? 'YES' : 'NO')
  }
})();

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var list = readline().split(" ").map(Number);
    var ok = true;
    for(var i=0;i<n-1;i++){
      if(list[i]<=list[i+1]){
        ok = false;
      }
    }
    if(ok==true){
        print("NO");
    }else print("YES");
}

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

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

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

    const str = arr.join("");
    arr.sort((a, b) => b - a);

    const str2 = arr.join("");

    if (str === str2 && arr[0] !== arr[len - 1]) console.log("NO");
    else console.log("YES");
  }
}

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var input = readline();
    var arr = input.split(' ').map(Number);
    var ok = true;
    if(ok==true){
        print("NO\n");
    }else print("YES\n");
}

var t = parseInt(readline());
while(t--){
    var n = parseInt(readline());
    var list = readline().split(" ").map(Number);
    for(var i=0;i<n-1;i++){
      if(list[i]<=list[i+1]){
        ok = false;
      }
    }
    var ok = true;
    if(ok==true){
        print("NO");
    }else print("YES");
}


Let $$$n$$$ be a positive integer. Let $$$a, b, c$$$ be nonnegative integers such that $$$a + b + c = n$$$.Alice and Bob are gonna play rock-paper-scissors $$$n$$$ times. Alice knows the sequences of hands that Bob will play. However, Alice has to play rock $$$a$$$ times, paper $$$b$$$ times, and scissors $$$c$$$ times.Alice wins if she beats Bob in at least $$$\lceil \frac{n}{2} \rceil$$$ ($$$\frac{n}{2}$$$ rounded up to the nearest integer) hands, otherwise Alice loses.Note that in rock-paper-scissors:  rock beats scissors;  paper beats rock;  scissors beat paper. The task is, given the sequence of hands that Bob will play, and the numbers $$$a, b, c$$$, determine whether or not Alice can win. And if so, find any possible sequence of hands that Alice can use to win.If there are multiple answers, print any of them.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then, $$$t$$$ testcases follow, each consisting of three lines:    The first line contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$).  The second line contains three integers, $$$a, b, c$$$ ($$$0 \le a, b, c \le n$$$). It is guaranteed that $$$a + b + c = n$$$.  The third line contains a string $$$s$$$ of length $$$n$$$. $$$s$$$ is made up of only 'R', 'P', and 'S'. The $$$i$$$-th character is 'R' if for his $$$i$$$-th Bob plays rock, 'P' if paper, and 'S' if scissors.

For each testcase:    If Alice cannot win, print "NO" (without the quotes).  Otherwise, print "YES" (without the quotes). Also, print a string $$$t$$$ of length $$$n$$$ made up of only 'R', 'P', and 'S' — a sequence of hands that Alice can use to win. $$$t$$$ must contain exactly $$$a$$$ 'R's, $$$b$$$ 'P's, and $$$c$$$ 'S's.  If there are multiple answers, print any of them.  The "YES" / "NO" part of the output is case-insensitive (i.e. "yEs", "no" or "YEs" are all valid answers). Note that 'R', 'P' and 'S' are case-sensitive.

NoteIn the first testcase, in the first hand, Alice plays paper and Bob plays rock, so Alice beats Bob. In the second hand, Alice plays scissors and Bob plays paper, so Alice beats Bob. In the third hand, Alice plays rock and Bob plays scissors, so Alice beats Bob. Alice beat Bob 3 times, and $$$3 \ge \lceil \frac{3}{2} \rceil = 2$$$, so Alice wins.In the second testcase, the only sequence of hands that Alice can play is "RRR". Alice beats Bob only in the last hand, so Alice can't win. $$$1 < \lceil \frac{3}{2} \rceil = 2$$$.

  var sets = parseInt(readline(), 10);

  function getMinValue(a, b) {
    return a < b ? a : b;
  }

  for (var i = 0; i < sets; i++) {
    var rounds = parseInt(readline(), 10);

    var neededWins = Math.ceil(rounds / 2);

    var AliceActionCounts = readline()
      .split(" ")
      .map(function(val) {
        return parseInt(val);
      });

    var AliceActions = {
      R: AliceActionCounts[0],
      P: AliceActionCounts[1],
      S: AliceActionCounts[2]
    };

    var BobActionsString = readline();
    var BobActions = BobActionsString.split("").reduce(
      function(result, action) {
        result[action]++;
        return result;
      },
      { R: 0, P: 0, S: 0 }
    );

    var AliceWins =
      getMinValue(AliceActions.P, BobActions.R) +
      getMinValue(AliceActions.R, BobActions.S) +
      getMinValue(AliceActions.S, BobActions.P);

    if (AliceWins < neededWins) print("NO");
    else {
      print("YES");
      var resultString = "";

      var freeActions = [];

      if (AliceActions.P > BobActions.R) {
        for (var j = 0; j < AliceActions.P - BobActions.R; j++) {
          freeActions.push("P");
        }
      }

      if (AliceActions.R > BobActions.S) {
        for (var j = 0; j < AliceActions.R - BobActions.S; j++) {
          freeActions.push("R");
        }
      }

      if (AliceActions.S > BobActions.P) {
        for (var j = 0; j < AliceActions.S - BobActions.P; j++) {
          freeActions.push("S");
        }
      }

      for (var j = 0; j < rounds; j++) {
        switch (BobActionsString[j]) {
          case "R":
            if (AliceActions.P) {
              resultString += "P";
              AliceActions.P--;
            } else {
              resultString += freeActions.pop();
            }
            break;
          case "P":
            if (AliceActions.S) {
              resultString += "S";
              AliceActions.S--;
            } else {
              resultString += freeActions.pop();
            }
            break;
          case "S":
            if (AliceActions.R) {
              resultString += "R";
              AliceActions.R--;
            } else {
              resultString += freeActions.pop();
            }
            break;
        }
      }
      print(resultString);
    }
  }


Alice and Bob are playing a game on an array $$$a$$$ of $$$n$$$ positive integers. Alice and Bob make alternating moves with Alice going first.In his/her turn, the player makes the following move: If $$$a_1 = 0$$$, the player loses the game, otherwise: Player chooses some $$$i$$$ with $$$2\le i \le n$$$. Then player decreases the value of $$$a_1$$$ by $$$1$$$ and swaps $$$a_1$$$ with $$$a_i$$$. Determine the winner of the game if both players play optimally.

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ $$$(1 \leq t \leq 2 \cdot 10^4)$$$  — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ $$$(2 \leq n \leq 10^5)$$$  — the length of the array $$$a$$$. The second line of each test case contains $$$n$$$ integers $$$a_1,a_2 \ldots a_n$$$ $$$(1 \leq a_i \leq 10^9)$$$  — the elements of the array $$$a$$$. It is guaranteed that sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, if Alice will win the game, output "Alice". Otherwise, output "Bob". You can output each letter in any case. For example, "alIcE", "Alice", "alice" will all be considered identical.

NoteIn the first testcase, in her turn, Alice can only choose $$$i = 2$$$, making the array equal $$$[1, 0]$$$. Then Bob, in his turn, will also choose $$$i = 2$$$ and make the array equal $$$[0, 0]$$$. As $$$a_1 = 0$$$, Alice loses.In the second testcase, once again, players can only choose $$$i = 2$$$. Then the array will change as follows: $$$[2, 1] \to [1, 1] \to [1, 0] \to [0, 0]$$$, and Bob loses.In the third testcase, we can show that Alice has a winning strategy.

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) ? 'Alice' : 'Bob'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const min = Math.min(...arr)
    if (arr[0] === min) {
        return false
    } else {
        return true
    }
}

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 f = a[0];
            a.sort(function(a, b){return a - b});
            console.log(a[0] == f ? 'Bob' : 'Alice');
        }
    }
});

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

var T = readline();
var inf = 1000000000000;
for(var tc=1;tc<=T;tc++) {
	var n = readline();
	var a = readline().split(" ").map(w => parseInt(w));
	var minn = inf;
	for(var i=0;i<n;i++) minn = min(minn, a[i])
	if(minn !== a[0]) console.log("Alice");
	else console.log("Bob")
}

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

// const { readline, print, testOutput } = require('@ip-algorithmics/codeforces-io');
// main();
// testOutput();

function begin(n, nums) {
    let min = Number.MAX_SAFE_INTEGER;
    let minIndex = 0;
    for(let i = 0; i < nums.length; i++) {
        if(min > nums[i]) {
            min = nums[i];
            minIndex = i;
        }
    }
    if(minIndex > 0) {
        print("Alice");
    } else {
        print("Bob");
    }
}

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

'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(),
        a = rns();
  if (a[0] === 1) return 'Bob';
  for (let i = 1; i < n; i++) {
    if (a[i] < a[0]) return 'Alice';
  }
  return 'Bob';
}
function convertInput(read) {
  const rn = () => Number(read());
  const rb = () => BigInt(read());
  const rns = () => read().split(/\s+/).map(Number);
  const re = () => read().split(/\s+/).map(s => Number(s) - 1);
  const rbs = () => read().split(/\s+/).map(BigInt);
  return [rn, rb, rns, re, rbs];
}
function main(r) {
  try {
    let t = Number(r());
    let res = new Array(t);
    let limit = 0;
    for (let i = 0; i < t; i++) {
      let s = solve(r);
      if (s === undefined) s = '';
      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(/\r?\n/);
void function () {
  const read = ((i = 0) => () => inputs[i++])();
  const output = main(read);
  process.stdout.write(output);
}();

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

// your code goes here

// declare global variables
var input_stdin = "";
var lines = "";
var input_currentline = 0;

// standard input is stored into input_stdin
process.stdin.on('data', function (data) {
    input_stdin += data;
});

// standard input is done and stored into an array
process.stdin.on('end', function () {
    lines = input_stdin.split("\n");
    start();
});

function start() {
    const T = parseInt(lines[0])
    let line = 1
    for (let t = 1; t <= T; t++) {
        const n = parseInt(lines[line++].split(' ')[0], 10)
        const a = lines[line++].split(' ').map(x => parseInt(x, 10))
        let min = a[1];
        for(let i = 1; i < a.length; i++) {
            if (min > a[i])
                min = a[i]
        }
        if (a[0] > min) console.log('Alice')
        else console.log('Bob')
    }
}

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) ? 'Alice' : 'Bob'
    }
    console.log(output.join('\n'))
// })()
})

function solve(n, arr) {
    const min = Math.min(...arr)
    if (min === 1) {
        return arr[0] !== 1
    }
    const sum = arr.reduce((s, x) => s + x, 0)
    return (sum - 2 * n) & 1
}


The country of Byalechinsk is running elections involving n candidates. The country consists of m cities. We know how many people in each city voted for each candidate.The electoral system in the country is pretty unusual. At the first stage of elections the votes are counted for each city: it is assumed that in each city won the candidate who got the highest number of votes in this city, and if several candidates got the maximum number of votes, then the winner is the one with a smaller index.At the second stage of elections the winner is determined by the same principle over the cities: the winner of the elections is the candidate who won in the maximum number of cities, and among those who got the maximum number of cities the winner is the one with a smaller index.Determine who will win the elections.

The first line of the input contains two integers n, m (1 ≤ n, m ≤ 100) — the number of candidates and of cities, respectively. Each of the next m lines contains n non-negative integers, the j-th number in the i-th line aij (1 ≤ j ≤ n, 1 ≤ i ≤ m, 0 ≤ aij ≤ 109) denotes the number of votes for candidate j in city i. It is guaranteed that the total number of people in all the cities does not exceed 109.

Print a single number — the index of the candidate who won the elections. The candidates are indexed starting from one.

NoteNote to the first sample test. At the first stage city 1 chosen candidate 3, city 2 chosen candidate 2, city 3 chosen candidate 2. The winner is candidate 2, he gained 2 votes.Note to the second sample test. At the first stage in city 1 candidates 1 and 2 got the same maximum number of votes, but candidate 1 has a smaller index, so the city chose candidate 1. City 2 chosen candidate 3. City 3 chosen candidate 1, due to the fact that everyone has the same number of votes, and 1 has the smallest index. City 4 chosen the candidate 3. On the second stage the same number of cities chose candidates 1 and 3. The winner is candidate 1, the one with the smaller index.

var input = readline().split(" "), n = +input[0], m = +input[1], a = [], win1 = [], store = {}, winners = [];
for(i = 0; i < m; i++){
	a.push(readline().split(" "));
}

a.forEach(function(v){
	var sorted = v.concat().sort(function(x,y){return y-x});
	var canNumber = v.indexOf(sorted[0]);
	win1.push(canNumber);
});

for (var i = 0; i < win1.length; i++) {
  var key = win1[i];
  store[key] = key;
}

for(i = 0; i < n; i++){
	winners[i] = 0;
}

for(key in store){
	for(i = 0; i < m; i++){
		if(win1[i] == key){
			winners[key]++;
		}
	}
}

winnerss = winners.concat().sort(function(x,y){return y-x});

write(winners.indexOf(winnerss[0]) + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let n = _in[0], m = _in[1];
let a = [];
for (let i = 0; i < m; i++) {
    a.push(readline().split(/\s+/).map((s) => parseInt(s, 10)));
}
let f = (acc, _, i, v) => (v[acc] < v[i]) ? i : acc;
a = a.map((v) => v.reduce(f, 0));
let ct = new Array(n).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

var data = readline().split(' ');
var candidates = parseInt(data[0]);
var cities = parseInt(data[1]);
var result_cities = [];

for (var i = 0; i < cities; i++) {
    var data = readline().split(' ');
    var result = 0;
    for (var x = 0; x < candidates; x++) {
        var temp_result = parseInt(data[x]+1);
        if(result<temp_result) { //если текущий кандидат набрал больше предыдущего
            result = parseInt(data[x]+1); //то его результат пишем
            result_cities[i] = x+1;//и запоминаем номер кандидата

        }
    }
}

//на выхоже массив с результатами голосования по городам
var candidate_list = [candidates];
for (var i = 0; i < candidates; i++) {
    candidate_list[i] = 0;
    for (var x = 0; x < cities; x++) {
        if((i+1) == result_cities[x]) {
            candidate_list[i]++;
        }
    }
    //print(candidate_list[i]);
}

result = 1;

//находим победителя
for (var i = 1; i < candidates; i++) {
    if(candidate_list[i] > candidate_list[result-1]) {
        result = i+1;
    }
}

write(result);

(function() {
    "use strict";
    var arr = readline().split(" ").map(function(x) {
        return parseInt(x);
    });
    var can = arr[0], cit = arr[1], mat = [];
    var canind = [], maxvotes = [];
    for(var i = 0; i < cit; i++)
    {
        mat[i] = readline().split(" ").map(function(x) {
           return parseInt(x);
        });

        maxvotes[i] = mat[i][0];
        canind[i] = 0;
        for(var j = 0; j < can; j++)
        {
            if(mat[i][j] > maxvotes[i])
            {
                maxvotes[i] = mat[i][j];
                canind[i] = j;
            }
        }
    }

    var Tarek = [];
    for(var i = 0; i < can; i++)
    {
        Tarek[i] = 0;
    }

    for(var i = 0; i < cit; i++)
    {
        Tarek[canind[i]]++;
    }

    var fin_max = 0, fin_ind = 0;
    for(var i = 0; i < Tarek.length; i++)
    {
        if(Tarek[i] > fin_max)
        {
            fin_max = Tarek[i];
            fin_ind = i;
        }
    }

    print(fin_ind + 1);
})();

var arr = [];
var numberCitiesCandidates = readline();
numberCitiesCandidates = numberCitiesCandidates.split(' ');
var cities = numberCitiesCandidates[1];
var candidates = numberCitiesCandidates[0];

for (var i = 0; i < cities; i++) {
    var line = readline();
    if (!line) {
        break;
    }
    var lineChars = line.split(' ');
    for (var j = 0; j < candidates; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}

var filteration = [];
for (var i = 0; i < arr.length; i++) {
    var maxCanditate = {
        index: 0,
        value: Number(arr[i][0])
    };
    for (var j = 1; j < arr[i].length; j++) {
        var currVotes = Number(arr[i][j]);
        if (maxCanditate.value < currVotes) {
            maxCanditate = {
                index: j,
                value: arr[i][j]
            };
        }
    }

    filteration.push(maxCanditate);
}
var citiesStatistics = {};
filteration.map(function(a) {
    if (a.index in citiesStatistics) {
        citiesStatistics[a.index]++;
    } else {
        citiesStatistics[a.index] = 1;
    }
});
var winner;
for (var canditateIndex in citiesStatistics) {
    var canditateIndexNum = Number(canditateIndex);
    if (!winner) {
        winner = {
            index: canditateIndexNum,
            cities: citiesStatistics[canditateIndex]
        };
    } else {
        if ((winner.cities < citiesStatistics[canditateIndex]) || (winner.cities == citiesStatistics[canditateIndex] && winner.index > canditateIndexNum)) {
            winner = {
                index: canditateIndexNum,
                cities: citiesStatistics[canditateIndex]
            };
        }
    }
}

print(winner.index + 1);

var firstInput = readline().split(' ');
var nCandidates = parseInt(firstInput[0]);
var nCities = parseInt(firstInput[1]);
var citiesWonByCandidates = [];
var i, j, highestVotePerCity, currentVote, winnerPerCityIdx, votesPerCity;
for (i = 0; i < nCities; i++) {
	votesPerCity = readline().split(' ');
	highestVotePerCity = -1;
	for (j = 0; j < nCandidates; j++) {
		currentVote = parseInt(votesPerCity[j]);
		if (currentVote > highestVotePerCity) {
			winnerPerCityIdx = j;
			highestVotePerCity = currentVote;
		}
	}
	if (citiesWonByCandidates[winnerPerCityIdx] == null) {
		citiesWonByCandidates[winnerPerCityIdx] = 1;
	} else {
		citiesWonByCandidates[winnerPerCityIdx] += 1;
	}
}
var highestVote = -1, winner = 1;
for (i = 0; i < citiesWonByCandidates.length; i++) {
	if (citiesWonByCandidates[i] > highestVote) {
		winner = i+1;
		highestVote = citiesWonByCandidates[i];
	}
}
print(winner);

nm = readline().split(' ').map(Number);

var n = nm[0];
var m = nm[1];

var arr = [];

for (var i = 0; i < m; i++) {
	str = readline().split(' ').map(Number);

	var max = 0;
	var maxPos = 0;

	for (var j = 0; j < n; j++) {
		if (str[j] > max) {
			max = str[j];
			maxPos = j;
		};
	};

	arr.push(maxPos + 1);
};

for (var j = 0; j < m - 1; j++) {
	for (var k = j + 1; k < m; k++) {
		if (arr[j] > arr[k]) {
			var temp = arr[j];
			arr[j] = arr[k];
			arr[k] = temp;
		};
	};
};

var maxCount = 0;
var res = 0;

for (var k = 0; k < m; k++) {
	var count = 0;

	for (var l = 0; l < m; l++) {
		if (arr[k] == arr[l]) {
			count++;
		};
	};

	if (count > maxCount) {
		maxCount = count;
		res = arr[k];
	};
};

print(res);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let n = _in[0], m = _in[1];
let a = [];
for (let i = 0; i < n; i++) {
    a.push(readline().split().map(parseInt));
}
let f = (acc, _, i, v) => v[acc] < v[i] ? i : acc;
a.map((v) => v.reduce(f, 0));
let ct = new Array(m).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let m = _in[0], n = _in[1];
let a = [];
for (let i = 0; i < n; i++) {
    a.push(readline().split().map(parseInt));
}
let f = (acc, _, i, v) => v[acc] < v[i] ? i : acc;
a.map((v) => v.reduce(f, 0));
let ct = new Array(m).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

'use strict';
let _in = readline().split(/\s+/).map((s) => parseInt(s, 10));
let n = _in[0], m = _in[1];
let a = [];
for (let i = 0; i < m; i++) {
    a.push(readline().split(/\s+/).map((s) => parseInt(s, 10)));
}
let f = (acc, _, i, v) => (v[acc] < v[i]) ? i : acc;
a = a.map((v) => v.reduce(f, 0));
let ct = new Array(m).fill(0);
for (let i = 0; i < m; i++) {
    ct[a[i]]++;
}
print(ct.reduce(f, 0) + 1);

var data = readline().split(' ');
var candidates = parseInt(data[0]);
var cities = parseInt(data[1]);
var result_cities = [];

for (var i = 0; i < cities; i++) {
    var data = readline().split(' ');
    var result = 0;
    for (var x = 0; x < candidates; x++) {
        var temp_result = parseInt(data[x]);
        if(result<temp_result) { //если текущий кандидат набрал больше предыдущего
            result = parseInt(data[x]); //то его результат пишем
            result_cities[i] = x+1;//и запоминаем номер кандидата

        }
    }
}

//на выхоже массив с результатами голосования по городам
var candidate_list = [candidates];
for (var i = 0; i < candidates; i++) {
    candidate_list[i] = 0;
    for (var x = 0; x < cities; x++) {
        if((i+1) == result_cities[x]) {
            candidate_list[i]++;
        }
    }
    print(candidate_list[i]);
}

result = 1;

//находим победителя
for (var i = 1; i < candidates; i++) {
    if(candidate_list[i] > candidate_list[result-1]) {
        result = i+1;
    }
}

write(result);

var data = readline().split(' ');
var candidates = parseInt(data[0]);
var cities = parseInt(data[1]);
var result_cities = [];

for (var i = 0; i < cities; i++) {
    var data = readline().split(' ');
    var result = 0;
    for (var x = 0; x < candidates; x++) {
        var temp_result = parseInt(data[x]);
        if(result<temp_result) { //если текущий кандидат набрал больше предыдущего
            result = parseInt(data[x]); //то его результат пишем
            result_cities[i] = x+1;//и запоминаем номер кандидата
        }
    }
}

//на выхоже массив с результатами голосования по городам
var candidate_list = [candidates];
for (var i = 0; i < candidates; i++) {
    candidate_list[i] = 0;
    for (var x = 0; x < cities; x++) {
        if((i+1) == result_cities[x]) {
            candidate_list[i]++;
        }
    }
}

result = 1;

//находим победителя
for (var i = 1; i < candidates; i++) {
    if(candidate_list[i] > candidate_list[result-1]) {
        result = i+1;
    }
}

write(result);

(function () {
    "use strict";
    var arr = readline().split(" ").map(function (x) {
        return parseInt(x, 10);
    }), can = arr[0], cit = arr[1], mat = [], maxi = [], index = [];
    for (var i = 0; i < cit; i++) {
        mat[i] = readline().split(" ").map(function(z) {
            return parseInt(z);
        });
        maxi[i] = 0;
        index[i] = null;
        for(var j = can - 1; j >= 0; j--) {
            if(mat[i][j] >= maxi[i]) {
                maxi[i] = mat[i][j];
                index[i] = j;
            }
        }
    }

    var maxcan = [];

    for(i = 0; i < cit; i++) {
        maxcan[i] = 0;
    }

    for(i = 0; i < cit; i++) {
        maxcan[index[i]]++;
    }

    var maxnum = maxcan[0], maxindex = 0;
    for(i = can - 1; i >= 0; i--) {
        if(maxcan[i] >= maxnum) {
            maxnum = maxcan[i];
            maxindex = i;
        }
    }

    print(maxindex+1);

})();

(function () {
    "use strict";
    var arr = readline().split(" ").map(function (x) {
        return parseInt(x, 10);
    }), can = arr[0], cit = arr[1], mat = [],
        maxi = [], index = [], maxcan = [],
        maxnum = maxcan[0], maxindex = 0;
    for (var i = 0; i < cit; i++) {
        mat[i] = readline().split(" ").map(function(z) {
            return parseInt(z);
        });
        maxi[i] = 0;
        index[i] = null;
        for(var j = can - 1; j >= 0; j--) {
            if(mat[i][j] >= maxi[i]) {
                maxi[i] = mat[i][j];
                index[i] = j;
            }
        }
    }
    for(i = 0; i < cit; i++) {
        maxcan[i] = 0;
    }
    for(i = 0; i < cit; i++) {
        maxcan[index[i]]++;
    }
    for(i = cit - 1; i >= 0; i--) {
        if(maxcan[i] >= maxnum) {
            maxnum = maxcan[i];
            maxindex = i;
        }
    }
    print(maxindex+1);
})();

var arr = [];
var numberCitiesCandidates = readline();
numberCitiesCandidates = numberCitiesCandidates.split(' ');
var cities = numberCitiesCandidates[1];
var candidates = numberCitiesCandidates[0];

for (var i = 0; i < cities; i++) {
    var line = readline();
    if (!line) {
        break;
    }
    var lineChars = line.split(' ');
    for (var j = 0; j < candidates; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}

var filteration = [];
for (var i = 0; i < arr.length; i++) {
    var maxCanditate = {
        index: 0,
        value: Number(arr[i][0])
    };
    for (var j = 1; j < arr[i].length; j++) {
    	var currVotes = Number(arr[i][j]);
        if (maxCanditate.value < currVotes) {
            maxCanditate = {
                index: j,
                value: arr[i][j]
            };
        }
    }
    if(filteration.length === 0 || (filteration.length !== 0 && maxCanditate.value !== 0))
    	filteration.push(maxCanditate);
}
var citiesStatistics = {};
filteration.map(function(a) {
    if (a.index in citiesStatistics) {
        citiesStatistics[a.index]++;
    } else {
        citiesStatistics[a.index] = 1;
    }
});
var winner;
for(var canditateIndex in citiesStatistics){
	var canditateIndexNum = Number(canditateIndex);
	if(!winner){
		winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
	}else{
		if((winner.cities < citiesStatistics[canditateIndex]) || (winner.cities == citiesStatistics[canditateIndex] && winner.index > canditateIndexNum)){
			winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
		}
	}
}

print(winner.index + 1);

var arr = [];
var input = readline();
print(input);
var lines = input.split("\n");
for (var i = 0; i < lines.length; i++) {
    var line = lines[i];
    var lineChars = line.split(' ');
    for (var j = 0; j < lineChars.length; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}

var arr = [];
for (var i = 0; i < 100; i++) {
    var line = readline();
    if (!line) {
        break;
    }
    var lineChars = line.split(' ');
    for (var j = 0; j < lineChars.length; j++) {
        if (!arr[i]) {
            arr[i] = [];
        }
        arr[i][j] = lineChars[j];
    }
}
var filteration = [];
for (var i = 0; i < arr.length; i++) {
    var maxCanditate = {
        index: 0,
        value: Number(arr[i][0])
    };
    for (var j = 1; j < arr[i].length; j++) {
        if (maxCanditate.value < Number(arr[i][j])) {
            maxCanditate = {
                index: j,
                value: arr[i][j]
            };
        }
    }
    filteration.push(maxCanditate);
}
var citiesStatistics = {};
filteration.map(function(a) {
    if (a.index in citiesStatistics) {
        citiesStatistics[a.index]++;
    } else {
        citiesStatistics[a.index] = 1;
    }
});
var winner;
for(var canditateIndex in citiesStatistics){
	var canditateIndexNum = Number(canditateIndex);
	if(!winner){
		winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
	}else{
		if((winner.cities < citiesStatistics[canditateIndex]) || (winner.cities == citiesStatistics[canditateIndex] && winner.index > canditateIndexNum)){
			winner = {index: canditateIndexNum, cities: citiesStatistics[canditateIndex]};
		}
	}
}

print(winner.index + 1);

var firstInput = readline().split(' ');
var nCandidates = parseInt(firstInput[0]);
var nCities = parseInt(firstInput[1]);
var citiesWonByCandidates = [];
var i, j, highestVotePerCity, currentVote, winnerPerCityIdx, votesPerCity;
for (i = 0; i < nCities; i++) {
    votesPerCity = readline().split(' ');
    highestVotePerCity = 0;
    for (j = 0; j < nCandidates; j++) {
        currentVote = parseInt(votesPerCity[j]);
        if (currentVote > highestVotePerCity) {
            winnerPerCityIdx = j;
            highestVotePerCity = currentVote;
        }
    }
    if (citiesWonByCandidates[winnerPerCityIdx] == null) {
        citiesWonByCandidates[winnerPerCityIdx] = 1;
    } else {
        citiesWonByCandidates[winnerPerCityIdx] += 1;
    }
}
var highestVote = 0, winner = 1;
for (i = 0; i < citiesWonByCandidates.length; i++) {
    if (citiesWonByCandidates[i] > highestVote) {
        winner = i+1;
        highestVote = citiesWonByCandidates[i];
    }
}
print(winner);

var firstInput = readline().split(' ');
var nCandidates = parseInt(firstInput[0]);
var nCities = parseInt(firstInput[1]);
var citiesWonByCandidates = [];
var i, j, highestVotePerCity, currentVote, winnerPerCityIdx, votesPerCity;
for (i = 0; i < nCities; i++) {
	votesPerCity = readline().split(' ');
	highestVotePerCity = 0;
	for (j = 0; j < nCandidates; j++) {
		currentVote = parseInt(votesPerCity[j]);
		if (currentVote > highestVotePerCity) {
			winnerPerCityIdx = j;
			highestVotePerCity = currentVote;
		}
	}
	if (citiesWonByCandidates[winnerPerCityIdx] == null) {
		citiesWonByCandidates[winnerPerCityIdx] = 1;
	} else {
		citiesWonByCandidates[winnerPerCityIdx] += 1;
	}
}
var highestVote = 0, winner;
for (i = 0; i < citiesWonByCandidates.length; i++) {
	if (citiesWonByCandidates[i] > highestVote) {
		winner = i+1;
		highestVote = citiesWonByCandidates[i];
	}
}
print(winner);


When registering in a social network, users are allowed to create their own convenient login to make it easier to share contacts, print it on business cards, etc.Login is an arbitrary sequence of lower and uppercase latin letters, digits and underline symbols («_»). However, in order to decrease the number of frauds and user-inattention related issues, it is prohibited to register a login if it is similar with an already existing login. More precisely, two logins s and t are considered similar if we can transform s to t via a sequence of operations of the following types:   transform lowercase letters to uppercase and vice versa;  change letter «O» (uppercase latin letter) to digit «0» and vice versa;  change digit «1» (one) to any letter among «l» (lowercase latin «L»), «I» (uppercase latin «i») and vice versa, or change one of these letters to other. For example, logins «Codeforces» and «codef0rces» as well as «OO0OOO00O0OOO0O00OOO0OO_lol» and «OO0OOO0O00OOO0O00OO0OOO_1oI» are considered similar whereas «Codeforces» and «Code_forces» are not.You're given a list of existing logins with no two similar amonst and a newly created user login. Check whether this new login is similar with any of the existing ones.

The first line contains a non-empty string s consisting of lower and uppercase latin letters, digits and underline symbols («_») with length not exceeding 50  — the login itself. The second line contains a single integer n (1 ≤ n ≤ 1 000) — the number of existing logins. The next n lines describe the existing logins, following the same constraints as the user login (refer to the first line of the input). It's guaranteed that no two existing logins are similar.

Print «Yes» (without quotes), if user can register via this login, i.e. none of the existing logins is similar with it. Otherwise print «No» (without quotes).

NoteIn the second sample case the user wants to create a login consisting of three zeros. It's impossible due to collision with the third among the existing.In the third sample case the new login is similar with the second one.

var login = readline().toLowerCase();
var countLogins = +readline();
var logins = [];
var result = true;

for (var i = 0; i < countLogins; i++) {
  logins.push(readline().toLowerCase());
}

// Solution start
function reformatLogin(login) {
  return login.replace(/o/gi, '0').replace(/l/gi, '1').replace(/i/gi, '1');
}

login = reformatLogin(login);

for (var i = 0; i < countLogins; i = i + 1) {
  var temp = reformatLogin(logins[i]);

  if (login === temp) {
    result = false;
    break;
  }
}

print(result ? 'Yes' : 'No');

var input = function(){
  var userNick = normalize(readline());
  var n = parseInt(readline());
  var s = new Set();
  for(var i=0; i<n; i++){
    s.add(normalize(readline()));
  }
  return {
    set : s,
    userNick: userNick
  }
}

var normalize = function(str){
  str = str.toLowerCase();
  str = str.replace(/0/g, 'o');
  str = str.replace(/1/g, 'i');
  str = str.replace(/l/g, 'i');
  return str;
}

var data = input();
if(data.set.has(data.userNick)){
  print('No');
} else {
  print('Yes');
}

function transformLogin(login) {
  return login.trim().toUpperCase().replace(/O/g, "0").replace(/[LI]/g, "1");
}

const newLogin = transformLogin(readline());
const existingCount = Number(readline());
(() => {
  for (var i = 0; i < existingCount; i++)
    if (newLogin === transformLogin(readline())) {
      print("No");
      return;
    }
  print("Yes");
})();

//Some debug stuff
const isDebugMode=false;
var log=()=>{}
if(isDebugMode){
    var print=function (out) {
        console.log('COUT: '+ out);
    }
    log=function (out) {
        console.log('DEBUG OUTPUT: '+ out);
    }
    function* readline_generator() {
        var a=[
            'La0',
            '3',
            '2a0',
            'La1',
            '1a0'
        ];
        while(a.length>1){
            yield a.shift()
        }
        return a.shift();
    }
    var g=readline_generator();
    var readline=function () {
        return g.next().value;
    }
}

//SOLUTION

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
        case 'i':
        case 'L':
            if(['1', 'l', 'I', 'i', 'L'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
            diff1.push(i);
            diff2.push(s2[k]);
        }
    })
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    log('Comparing '+currentLogin+ ' vs '+loginToTest);
    if( currentLogin && currentLogin.length==loginToTest.length){
        log('Length is equal')
        if(magic(loginToTest, currentLogin)){
            log('Magic is true');
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

var login = readline().replace(/0/g, "o").toLowerCase().replace(/1/g, "i").replace(/l/g, "i");
var db = readline();
var logins, answer;
for (i=0; i<db; i++) {
    logins = readline();
    logins = logins.replace(/0/g, "o").toLowerCase().replace(/1/g, "i").replace(/l/g, "i");
    if (login === logins) {answer="No";break;} else answer = "Yes";
}
print(answer);

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j].toLowerCase() == logged[i][j].toLowerCase()) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
    }
    numberSample = 0;
}
if (!res) write("No");
else write("Yes");

var newLogin = readline();
var numberOfLogins = parseInt(readline());
var isPrinted = false;

for (var i = 0; i < numberOfLogins; i++) {
    if(areLoginsSimilar(newLogin, readline())) {
        write('No');
        isPrinted = true;
        break;
    }
}

isPrinted || write('Yes');

function areLoginsSimilar(login, loginToChange) {
    if(login.length !== loginToChange.length) {
        return false;
    }

    for(var i = 0; i < loginToChange.length; i++) {
        if(!areLettersSimilar(login[i], loginToChange[i])) {
            return false;
        }
    }

    return true;
}

function areLettersSimilar(letter, letterToChange) {
    if(letterToChange.toLowerCase() === letter ||
           letterToChange.toUpperCase() === letter) {
           return true;
    }

    if(letter.match(/[0o]/i) && letterToChange.match(/[0o]/i)) {
        return true
    }

    if(letter.match(/[1li]/i) && letterToChange.match(/[1li]/i)) {
        return true
    }

    return false;
}

'use strict'
function getInputs(){
    let i = []
    let x = readline()
    while(typeof x != 'undefined'){
        i.push(x)
        x=readline()
    }
    return i
}
function check1(l){
    if(!l){
        print('No')
        return false
    }
    l = '' + l
    if(l.match(/[a-z0-9_]{1,50}/i)){
        return true
    } else{
        print('No')
        return false
    }
}
function upgradeDatabase(db){
    db = db.map(e=>e.toLowerCase(e))
    db = db.map(e=>e.replace(/(i|l)/ig,'1'))
    db = db.map(e=>e.replace(/(o)/ig,'0'))
    return db
}
function upgradeLogin(lg){
    lg = lg.toLowerCase()
    lg = lg.replace(/(i|l)/ig,'1')
    lg = lg.replace(/o/ig,'0')
    return lg
}
function check2(l,db){
    let check = true
    for(let e of db){
        if(e == l){
           check = false
        }
    }
    if(check){
        return true
    } else{
        print('No')
        return false
    }
}
function checkLogin(login,dbsize,...db){
    db=db[0]
    if(check1(login)){
        db = upgradeDatabase(db)
        login = upgradeLogin(login)
        if(check2(login,db)){
            print('Yes')
        }
    }
}

let inputs = getInputs()
checkLogin(inputs[0],inputs[1],inputs.slice(2))

String.prototype.normalize = function() {
    var self = this;
    return self.toLowerCase().replace(/o/g, '0').replace(/[il]/g, 1);
};

var potentialLogin = readline().normalize();
var existanceLoginCount = parseInt(readline());
var extstanceLogins = [];
var canLogIn = true;
var i = 0;
while(i < existanceLoginCount) {
    var line = readline();
    if(canLogIn && potentialLogin === line.normalize()){
        canLogIn = false;
    }
    i++;
}

print(canLogIn ? 'Yes' : 'No')

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
        case 'i':
            if(['1', 'l', 'I', 'i'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
        diff1.push(i);
        diff2.push(s2[k]);
    }
})
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    if(currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

'use strict';
var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
            if(['1', 'l', 'I'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
        diff1.push(i);
        diff2.push(s2[k]);
    }
})
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    if(currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f==1){
    print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;

while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest){
		if(magic(loginToTest, currentLogin)){
			print('No');
			//return false;
		}
	}
}
if(count==numOfLogins){
print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;

while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest.length){
		if(magic(loginToTest, currentLogin)){
			print('No');
			//return false;
		}
	}
}
if(count==numOfLogins){
print('Yes');
}

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
            if(['1', 'l', 'I'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
        diff1.push(i);
        diff2.push(s2[k]);
    }
})
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
    count++;
    var currentLogin=readline();
    if(currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest){
		if(magic(loginToTest, currentLogin)){
			print('No');
			f=1;
			//return false;
		}
	}
}
if(f==1){
print('Yes');
}

var compareS=function(s1, s2){
	if(s1.toLowerCase()==s2.toLowerCase()){
		return true;
	}
	switch(s1){
		case 'O':
		case '0':
		case 'o':
			if(['0', 'O', 'o'].indexOf(s2)>-1){
				return true;
			}
			break;
		case '1':
		case 'l':
		case 'I':
			if(['1', 'l', 'I'].indexOf(s2)>-1){
				return true;
			}
			break;
	}
	return false;
};

var compare=function(a1, a2){
	var c=0;
	a1.forEach((i,k)=>{
		if(compareS(i, a2[k])){
			c++;
		}
	})
	return c==a1.length;
}

var magic=function(s1, s2){
	s1=s1.split('');
	s2=s2.split('');
	var diff1=[];
	var diff2=[];
	s1.forEach((i,k)=>{
		if(i!=s2[k]){
			diff1.push(i);
			diff2.push(s2[k]);
		}
	})
	return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins){
	count++;
	var currentLogin=readline();
	if(currentLogin.length==loginToTest.length){
		if(magic(loginToTest, currentLogin)){
			print('No');
			f=1;
			//return false;
		}
	}
}
if(f==1){
print('Yes');
}

var compareS=function(s1, s2){
    if(s1.toLowerCase()==s2.toLowerCase()){
        return true;
    }
    switch(s1){
        case 'O':
        case '0':
        case 'o':
            if(['0', 'O', 'o'].indexOf(s2)>-1){
                return true;
            }
            break;
        case '1':
        case 'l':
        case 'I':
        case 'i':
            if(['1', 'l', 'I', 'i'].indexOf(s2)>-1){
                return true;
            }
            break;
    }
    return false;
};

var compare=function(a1, a2){
    var c=0;
    a1.forEach((i,k)=>{
        if(compareS(i, a2[k])){
            c++;
        }
    });
    return c==a1.length;
};

var magic=function(s1, s2){
    s1=s1.split('');
    s2=s2.split('');
    var diff1=[];
    var diff2=[];
    s1.forEach((i,k)=>{
        if(i!=s2[k]){
            diff1.push(i);
            diff2.push(s2[k]);
        }
    })
    return compare(diff1, diff2)
}

var loginToTest=readline();

var numOfLogins=+(readline());

var count=0;
var f=0;
while(count<numOfLogins+1){
    count++;
    var currentLogin=readline();
    if( currentLogin && currentLogin.length==loginToTest.length){
        if(magic(loginToTest, currentLogin)){
            print('No');
            f=1;
        }
    }
}
if(f===0){
    print('Yes');
}

var s1 = readline();
var s2 = parseInt(readline());
var arr = [];

for(var i = 0; i < s2; i++){
    arr.push(readline());
}

function task(){
    if(register(s1) === true && check(s1) === true) return "Yes";
    else return "No";
}

function register(string){
    for(var i = 0; i < arr.length; i++){
        if(s1.length !== arr[i].length) return false;
    }
    for(var i = 0; i < arr.length; i++){
        if(arr[i].toLowerCase() === string.toLowerCase()) return false;
    }
    return true;
}

function check(string){
    var word = string.split('');
    var ind = [];
    for(var i = 0; i < arr.length; i++){
        var buff = arr[i].split('');
        for(var j = 0; j < buff.length; j++){
            if(buff[j] === 'O' || buff[j] === '0' || buff[j] === '1' || buff[j] === 'l' || buff[j] === 'I' || buff[j] === 'i'){
                ind.push({index: j, el: buff[j]});
            }
        }
    }

    for(var i = 0; i < ind.length; i++){
        for(var j = 0; j < word.length;){
            if(ind[i].el === 'O' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'O' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'l' && ind[i].index === j) return false;
            if(ind[i].el === 'l' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'I' && ind[i].index === j) return false;
            if(ind[i].el === 'I' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'i' && ind[i].index === j) return false;
            if(ind[i].el === 'i' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === 'L' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'L' && ind[i].index === j) return false;
            j++;
        }
    }
    return true;
}

write(task());

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j] == logged[i][j]) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
        numberSample = 0;
    }
}
if (!res) write("No");
else write("Yes");

var user_input = readline();
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i") {
            user_input[j] = "*";
        }
        if (user_input[j] == logged[i][j]) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
        numberSample = 0;
    }
}
if (!res) write("No");
else write("Yes");

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j] == logged[i][j]) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
    }
    numberSample = 0;
}
if (!res) write("No");
else write("Yes");

var s1 = readline();
var s2 = parseInt(readline());
var arr = [];

for(var i = 0; i < s2; i++){
    arr.push(readline());
}

function task(){
    if(register(s1) === true && check(s1) === true) return "Yes";
    else return "No";
}

function register(string){
    for(var i = 0; i < arr.length; i++){
        if(s1.length !== arr[i].length) return false;
    }
    for(var i = 0; i < arr.length; i++){
        if(arr[i].toLowerCase() === string.toLowerCase()) return false;
    }
    return true;
}

function check(string){
    var word = string.split('');
    var ind = [];
    for(var i = 0; i < arr.length; i++){
        var buff = arr[i].split('');
        for(var j = 0; j < buff.length; j++){
            if(buff[j] === 'O' || buff[j] === '0' || buff[j] === '1' || buff[j] === 'l' || buff[j] === 'I' || buff[j] === 'i' || buff[j]==='L'){
                ind.push({index: j, el: buff[j]});
            }
        }
    }

    for(var i = 0; i < ind.length; i++){
        for(var j = 0; j < word.length;){
            if(ind[i].el === 'O' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'O' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'l' && ind[i].index === j) return false;
            if(ind[i].el === 'l' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'I' && ind[i].index === j) return false;
            if(ind[i].el === 'I' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'i' && ind[i].index === j) return false;
            if(ind[i].el === 'i' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === 'L' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'L' && ind[i].index === j) return false;
            j++;
        }
    }
    return true;
}

write(task());

var s1 = readline();
var s2 = parseInt(readline());
var arr = [];

for(var i = 0; i < s2; i++){
    arr.push(readline());
}

function task(){
    if(register(s1) === true && check(s1) === true) return "Yes";
    else return "No";
}

function register(string){
    for(var i = 0; i < arr.length; i++){
        if(s1.length !== arr[i].length) return false;
    }
    for(var i = 0; i < arr.length; i++){
        if(arr[i].toLowerCase() === string.toLowerCase()) return false;
    }
    return true;
}

function check(string){
    var word = string.split('');
    var ind = [];
    for(var i = 0; i < arr.length; i++){
        var buff = arr[i].split('');
        for(var j = 0; j < buff.length; j++){
            if(
                buff[j] === 'O' ||
                buff[j] === '0' ||
                buff[j] === '1' ||
                buff[j] === 'l' ||
                buff[j] === 'I' ||
                buff[j] === 'i' ||
                buff[j] === 'L' ||
                buff[j] === 'o'
            ){
                ind.push({index: j, el: buff[j]});
            }
        }
    }

    for(var i = 0; i < ind.length; i++){
        for(var j = 0; j < word.length;){
            if(ind[i].el === 'O' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'O' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'l' && ind[i].index === j) return false;
            if(ind[i].el === 'l' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'I' && ind[i].index === j) return false;
            if(ind[i].el === 'I' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'i' && ind[i].index === j) return false;
            if(ind[i].el === 'i' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === 'L' && word[j] === '1' && ind[i].index === j) return false;
            if(ind[i].el === '1' && word[j] === 'L' && ind[i].index === j) return false;
            if(ind[i].el === 'o' && word[j] === '0' && ind[i].index === j) return false;
            if(ind[i].el === '0' && word[j] === 'o' && ind[i].index === j) return false;
            j++;
        }
    }
    return true;
}

write(task());

var user_input = readline().split("");
var number = parseInt(readline());
var logged = [];
for (var i = 0; i < number; i++) {
    logged.push(readline().split(""));
}
var numberSample = 0;
var res = true;
for (var i = 0; i < logged.length; i++) {
    if (logged[i].length != user_input.length) {
        res = false;
        continue;
    }
    for (var j = 0; j < logged[i].length; j++) {
        if (logged[i][j] == "0" || logged[i][j] == "o" || logged[i][j] == "O") {
            logged[i][j] = ".";
        }
        if (user_input[j] == "0" || user_input[j] == "o" || user_input[j] == "O") {
            user_input[j] = ".";
        }
        if (logged[i][j] == "1" || logged[i][j] == "l" || logged[i][j] == "I" || logged[i][j] == "i" || logged[i][j] == "L") {
            logged[i][j] = "*";
        }
        if (user_input[j] == "1" || user_input[j] == "l" || user_input[j] == "I" || user_input[j] == "i" || user_input[j] == "L") {
            user_input[j] = "*";
        }
        if (user_input[j].toLowerCase() == logged[i][j].toLowerCase()) {
            numberSample++;
        }
    }
    if (user_input.length == numberSample) {
        res = false;
    }
    numberSample = 0;
}
if (!res) write("No");
else write("Yes");


This is an interactive problem.There was a tournament consisting of $$$2^n$$$ contestants. The $$$1$$$-st contestant competed with the $$$2$$$-nd, the $$$3$$$-rd competed with the $$$4$$$-th, and so on. After that, the winner of the first match competed with the winner of second match, etc. The tournament ended when there was only one contestant left, who was declared the winner of the tournament. Such a tournament scheme is known as the single-elimination tournament.You don't know the results, but you want to find the winner of the tournament. In one query, you select two integers $$$a$$$ and $$$b$$$, which are the indices of two contestants. The jury will return $$$1$$$ if $$$a$$$ won more matches than $$$b$$$, $$$2$$$ if $$$b$$$ won more matches than $$$a$$$, or $$$0$$$ if their number of wins was equal.Find the winner in no more than $$$\left \lceil \frac{1}{3} \cdot 2^{n + 1} \right \rceil$$$ queries. Here $$$\lceil x \rceil$$$ denotes the value of $$$x$$$ rounded up to the nearest integer.Note that the tournament is long over, meaning that the results are fixed and do not depend on your queries.

The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 2^{14}$$$) — the number of test cases. The only line of input contains a single integer $$$n$$$ ($$$1 \leq n \leq 17$$$). It is guaranteed that the sum of $$$2^n$$$ over all test cases does not exceed $$$2^{17}$$$.

NoteThe tournament in the first test case is shown below. The number of wins is $$$[1,0,0,2,0,1,3,0]$$$.    In this example, the winner is the $$$7$$$-th contestant.

var tests = parseInt(readline());
    var n;
    var arr;
    var count;

    function query(a, b) {
        print('? ' + a + ' ' + b);
        var rep = parseInt(readline());
        count++;
        return rep;
    }

    function pitTwo(a, b) {
        var rep = query(a, b);
        if (rep == -1) {
            return rep;
        }
        if (rep == 1) {
            return a;
        } else {
            return b;
        }
    }

    function pit(i) {
        var first = arr[i], second = arr[i+2];
        var rep = query(first, second);
        if (rep == -1) {
            return rep;
        }
        if (rep == 1) {
            second = arr[i+3];
        } else if (rep == 2) {
            first = arr[i+1];
        } else {
            first = arr[i+1];
            second = arr[i+3];
        }
        return pitTwo(first, second);
    }

    for (var t=0; t < tests; t++) {
        n = parseInt(readline());
        count = 0;
        arr = new Array((1 << n));
        for (var i = 0; i < arr.length; i++) {
            arr[i] = i+1;
        }
        while (arr.length >= 4) {
            var temp = [];
            var winner = -1;
            for (var i = 0; i < arr.length; i+=4) {
                winner = pit(i);
                if (winner == -1) {
                    break;
                }
                temp.push(winner);
            }
            if (winner == -1) {
                break;
            }
            arr = temp;
        }
        var ans;
        if (arr.length == 2) {
            ans = pitTwo(arr[0], arr[1]);
        } else {
            ans = arr[0];
        }
        print('! ' + ans);
    }


You are given a string $$$s$$$ consisting of exactly $$$n$$$ characters, and each character is either '0', '1' or '2'. Such strings are called ternary strings.Your task is to replace minimum number of characters in this string with other characters to obtain a balanced ternary string (balanced ternary string is a ternary string such that the number of characters '0' in this string is equal to the number of characters '1', and the number of characters '1' (and '0' obviously) is equal to the number of characters '2').Among all possible balanced ternary strings you have to obtain the lexicographically (alphabetically) smallest.Note that you can neither remove characters from the string nor add characters to the string. Also note that you can replace the given characters only with characters '0', '1' and '2'.It is guaranteed that the answer exists.

The first line of the input contains one integer $$$n$$$ ($$$3 \le n \le 3 \cdot 10^5$$$, $$$n$$$ is divisible by $$$3$$$) — the number of characters in $$$s$$$. The second line contains the string $$$s$$$ consisting of exactly $$$n$$$ characters '0', '1' and '2'.

Print one string — the lexicographically (alphabetically) smallest balanced ternary string which can be obtained from the given one with minimum number of replacements. Because $$$n$$$ is divisible by $$$3$$$ it is obvious that the answer exists. And it is obvious that there is only one possible answer.

var n = readline();

var str = readline().split('');

var div = n / 3;

var one, two, zero;
var div0 = div, div1 = div, div2 = div;

one = 0;
two = 0;
zero = 0;

for( var i=0; i<n; i++ ) {
    if( str[i] === '0' ) zero++;
    if( str[i] === '1' ) one++;
    if( str[i] === '2' ) two++;
}
/*
write(zero + ' ');
write(one + ' ');
write(two + '\n\n');
*/

for( var i=0; i<n && zero < div; i++ ) {
    if( str[i] === '0' ) continue;
    else {
        if( str[i] === '2' ) {
            if( two > div ) {
                two--;
                zero++;
                str[i] = '0';
            }
        }
        if( str[i] === '1' ) {
            if( one > div ) {
                one--;
                zero++;
                str[i] = '0';
            }
        }
    }
}

for( var i=n-1; i>=0 && two < div; i-- ) {
    if( str[i] === '2' ) continue;
    else {

        if( str[i] === '1' ) {
            if( one > div ) {
                one--;
                str[i] = '2';
                two++;
            }
        }
        if( str[i] === '0' ) {
            if( zero > div ) {
                zero--;
                str[i] = '2';
                two++;
            }
        }
    }
}

if( one < div ) {
    if( zero > div ) {
       for( var i=n-1; i>=0 && one < div; i-- ) {
            if( str[i] === '1' ) continue;
            else {
                if( str[i] === '0' ) {
                    if( zero > div ) {
                        zero--;
                        str[i] = '1';
                        one++;
                    }
                }

            }
        }
    }
    if( two > div ) {
       for( var i=0; i<n && one < div; i++ ) {
            if( str[i] === '1' ) continue;
            else {
                if( str[i] === '2' ) {
                    if( two > div ) {
                        two--;
                        str[i] = '1';
                        one++;
                    }
                }

            }
        }
    }
}

str.forEach( i=> {
   write(i);
});

var n = readline();

var str = readline().split('');

var div = n / 3;

var one, two, zero;
var div0 = div, div1 = div, div2 = div;

one = 0;
two = 0;
zero = 0;

for( var i=0; i<n; i++ ) {
    if( str[i] === '0' ) zero++;
    if( str[i] === '1' ) one++;
    if( str[i] === '2' ) two++;
}
write(zero + ' ');
write(one + ' ');
write(two + '\n\n');

for( var i=0; i<n && zero < div; i++ ) {
    if( str[i] === '0' ) continue;
    else {
        if( str[i] === '2' ) {
            if( two > div ) {
                two--;
                zero++;
                str[i] = '0';
            }
        }
        if( str[i] === '1' ) {
            if( one > div ) {
                one--;
                zero++;
                str[i] = '0';
            }
        }
    }
}

for( var i=n-1; i>=0 && two < div; i-- ) {
    if( str[i] === '2' ) continue;
    else {

        if( str[i] === '1' ) {
            if( one > div ) {
                one--;
                str[i] = '2';
                two++;
            }
        }
        if( str[i] === '0' ) {
            if( zero > div ) {
                zero--;
                str[i] = '2';
                two++;
            }
        }
    }
}

for( var i=n-1; i>=0 && one < div; i-- ) {
    if( str[i] === '1' ) continue;
    else {

        if( str[i] === '2' ) {
            if( two > div ) {
                two--;
                str[i] = '1';
                one++;
            }
        }
        if( str[i] === '0' ) {
            if( zero > div ) {
                zero--;
                str[i] = '1';
                one++;
            }
        }
    }
}

str.forEach( i=> {
   write(i);
});

var n = readline();

var str = readline();

var div = n / 3;

var one, two, zero;
var div0 = div, div1 = div, div2 = div;

one = two = zero = 0;

for( var i=0; i<n; i++ ) {
    if( str.charAt(i) === '0') {
        if(div0 > 0 ) {
            div0--;
            write(0);
        } else {
            if( div1 > div2 ) {
                write(1);
                div1--;
            } else {
                write(2);
                div2--;
            }
        }
    }
    if( str.charAt(i) === '1') {
        if(div1 > 0 ) {
            div1--;
            write(1);
        } else {
            if( div0 > div2 ) {
                write(0);
                div0--;
            } else {
                write(2);
                div2--;
            }
        }
    }
    if( str.charAt(i) === '2') {
        if(div2 > 0 ) {
            div2--;
            write(2);
        } else {
            if( div1 > div0 ) {
                write(1);
                div1--;
            } else {
                write(0);
                div0--;
            }
        }
    }
}

var n = readline();

var str = readline().split('');

var div = n / 3;

var one, two, zero;
var div0 = div, div1 = div, div2 = div;

one = 0;
two = 0;
zero = 0;

for( var i=0; i<n; i++ ) {
    if( str[i] === '0' ) zero++;
    if( str[i] === '1' ) one++;
    if( str[i] === '2' ) two++;
}
/*
write(zero + ' ');
write(one + ' ');
write(two + '\n\n');
*/

for( var i=0; i<n && zero < div; i++ ) {
    if( str[i] === '0' ) continue;
    else {
        if( str[i] === '2' ) {
            if( two > div ) {
                two--;
                zero++;
                str[i] = '0';
            }
        }
        if( str[i] === '1' ) {
            if( one > div ) {
                one--;
                zero++;
                str[i] = '0';
            }
        }
    }
}

for( var i=n-1; i>=0 && two < div; i-- ) {
    if( str[i] === '2' ) continue;
    else {

        if( str[i] === '1' ) {
            if( one > div ) {
                one--;
                str[i] = '2';
                two++;
            }
        }
        if( str[i] === '0' ) {
            if( zero > div ) {
                zero--;
                str[i] = '2';
                two++;
            }
        }
    }
}

for( var i=n-1; i>=0 && one < div; i-- ) {
    if( str[i] === '1' ) continue;
    else {

        if( str[i] === '2' ) {
            if( two > div ) {
                two--;
                str[i] = '1';
                one++;
            }
        }
        if( str[i] === '0' ) {
            if( zero > div ) {
                zero--;
                str[i] = '1';
                one++;
            }
        }
    }
}

str.forEach( i=> {
   write(i);
});