After the contest in comparing numbers, Shapur's teacher found out that he is a real genius and that no one could possibly do the calculations faster than him even using a super computer!Some days before the contest, the teacher took a very simple-looking exam and all his n students took part in the exam. The teacher gave them 3 strings and asked them to concatenate them. Concatenating strings means to put them in some arbitrary order one after the other. For example from concatenating Alireza and Amir we can get to AlirezaAmir or AmirAlireza depending on the order of concatenation.Unfortunately enough, the teacher forgot to ask students to concatenate their strings in a pre-defined order so each student did it the way he/she liked.Now the teacher knows that Shapur is such a fast-calculating genius boy and asks him to correct the students' papers.Shapur is not good at doing such a time-taking task. He rather likes to finish up with it as soon as possible and take his time to solve 3-SAT in polynomial time. Moreover, the teacher has given some advice that Shapur has to follow. Here's what the teacher said:   As I expect you know, the strings I gave to my students (including you) contained only lowercase and uppercase Persian Mikhi-Script letters. These letters are too much like Latin letters, so to make your task much harder I converted all the initial strings and all of the students' answers to Latin.  As latin alphabet has much less characters than Mikhi-Script, I added three odd-looking characters to the answers, these include "-", ";" and "_". These characters are my own invention of course! And I call them Signs.  The length of all initial strings was less than or equal to 100 and the lengths of my students' answers are less than or equal to 600  My son, not all students are genius as you are. It is quite possible that they make minor mistakes changing case of some characters. For example they may write ALiReZaAmIR instead of AlirezaAmir. Don't be picky and ignore these mistakes.  Those signs which I previously talked to you about are not important. You can ignore them, since many students are in the mood for adding extra signs or forgetting about a sign. So something like Iran;;-- is the same as --;IRAN  You should indicate for any of my students if his answer was right or wrong. Do this by writing "WA" for Wrong answer or "ACC" for a correct answer.  I should remind you that none of the strings (initial strings or answers) are empty.  Finally, do these as soon as possible. You have less than 2 hours to complete this.

The first three lines contain a string each. These are the initial strings. They consists only of lowercase and uppercase Latin letters and signs ("-", ";" and "_"). All the initial strings have length from 1 to 100, inclusively. In the fourth line there is a single integer n (0 ≤ n ≤ 1000), the number of students. Next n lines contain a student's answer each. It is guaranteed that the answer meets what the teacher said. Each answer iconsists only of lowercase and uppercase Latin letters and signs ("-", ";" and "_"). Length is from 1 to 600, inclusively.

For each student write in a different line. Print "WA" if his answer is wrong or "ACC" if his answer is OK.

Iran_
Persian;
W_o;n;d;e;r;f;u;l;
7
WonderfulPersianIran
wonderful_PersIAN_IRAN;;_
WONDERFUL___IRAN__PERSIAN__;;
Ira__Persiann__Wonderful
Wonder;;fulPersian___;I;r;a;n;
__________IranPersianWonderful__________
PersianIran_is_Wonderful

Shapur;;
is___
a_genius
3
Shapur__a_is___geniUs
is___shapur___a__Genius;
Shapur;;is;;a;;geni;;us;;

function trim(s) {
	return s.replace(/^\s+|\s+$/gm, '');
}

function tokenize(s) {
	return trim(s).split(/\s+/);
}

function tokenizeIntegers(s) {
	var tokens = tokenize(s);
	for (var i = 0; i < tokens.length; i += 1) {
		tokens[i] = parseInt(tokens[i], 10);
	};
	return tokens;
}

function main() {
	var words = [];
	for (var i = 0; i < 3; ++i) {
		words.push(trim(readline()).toLowerCase().replace(/[-;_]/g, ''));
	}
	var a = words[0], b = words[1], c = words[2],
		sentences = [a+b+c, a+c+b, b+a+c, b+c+a, c+a+b, c+b+a],
		n = parseInt(readline());
	for (var i = 0; i < n; ++i) {
		var input = trim(readline()).toLowerCase().replace(/[-;_]/g, '');
		for (var j = 0; j < 6; ++j) {
			if (input == sentences[j]) {
				print('ACC');
				break;
			}
		}
		if (j == 6) {
			print('WA');
		}
	}
}

main();

'use strict'

let A = readline().toLowerCase().replace(/[_;-]/g, '')
let B = readline().toLowerCase().replace(/[_;-]/g, '')
let C = readline().toLowerCase().replace(/[_;-]/g, '')
let N = readline()

let vars = [
  A + B + C,
  A + C + B,
  B + A + C,
  B + C + A,
  C + A + B,
  C + B + A
]

let R

while (R = readline()) {
  R = R.toLowerCase().replace(/[_;-]/g, '')
  let ok = false
  for (let i = 0; i < vars.length; i++) {
    if (vars[i] == R) {
      ok = true
      break
    }
  }
  print(ok ? 'ACC' : 'WA')
}

'use strict'

let A = readline().toLowerCase().replace(/[_;-]/g, '')
let B = readline().toLowerCase().replace(/[_;-]/g, '')
let C = readline().toLowerCase().replace(/[_;-]/g, '')
let N = readline()

let vars = [
  A + B + C,
  A + C + B,
  B + A + C,
  B + C + A,
  C + A + B,
  C + B + A
]

let R = readline()

while (R = R && R.toLowerCase().replace(/[_;-]/g, '')) {
  let ok = false
  for (let i = 0; i < vars.length; i++) {
    if (vars[i] == R) {
      ok = true
      break
    }
  }
  print(ok ? 'ACC' : 'WA')
  R = readline()
}


On February 14 Denis decided to give Valentine to Nastya and did not come up with anything better than to draw a huge red heart on the door of the length $$$k$$$ ($$$k \ge 3$$$). Nastya was very confused by this present, so she decided to break the door, throwing it on the mountains.Mountains are described by a sequence of heights $$$a_1, a_2, \dots, a_n$$$ in order from left to right ($$$k \le n$$$). It is guaranteed that neighboring heights are not equal to each other (that is, $$$a_i \ne a_{i+1}$$$ for all $$$i$$$ from $$$1$$$ to $$$n-1$$$).Peaks of mountains on the segment $$$[l,r]$$$ (from $$$l$$$ to $$$r$$$) are called indexes $$$i$$$ such that $$$l < i < r$$$, $$$a_{i - 1} < a_i$$$ and $$$a_i > a_{i + 1}$$$. It is worth noting that the boundary indexes $$$l$$$ and $$$r$$$ for the segment are not peaks. For example, if $$$n=8$$$ and $$$a=[3,1,4,1,5,9,2,6]$$$, then the segment $$$[1,8]$$$ has only two peaks (with indexes $$$3$$$ and $$$6$$$), and there are no peaks on the segment $$$[3, 6]$$$.To break the door, Nastya throws it to a segment $$$[l,l+k-1]$$$ of consecutive mountains of length $$$k$$$ ($$$1 \le l \le n-k+1$$$). When the door touches the peaks of the mountains, it breaks into two parts, after that these parts will continue to fall in different halves and also break into pieces when touching the peaks of the mountains, and so on. Formally, the number of parts that the door will break into will be equal to $$$p+1$$$, where $$$p$$$ is the number of peaks on the segment $$$[l,l+k-1]$$$.Nastya wants to break it into as many pieces as possible. Help her choose such a segment of mountains $$$[l, l+k-1]$$$ that the number of peaks on it is maximum. If there are several optimal segments, Nastya wants to find one for which the value $$$l$$$ is minimal.Formally, you need to choose a segment of mountains $$$[l, l+k-1]$$$ that has the maximum number of peaks. Among all such segments, you need to find the segment that has the minimum possible value $$$l$$$.

The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$)  — the number of test cases. Then the descriptions of the test cases follow. The first line of each test case contains two integers $$$n$$$ and $$$k$$$ ($$$3 \leq k \leq n \leq 2 \cdot 10^5$$$)  — the number of mountains and the length of the door. The second line of the input data set contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$0 \leq a_i \leq 10 ^ 9$$$, $$$a_i \neq a_{i + 1}$$$)  — the heights of mountains. It is guaranteed that the sum of $$$n$$$ over all the test cases will not exceed $$$2 \cdot 10^5$$$.

For each test case, output two integers $$$t$$$ and $$$l$$$  — the maximum number of parts that the door can split into, and the left border of the segment of length $$$k$$$ that the door should be reset to.

NoteIn the first example, you need to select a segment of mountains from $$$2$$$ to $$$7$$$. In this segment, the indexes $$$3$$$ and $$$6$$$ are peaks, so the answer is $$$3$$$ (only $$$2$$$ peaks, so the door will break into $$$3$$$ parts). It is not difficult to notice that the mountain segments $$$[1, 6]$$$ and $$$[3, 8]$$$ are not suitable since they only have a $$$1$$$ peak (for the first segment, the $$$6$$$ index is not a peak, and for the second segment, the $$$3$$$ index is not a peak).In the second example, you need to select a segment of mountains from $$$2$$$ to $$$4$$$. In this segment, the index $$$3$$$ is a peak, so the answer is $$$2$$$ (only $$$1$$$ peak, so the door will break into $$$2$$$ parts).In the third example, you need to select a segment of mountains from $$$1$$$ to $$$4$$$. In this segment, the index $$$3$$$ is a peak, so the answer is $$$2$$$ (only $$$1$$$ peak, so the door will break into $$$2$$$ parts). You can see that on the segments $$$[2, 5]$$$, $$$[4, 7]$$$ and $$$[5, 8]$$$ the number of peaks is also $$$1$$$, but these segments have a left border greater than the segment $$$[1, 4]$$$, so they are not the correct answer.

var t = parseInt(readline());

function mapper(s) { return +s; }

for(var qq = 0; qq < t; qq++) {
    var line = readline().split(' ').map(mapper);
    var n = line[0];
    var k = line[1];
    var a = readline().split(' ').map(mapper);
    var al = a.length;

    var max = 0;
    var left = -1;
    var curCount = 0;
    var pikes = [];

    for(var i = 0; i < al; i++) {
        pikes[i] = 0;
    }

    for(var i = al - 2; i >= 0; i--) {
        var idx = Math.min(i + k - 1, al - 1);

        if (pikes[idx]) {
            curCount -= 1;
        }

        if (a[i + 1] > a[i] && a[i + 1] > a[i + 2]) {
            pikes[i + 1] = ++curCount;

            if (curCount >= max) {
                max = curCount;
                left = i;
            }
        } else {
            pikes[i] = 0;
        }

        if (curCount === max) {
            left = i;
        }
    }
    print(max + 1, left + 1);

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main() {
    let range = readline();
    for(let r=0;r<range;r++) {
        let data = readline().split(" ").map(x => parseInt(x));
        let n = data[0];
        let k = data[1];
        let a = readline().split(" ").map(x => parseInt(x));
        let count = 0;
        let peak = new Array(a.length).fill(false);

        for(let i=1;i<n - 1;i++) {
            if(a[i] > a[i-1] && a[i] > a[i+1]) {

                peak[i] = true;
            }
        }

        let sum = 0;

        for(let i=1;i<k-1;i++) {
            if(peak[i]) {
                sum++;
            }
        }

        let max = sum;
        let counter = 1;
        let start = 1;
        for(let i=k-1;i<n;i++) {
            if(peak[i]) {
                sum++;
            }

            if(peak[counter]) {
                sum--;
            }

            if(sum > max) {
                max = sum;
                start = counter + 1;
            }

            counter++;
        }

        console.log((max+1) + " " + start);
    }

}


Bash has set out on a journey to become the greatest Pokemon master. To get his first Pokemon, he went to Professor Zulu's Lab. Since Bash is Professor Zulu's favourite student, Zulu allows him to take as many Pokemon from his lab as he pleases.But Zulu warns him that a group of k > 1 Pokemon with strengths {s1, s2, s3, ..., sk} tend to fight among each other if gcd(s1, s2, s3, ..., sk) = 1 (see notes for gcd definition).Bash, being smart, does not want his Pokemon to fight among each other. However, he also wants to maximize the number of Pokemon he takes from the lab. Can you help Bash find out the maximum number of Pokemon he can take? Note: A Pokemon cannot fight with itself.

The input consists of two lines. The first line contains an integer n (1 ≤ n ≤ 105), the number of Pokemon in the lab. The next line contains n space separated integers, where the i-th of them denotes si (1 ≤ si ≤ 105), the strength of the i-th Pokemon.

Print single integer — the maximum number of Pokemons Bash can take.

Notegcd (greatest common divisor) of positive integers set {a1, a2, ..., an} is the maximum positive integer that divides all the integers {a1, a2, ..., an}.In the first sample, we can take Pokemons with strengths {2, 4} since gcd(2, 4) = 2.In the second sample, we can take Pokemons with strengths {2, 4, 6}, and there is no larger group with gcd ≠ 1.

function main()
{
    var n = Number(readline());
    var a = readline().split(' ').map( Number );

    var c = {};

    a.forEach( function( x ) {
        var t = ~~( Math.sqrt( x ) );
        for ( var i=2 ; i<=t ; i++ )
        {
            if ( x % i == 0 )
            {
                c[ i ] = c[i] ? c[i]+1 : 1;
                while ( x%i == 0 ) x /= i;
            }
        }
        if ( x )
        {
            c[ x ] = c[x] ? c[x]+1 : 1;
        }
    } );

    var ans = c[1] ? 1 : 0;
    delete c[1];
    for ( var i in c ) ans = Math.max( ans , c[i] );

    print( ans );

} main();

var all = [];
for(var i=0;i<100001;i++){
    all[i] = 0;
}

function calculate(num) {

    var half = Math.floor(Math.sqrt(num)) + 1;
    if(num == 1){
        return;
    }
    if(num==2){
        all[2]++
        return;
    }
    if(num==3){
        all[3]++;
        return;
    }

    for (var i=1; i < half; i++) {
        if(num % i === 0 && i*i != num){
            all[i]++;
            all[num/i]++;
        } else if(num % i === 0){
            all[i]++;
        }
    }
}

function main() {
    var s1 = readline();
    var numbers = readline().split(' ').map(Number);
    numbers.map(calculate);
    all[1] = 1;
    all[0] = 0;
    print(Math.max(...all))
}

main()

var all = [];
for(var i=0;i<100001;i++){
    all[i] = 0;
}

function calculate(num) {

    var half = Math.floor(Math.sqrt(num)) + 1;

    for (var i=1; i < half; i++) {
        if(num % i === 0 && i*i != num){
            all[i]++;
            all[num/i]++;
        } else if(num % i === 0){
            all[i]++;
        }
    }
}

function main() {
    var s1 = readline();
    var numbers = readline().split(' ').map(Number);
    numbers.map(calculate);
    all[1] = 1;
    all[0] = 0;
    print(Math.max(...all))
}

main()

var all = [];
for(var i=0;i<100001;i++){
    all[i] = 0;
}

function calculate(num) {

    var half = Math.floor(Math.sqrt(num)) + 1;
    if(num == 1){
        return;
    }
    if(num==2){
        all[2]++
        return;
    }
    if(num==3){
        all[3]++;
    }

    for (var i=1; i < half; i++) {
        if(num % i === 0 && i*i != num){
            all[i]++;
            all[num/i]++;
        } else if(num % i === 0){
            all[i]++;
        }
    }
}

function main() {
    var s1 = readline();
    var numbers = readline().split(' ').map(Number);
    numbers.map(calculate);
    all[1] = 1;
    all[0] = 0;
    print(Math.max(...all))
}

main()

var all = [];
for(var i=0;i<100001;i++){
    all[i] = 0;
}

function calculate(num) {

    var half = Math.floor(Math.sqrt(num)) + 1;
    if(num == 1){
        return;
    }
    if(num==2){
        all[2]++
        return;
    }
    if(num==3){
        all[3]++;
    }

    for (var i=1; i < half; i++) {
        if(num % i === 0 && i*i != num){
            all[i]++;
            all[num/i]++;
        } else if(num % i === 0){
            all[i]++;
        }
    }
}

function main() {
    var s1 = readline();
    var numbers = readline().split(' ').map(Number);
    numbers.map(calculate);
    all[1] = 0;
    all[0] = 0;
    print(Math.max(...all))
}

main()

function main()
{
    var n = Number(readline());
    var a = readline().split(' ').map( Number );

    var c = {};

    a.forEach( function( x ) {
        var t = ~~( Math.sqrt( x ) );
        for ( var i=2 ; i<=t ; i++ )
        {
            if ( x % i == 0 )
            {
                c[ i ] = c[i] ? c[i]+1 : 1;
                while ( x%i == 0 ) x /= i;
            }
        }
        if ( x )
        {
            c[ x ] = c[x] ? c[x]+1 : 1;
        }
    } );

    var ans = 0;
    for ( var i in c ) ans = Math.max( ans , c[i] );

    print( ans );

} main();

function main()
{
    var n = Number(readline());
    var a = readline().split(' ').map( Number );

    var c = {};

    a.forEach( function( x ) {
        var t = ~~( Math.sqrt( x ) );
        for ( var i=2 ; i<=t ; i++ )
        {
            if ( x % i == 0 )
            {
                c[ i ] = c[i] ? c[i]+1 : 1;
                while ( x%i == 0 ) x /= i;
            }
        }
        if ( x )
        {
            c[ x ] = c[x] ? c[x]+1 : 1;
        }
    } );

    var ans = 0;
    delete c[1];
    for ( var i in c ) ans = Math.max( ans , c[i] );

    print( ans );

} main();


The School №0 of the capital of Berland has n children studying in it. All the children in this school are gifted: some of them are good at programming, some are good at maths, others are good at PE (Physical Education). Hence, for each child we know value ti:  ti = 1, if the i-th child is good at programming,  ti = 2, if the i-th child is good at maths,  ti = 3, if the i-th child is good at PE Each child happens to be good at exactly one of these three subjects.The Team Scientific Decathlon Olympias requires teams of three students. The school teachers decided that the teams will be composed of three children that are good at different subjects. That is, each team must have one mathematician, one programmer and one sportsman. Of course, each child can be a member of no more than one team.What is the maximum number of teams that the school will be able to present at the Olympiad? How should the teams be formed for that?

The first line contains integer n (1 ≤ n ≤ 5000) — the number of children in the school. The second line contains n integers t1, t2, ..., tn (1 ≤ ti ≤ 3), where ti describes the skill of the i-th child.

In the first line output integer w — the largest possible number of teams.  Then print w lines, containing three numbers in each line. Each triple represents the indexes of the children forming the team. You can print both the teams, and the numbers in the triplets in any order. The children are numbered from 1 to n in the order of their appearance in the input. Each child must participate in no more than one team. If there are several solutions, print any of them. If no teams can be compiled, print the only line with value w equal to 0.

//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");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return 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 N = nextInt();
  var list = nextIntArray();
  var one = new Set();
  var two = new Set();
  var three = new Set();
  for(var i = 0; i < N; i++){
    switch(list[i]){
      case 1:
        one.add(i + 1);
        break;
      case 2:
        two.add(i + 1);
        break;
      case 3:
        three.add(i + 1);
        break;
                  }
  }
  var sizeMin = Math.min.apply(null, [one.size, two.size, three.size]);
  myout(sizeMin);
  var oneList = Array.from(one);
  var twoList = Array.from(two);
  var threeList = Array.from(three);
  for(var i = 0; i < sizeMin; i++){
    myout(oneList[i] + " " + twoList[i] + " " + threeList[i]);
  }
}

const readline = require('readline');

let secondLine = false;

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let inputs = [];

rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Read Inputs
rl.on('close', () => {
    const children = inputs[0]
    const skills = inputs[1].split(' ');
    let teams = [];
    let prgrammingSkills = [];
    let mathSkills = [];
    let physicsSkills = [];

    if (Math.floor(children / 3) < 1) return console.log(0);

    skills.forEach((skill, i) => {
        if (skill == 1) prgrammingSkills.push({ index: ++i });
        if (skill == 2) mathSkills.push({ index: ++i })
        if (skill == 3) physicsSkills.push({ index: ++i });
    })

    if (prgrammingSkills.length === 0 || mathSkills.length === 0 || physicsSkills.length === 0)
        return console.log(0);

    let estimatedTeams = Math.min(prgrammingSkills.length, mathSkills.length, physicsSkills.length);

    console.log(estimatedTeams)
    for (let i = 0; i < estimatedTeams; i++) {
        console.log(prgrammingSkills[i].index, mathSkills[i].index, physicsSkills[i].index);
    }

});

'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(s) {
  process.stdout.write(`${s}`);
}
// Make a Snippet for the code above this and then write your logic in main();

function main() {
  // input
  const n = +readline();
  let a = readline().split(' ').map(x => parseInt(x));
  let t1 = 0, t2 = 0, t3 = 0;
  const r = [];
  while (t1 < n && t2 < n && t3 < n) {
    if (a[t1] !== 1) {
      t1++;
      continue;
    }
    if (a[t2] !== 2) {
      t2++;
      continue;
    }
    if (a[t3] !== 3) {
      t3++;
      continue;
    }
    r.push(`${t1 + 1} ${t2 + 1} ${t3 + 1}\n`);
    t1++;
    t2++;
    t3++;
  }
  print(`${r.length}\n`);
  r.forEach(x => print(x));
}

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

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

  const people = d.split(' ').map(Number);
  const programming = [];
  const math = [];
  const pe = [];

  people.forEach((x, idx) => {
    if (x === 1) {
      programming.push(idx + 1);
    }
    else if (x === 2) {
      math.push(idx + 1);
    }
    else {
      pe.push(idx + 1);
    }
  });

  const ans = Math.min(programming.length, math.length, pe.length);
  console.log(ans);

  for (let i = 0; i < ans; i++) {
    console.log(`${programming[i]} ${math[i]} ${pe[i]}`);
  }

  c++;
});

rl.on('close', () => {

});

'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 readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

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

function write(x) {
    process.stdout.write(x);
}
function min(a,b) {
    if(a > b) return b;
    else return a;
}
function main() {
    let [n] = readint();
    let arr = readint();
    let t = [...arr];
    t.sort((a,b)=> (a - b));
    let ans = 6000;
    let cur = t[0];
    let count = 0;
    let proper = 0;
    t.forEach(element => {
        if(element == cur) count++;
        else {
            cur = element;
            ans = min(ans, count);
            count = 1;
            proper++;
        }
    });
    ans = min(ans, count);
    if(proper < 2) print(0);
    else {
        print(ans);
        for(let i = 0; i < ans; i++) {
            let j = 3;
            cur = 1;
            while(j--) {
                for(let k = 0; k < arr.length; k++) {
                    if(arr[k] == cur) {
                        write((k + 1) + " ");
                        arr[k] = 0;
                        break;
                    }
                }
                cur++;
            }
            console.log();
        }
    }
}

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

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

readLine.on('close', () => {
  let [n] = input[0].split(' ').map(x => parseInt(x));
  const nums = input[1].split(' ').map(x => parseInt(x));

  const map = {};
  nums.forEach((x, i) => {
    if (map[x] === undefined) map[x] = [i+1]
    else map[x].push(i+1);
  });

  if (map[1] === undefined || map[2] === undefined || map[3] === undefined) {
    console.log(0); return;
  }

  let answ = Math.min(map[1].length, map[2].length, map[3].length);
  console.log(answ);answ

  for (let i = 0; i < answ; i += 1) {
    console.log(`${map[1].pop()} ${map[2].pop()} ${map[3].pop()}`)
  }
});

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

const readLine=()=> inputString[currentLine++];
/* ================================================
           Main Solution Starts Here
===================================================*/

const main=()=>{
	let n=+readLine()
	let one = 0,two=0,three=0
	let o=[],t=[],th=[]
	let ls = readLine().split(" ").map((n,index)=>{
		if(n==='1')
			one++ , o.push(index+1)
		else if (n==='2')
			two++ , t.push(index+1)
		else if(n==='3') three++, th.push(index+1)
	return +n
	})
	let teams = Math.min(one,Math.min(two,three))
	if(teams){
		console.log(teams)
		for(let i=0;i<teams;i++){
			console.log(o[i],t[i],th[i])
		}
	}else{
		console.log(teams)
	}
}

// Sample code to perform I/O:

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var stdin_input = "";

process.stdin.on("data", function (input) {
    stdin_input += input;                               // Reading input from STDIN
});

process.stdin.on("end", function () {
    main(stdin_input);
});

/**
 *
 * @param {*} str
 * @param {*} seperator
 */
function splitter(str, seperator = '') {
    return str.trim().split(seperator);
}

/**
 *
 * @param {*} arr
 */
function strToNumArr(arr = []) {
    return arr.map(num => Number(num));
}

/**
 *
 * @param {*} num1
 * @param {*} num2
 */
function matrixArray(num1, num2) {
    return Array(num1).fill(Array(num2));
}

let log = function () {
    return Function.prototype.bind.call(console.log, console, '');
}();

function removeEmptyItem(arr, index) {
    return arr.slice(0, index).concat(arr.slice(index + 1, arr.length));
}

function range(min, max) {

    let arr = [];
    for (let index = min; index < max; index++) {
        arr.push(index);

    }
    return arr;
}

function main(input) {
    let output = nameLookUp(input);
    // process.stdout.write(output);       // Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail

// Write your code here
function nameLookUp(str) {

    let inputs = str.split('\n');
    let nSpecialites = strToNumArr(splitter(inputs[1], ' '));
    let n = inputs[0];

    let teamIndex = [];
    teamIndex[0] = [], teamIndex[1] = [], teamIndex[2] = [];

    let maxTeam = Math.floor(n / 2);

    for (let index = 0; index < nSpecialites.length; index++) {
        const element = nSpecialites[index];
        if (element == 1) {
            teamIndex[0].push(index + 1);
        }
        if (element == 2) {
            teamIndex[1].push(index + 1);
        }
        if (element == 3) {
            teamIndex[2].push(index + 1);
        }
    }
    let team = Math.min(teamIndex[0].length, teamIndex[1].length, teamIndex[2].length);
    console.log(team);
    for (let index = 0; index < team; index++) {
        const element = nSpecialites[index];
        console.log(teamIndex[0][index] + ' ' + teamIndex[1][index] + ' ' + teamIndex[2][index]);
    }
}

const readline = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
let input = [];
readline.on('line', line => {
  input.push(line);
});
process.stdin.on('end', () => {
const students = parseFloat(input[0]);
const skillMap = { 1:[], 2:[], 3:[] };
let skills = input[1].split(' ');
let text = '';
let count = 0;
for (let i=0; i < skills.length; i++) {
  const skill = parseInt(skills[i], 10);
  skillMap[skill].push(i+1);
  if (Object.entries(skillMap).every((a) => a[1].length > 0)) {
    count += 1;
    for (const key in skillMap) {
      text += `${skillMap[key].pop()} `;
    }
      text = text.slice(0, -1);
      text += '\n';
  }
}
console.log(count);
console.log(text);

});

"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
        .replace(/\s*$/, "")
        .split("\n")
        .map((str) => str.replace(/\s*$/, ""));

    main();
});

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

function main() {
    let n = parseInt(readLine())
    let arr = readLine().split(' ').map(v => parseInt(v))
    let bla = []
    let ans = []
    if (arr.indexOf(1) == -1 || arr.indexOf(2) == -1 || arr.indexOf(3) == -1) {
        console.log(0)
    } else {
        for (var j = 1; j <= 3; j++) {
            let i = 0;
            while (arr.indexOf(j, i) != -1) {
                bla.push(arr.indexOf(j, i) + 1)
                i += 1
            }
            ans.push([...new Set(bla)]);
            bla = []
        }
        let a = ans.map((value) => value.length)
        console.log(Math.min(...a))
        for (let i = 0; i < Math.min(...a); i++) {
            console.log(ans[0][i], ans[1][i], ans[2][i])
        }
    }
}

var n = +readline(), t = readline().split(" "), p = [], m = [], s = [];
for(i = 0; i < n; i++){
	if(t[i] == "1"){
		p.push(i+1);
	}
	else if(t[i] == "2"){
		m.push(i+1);
	}
	else{
		s.push(i+1);
	}
}

write(Math.min(p.length,m.length,s.length));

if(Math.min(p.length,m.length,s.length) > 0){
	write("\n");
	for(i = 0; i < Math.min(p.length,m.length,s.length); i++){
		write( (i == Math.min(p.length,m.length,s.length)-1) ? (p[i] + " " + m[i] + " " + s[i]) : (p[i] + " " + m[i] + " " + s[i] + "\n") );
	}
}

var x= parseInt(readline());

var arr = readline().split(' ').map(each => parseInt(each));

var ones=[], twos=[], threes=[];
for(var i=0; i<arr.length; i++){
  if(arr[i]===1)
    ones.push(i+1);
  else if(arr[i]===2)
    twos.push(i+1);
  else
    threes.push(i+1);
}

var min = Math.min(ones.length, Math.min(twos.length, threes.length));

print(min);
i=0;

while(min--){
  print(ones[i]+" "+twos[i]+" "+threes[i]);
  i++;
}

var num = parseInt(readline()),
    students = readline().split(' ');

    students.forEach(function(value, i) {
        students[i] = parseInt(value);
    })

    var arrOfTeams = [],
    tempArr = [];

for (var i = 1; i <= num; i++){

    if(students[i - 1] === 1){

        for (var j = 1; j <= num; j++){

            if(students[j - 1] === 2){

                for (var k = 1; k <= num; k++){

                    if(students[k - 1] === 3){
                        arrOfTeams.push([i, j, k].join(' '))
                        students[i - 1] = 0;
                        students[j - 1] = 0;
                        students[k - 1] = 0;
                        break;
                    }

                }
                break;

            }

        }
        continue;
    }
}

print(arrOfTeams.length);

for(var i = 0; i < arrOfTeams.length; i++){
    print(arrOfTeams[i]);
}

var n = parseInt(readline());
var s, skillsInput = readline().split(' ');
var skills = [];
var programmers = [];
var mathematicians = [];
var athletes = [];
var groups = [];

for (var i = 0; i < skillsInput.length ; i++) {
    var skillCursor = parseInt(skillsInput[i]);
    switch (skillCursor) {
        case 1:
            programmers.push(i+1);
            break;
        case 2:
            mathematicians.push(i+1);
            break;
        case 3:
            athletes.push(i+1);
            break;
        default:
            athletes.push(i+1);
            break;
    }
}

for (var j = 0; j < programmers.length && j < mathematicians.length && j < athletes.length; j++) {
    groups.push({ programmer: programmers[j], mathematician: mathematicians[j], athlete: athletes[j] });
}

print(groups.length);

for (i = 0; i < groups.length; i++) {
    print(groups[i].programmer + " " + groups[i].mathematician + " " + groups[i].athlete);
}

  var numberOfStudents = readline();
  var students = readline()
    .split(' ')
    .map(Number);

  var studentsGroupedByStrength = {};
  for (var i = 1; i <= Number(numberOfStudents); i++) {
    var studentStrength = students[i - 1];
    if (!studentsGroupedByStrength.hasOwnProperty(studentStrength)) {
      studentsGroupedByStrength[studentStrength] = [i]
    } else {
      var prevValue = studentsGroupedByStrength[studentStrength];
      prevValue.push(i)
      studentsGroupedByStrength[studentStrength] = prevValue
    }
  }

  var numberOfTeam = Infinity
  var hasMinimumATeam = true
  for (var i = 1; i <= 3; i++) {
    if (studentsGroupedByStrength[i]) {
      numberOfTeam = Math.min(numberOfTeam, studentsGroupedByStrength[i].length)
    } else {
      hasMinimumATeam = false
    }
  }

  if (!hasMinimumATeam) {
    print(0)
  } else {
    print(numberOfTeam)
    for (var i = 0; i < numberOfTeam; i++) {
      var indexA = studentsGroupedByStrength['1'].pop()
      var indexB = studentsGroupedByStrength['2'].pop()
      var indexC = studentsGroupedByStrength['3'].pop()
      print(indexA + ' ' + indexB + ' ' + indexC)
    }
  }

var numberOfStudents = readline();
  var students = readline()
    .split(' ')
    .map(Number);

  var first = [];
  var second = [];
  var third = [];

  for (var i = 0; i < numberOfStudents; i++) {
    switch (students[i]) {
      case 1:
        first.push(i + 1);
        break;
      case 2:
        second.push(i + 1);
        break;
      case 3:
        third.push(i + 1);
        break;
    }
  }

  var team = Math.min(first.length, second.length, third.length)

  print(team)
  for (var i = 0; i < team; i++) {
    print(first.pop() + ' ' + second.pop() + ' ' + third.pop())
  }

var Team=function(){
	  this.team = [];

}
Team.prototype.print=function(){
	print(this.team.join(' '));
}
Team.prototype.setMember=function(i,v){
	this.team[i]=v;
}
var n = parseInt(readline().trim());

var t = readline().trim().split(' ').map((x)=>parseInt(x));
var t1=[],t2=[],t3=[];
for (var i = 0; i < n; i++) {
	switch(t[i]){
		case 1:
			t1.push(i+1);
		break;
		case 2:
			t2.push(i+1);
		break;
		case 3:
			t3.push(i+1);
		break;
	}
}
var ans = 0;
var teams = [];
while(t1.length>0 && t2.length>0 && t3.length){
	var _t = new Team();
	_t.setMember(0,t1.pop());
	_t.setMember(1,t2.pop());
	_t.setMember(2,t3.pop());
	teams.push(_t);
	ans++;
}
print(ans);
for (var i in teams) {
	teams[i].print();
}

///////////////////////////////////////////////////////////////////////////////
function readNumber () { return Number(readline()); }
function readNumbersArray () { return readline().split(' ').map(Number); }
function algebraicSum (startValue, finishValue, size) { return (startValue + finishValue) * size / 2; }
///////////////////////////////////////////////////////////////////////////////

var n = readNumber();
var t = readNumbersArray();

var prog = 0;
var mat = 0;
var fiz = 0;

t.forEach(function (v) {
	if (v === 1) prog++;
	if (v === 2) mat++;
	if (v === 3) fiz++;
});

var min = Math.min.apply(null, [prog, mat, fiz]);
print(min);

if (min > 0) {
	var prog_index = t.indexOf(1) + 1;
	var mat_index = t.indexOf(2) + 1;
	var fiz_index = t.indexOf(3) + 1;

	for (var i = 0; i < min; i++) {
		print([prog_index, mat_index, fiz_index].join(' '));
		prog_index = t.indexOf(1, prog_index) + 1;
		mat_index = t.indexOf(2, mat_index) + 1;
		fiz_index = t.indexOf(3, fiz_index) + 1;
	}
}

'use strict'
String.prototype.getNumArray = function () {
  return String(this).split(' ').map(function (value) {
    return parseInt(value);
  });
}
readline();
let students = readline().getNumArray();
let dictionary = {
  1: [],
  2: [],
  3: [],
};

for (let i = 0; i < students.length; i++) {
  dictionary[students[i]].push(i+1);
}

let min = dictionary[1].length;

if (dictionary[2].length < min) {
  min = dictionary[2].length;
}

if (dictionary[3].length < min) {
  min = dictionary[3].length;
}
write(min + '\n');

for (let i = 0; i < min; i++) {
  write(dictionary[1][i] + ' ' + dictionary[2][i] + ' ' + dictionary[3][i] + '\n');
}

var r = readline();
var t= readline().split(' ').map(Number).reduce((a,c,i)=>{
    a[c].push(i+1)
    return a;
}, { 1:[], 2:[], 3:[] });

var min = Math.min(t[1].length, t[2].length, t[3].length);
	print(min);
	for (var i=0; i<min; i++){
		print(t[1][i],t[2][i],t[3][i]);
	}

"use strict";

var main = function() {
    var n = +rd();
    var T = [null].concat(rdAr());

    var S = new Array(4).fill(null).map(() => []);
    for (var i = 1; i < T.length; ++i) {
        S[T[i]].push(i);
    }
    S.shift();

    var r = Math.min(...S.map(v => v.length));
    pr(r);

    for (var i = 0; i < r; ++i) {
        prAr(S.map(v => v[i]));
    }
};

var rd = readline;
var wr = write;
var pr = print;
var rdAr = () => rd().split(' ').map(v => +v);
var prAr = (a) => pr(a.join(' '));
var cmpLt = (a, b) => a - b;
var cmpGt = (a, b) => b - a;

main();

n=Number(readline())

T=readline().split(' ').map(Number).reduce((a,c,i)=>{
    a[c].push(i+1)
    return a;
}, { 1:[], 2:[], 3:[] })
A=Math.min(T[1].length,T[2].length,T[3].length)
print(A)
for (i=0;i<A;++i)
    print(T[1][i],T[2][i],T[3][i])

if (!readline) {
    var _i = 0;
    var readline = function() {
        _i ++;

        switch (_i) {
            case 1: return '7';
            case 2: return '1 3 1 3 2 1 2';
        }
    }

    var write = console.log;
}

var n = +readline();
var t = [];

t[1] = [];
t[2] = [];
t[3] = [];

readline().split(' ').forEach(function(currentValue, index) {
    t[+currentValue].push(index + 1);
});

var k = Math.min(t[1].length, t[2].length, t[3].length);

write(k + '\n');

for (var i = 0; i < k; i ++) {
    write([t[1][i], t[2][i], t[3][i]].join(' ') + '\n');
}

var n = parseInt(readline()),
			childPerTimeMap = {},
			timeMap = {
				'1' : { 'count' : 0, 'mem' : [] },
				'2' : { 'count' : 0, 'mem' : [] },
				'3' : { 'count' : 0, 'mem' : [] }
			},
			times = readline().split(/\s/gi).map(function(t, childNo)	{
				childPerTimeMap[childNo + 1] = t;
				timeMap[t].count++;
				timeMap[t].mem.push(childNo + 1);

				return parseInt(t);
			});

		var minTime = Math.min(timeMap[1].count, timeMap[2].count, timeMap[3].count);

		if(!minTime)	print(0);
		else	{
			print(minTime);

			for(var index = 0; index < minTime; index++)	{
				var members = [];

				members.push(timeMap[1].mem[index]);
				members.push(timeMap[2].mem[index]);
				members.push(timeMap[3].mem[index]);

				print(members.join(' '));
			}
		}

var n = parseInt(readline()),
			timeMap = {
				'1' : { 'count' : 0, 'mem' : [] },
				'2' : { 'count' : 0, 'mem' : [] },
				'3' : { 'count' : 0, 'mem' : [] }
			},
			times = readline().split(/\s/gi).forEach(function(t, childNo)	{
				timeMap[t].count++;
				timeMap[t].mem.push(childNo + 1);
			});

		var minTime = Math.min(timeMap[1].count, timeMap[2].count, timeMap[3].count);

		if(!minTime)	print(0);
		else	{
			print(minTime);

			for(var index = 0; index < minTime; index++)	{
				var members = timeMap[1].mem[index] + ' ' +
				timeMap[2].mem[index] + ' ' +
				timeMap[3].mem[index];

				print(members);
			}
		}

var n = parseInt(readline()),
			timeMap = {
				'1' : { 'count' : 0, 'mem' : [] },
				'2' : { 'count' : 0, 'mem' : [] },
				'3' : { 'count' : 0, 'mem' : [] }
			},
			times = readline().split(/\s/gi).map(function(t, childNo)	{
				timeMap[t].count++;
				timeMap[t].mem.push(childNo + 1);

				return parseInt(t);
			});

		var minTime = Math.min(timeMap[1].count, timeMap[2].count, timeMap[3].count);

		if(!minTime)	print(0);
		else	{
			print(minTime);

			for(var index = 0; index < minTime; index++)	{
				var members = [];

				members.push(timeMap[1].mem[index]);
				members.push(timeMap[2].mem[index]);
				members.push(timeMap[3].mem[index]);

				print(members.join(' '));
			}
		}

var students = parseInt(readline());

var vals = readline().split(" ").map(Number);

var obj = {
    "1": [],
    "2": [],
    "3": []
}

for (var i = 0; i < vals.length; i++ ) {
    obj[+vals[i]].push(i + 1);
}

var total = Math.min(obj["1"].length, obj["2"].length, obj["3"].length);
print(total);

for (var i = 0; i < total; i++) {
    var team = [];
    team.push(obj["1"][i], obj["2"][i], obj["3"][i]);
    print(team.join(" "));
}

const readline = require('readline');

let secondLine = false;

// Create readline Interface
const rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout
});

let inputs = [];

rl.on('line', lineInput => {
    inputs.push(lineInput);
})

// Read Inputs
rl.on('close', () => {
    const children = inputs[0]
    const skills = inputs[1].split(' ');
    let teams = [];
    let prgrammingSkills = [];
    let mathSkills = [];
    let physicsSkills = [];

    if (Math.floor(children / 3) < 1) return console.log(0);

    skills.forEach((skill, i) => {
        if (skill == 1) prgrammingSkills.push({ index: ++i });
        if (skill == 2) mathSkills.push({ index: ++i })
        if (skill == 3) physicsSkills.push({ index: ++i });
    })

    if (prgrammingSkills.length === 0 || mathSkills.length === 0 || physicsSkills.length === 0)
        return console.log(0);

    let estimatedTeams = Math.min(prgrammingSkills.length, mathSkills.length, physicsSkills.length);

    for (let i = 0; i < estimatedTeams; i++) {
        console.log(prgrammingSkills[i].index, mathSkills[i].index, physicsSkills[i].index);
    }

});

'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 readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

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

function write(x) {
    process.stdout.write(x);
}
function min(a,b) {
    if(a > b) return b;
    else return a;
}
function main() {
    let [n] = readint();
    let arr = readint();
    let t = [...arr];
    t.sort((a,b)=> (a - b));
    let ans = 6000;
    let cur = t[0];
    let count = 0;
    t.forEach(element => {
        if(element == cur) count++;
        else {
            cur = element;
            ans = min(ans, count);
            count = 1;
        }
    });
    if(ans == 6000) print(0);
    else {
        print(ans);
        for(let i = 0; i < ans; i++) {
            let j = 3;
            cur = 1;
            while(--j) {
                arr.some((v, i) => {
                    if(v == cur) {
                        write((i + 1) + " ");
                        arr[i] = 0;
                        if(cur == 3)
                            return true;
                        else
                            cur++;
                    }
                });
            }
            console.log();
        }
    }
}

'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 readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

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

function write(x) {
    process.stdout.write(x);
}
function min(a,b) {
    if(a > b) return b;
    else return a;
}
function main() {
    let [n] = readint();
    let arr = readint();
    let t = [...arr];
    t.sort((a,b)=> (a - b));
    let ans = 6000;
    let cur = t[0];
    let count = 0;
    let proper = 0;
    t.forEach(element => {
        if(element == cur) count++;
        else {
            cur = element;
            ans = min(ans, count);
            count = 1;
            proper++;
        }
    });
    if(proper < 2) print(0);
    else {
        print(ans);
        for(let i = 0; i < ans; i++) {
            let j = 3;
            cur = 1;
            while(--j) {
                arr.some((v, i) => {
                    if(v == cur) {
                        write((i + 1) + " ");
                        arr[i] = 0;
                        if(cur == 3)
                            return true;
                        else
                            cur++;
                    }
                });
            }
            console.log();
        }
    }
}

'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 readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

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

function write(x) {
    process.stdout.write(x);
}
function min(a,b) {
    if(a > b) return b;
    else return a;
}
function main() {
    let [n] = readint();
    let arr = readint();
    let t = [...arr];
    t.sort((a,b)=> (a - b));
    let ans = 6000;
    let cur = t[0];
    let count = 0;
    t.forEach(element => {
        if(element == cur) count++;
        else {
            cur = element;
            ans = min(ans, count);
            count = 1;
        }
    });
    if(t[t.length - 1] < 3) print(0);
    else {
        print(ans);
        for(let i = 0; i < ans; i++) {
            let j = 3;
            cur = 1;
            while(--j) {
                arr.some((v, i) => {
                    if(v == cur) {
                        write((i + 1) + " ");
                        arr[i] = 0;
                        if(cur == 3)
                            return true;
                        else
                            cur++;
                    }
                });
            }
            console.log();
        }
    }
}

'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 readint() {
    let line = readline().split(' ').map(function(num) {
        return parseInt(num);
    });
    return line;
}

function readfloat() {
    let line = readline().split(' ').map(function(num) {
        return parseFloat(num);
    });
    return line;
}

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

function write(x) {
    process.stdout.write(x);
}
function min(a,b) {
    if(a > b) return b;
    else return a;
}
function main() {
    let [n] = readint();
    let arr = readint();
    let t = [...arr];
    t.sort((a,b)=> (a - b));
    let ans = 6000;
    let cur = t[0];
    let count = 0;
    let proper = 0;
    t.forEach(element => {
        if(element == cur) count++;
        else {
            cur = element;
            ans = min(ans, count);
            count = 1;
            proper++;
        }
    });
    if(proper < 2) print(0);
    else {
        print(ans);
        for(let i = 0; i < ans; i++) {
            let j = 3;
            cur = 1;
            while(j--) {
                for(let k = 0; k < arr.length; k++) {
                    if(arr[k] == cur) {
                        write((k + 1) + " ");
                        arr[k] = 0;
                        break;
                    }
                }
                cur++;
            }
            console.log();
        }
    }
}

var students = parseInt(readline());

var vals = readline().split(" ").map(Number);

var obj = {
    "1": [],
    "2": [],
    "3": []
}

for (var i = 0; i < vals.length; i++ ) {
    obj[+vals[i]].push(i + 1);
}

var total = Math.max(obj["1"].length, obj["2"].length, obj["3"].length);
print(total);

for (var i = 0; i < total; i++) {
    var team = [];
    team.push(obj["1"][i], obj["2"][i], obj["3"][i]);
    print(team.join(" "));
}

var students = parseInt(readline());

var vals = readline().split(" ").map(Number);

var obj = {
    "1": [],
    "2": [],
    "3": []
}

for (var i = 0; i < vals.length; i++ ) {
    obj[+vals[i]].push(i + 1);
}

var total = Math.max(obj["1"], obj["2"], obj["3"]);
print(total);

for (var i = 0; i < total; i++) {
    var team = [];
    team.push(obj["1"][i], obj["2"][i], obj["3"][i]);
    print(temp.join(" "));
}


Yura is tasked to build a closed fence in shape of an arbitrary non-degenerate simple quadrilateral. He's already got three straight fence segments with known lengths $$$a$$$, $$$b$$$, and $$$c$$$. Now he needs to find out some possible integer length $$$d$$$ of the fourth straight fence segment so that he can build the fence using these four segments. In other words, the fence should have a quadrilateral shape with side lengths equal to $$$a$$$, $$$b$$$, $$$c$$$, and $$$d$$$. Help Yura, find any possible length of the fourth side.A non-degenerate simple quadrilateral is such a quadrilateral that no three of its corners lie on the same line, and it does not cross itself.

The first line contains a single integer $$$t$$$ — the number of test cases ($$$1 \le t \le 1000$$$). The next $$$t$$$ lines describe the test cases. Each line contains three integers $$$a$$$, $$$b$$$, and $$$c$$$ — the lengths of the three fence segments ($$$1 \le a, b, c \le 10^9$$$).

For each test case print a single integer $$$d$$$ — the length of the fourth fence segment that is suitable for building the fence. If there are multiple answers, print any. We can show that an answer always exists.

NoteWe can build a quadrilateral with sides $$$1$$$, $$$2$$$, $$$3$$$, $$$4$$$.We can build a quadrilateral with sides $$$12$$$, $$$34$$$, $$$56$$$, $$$42$$$.

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

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

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

    arr.sort((a, b) => a - b);
    console.log(arr[2] + 1);
  }
}

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

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

function main() {
  let t = +readLine();
  while (t--) {
    const [a, b, c] = readLine()
      .split(" ")
      .map((n) => BigInt(n));

    let ans = '';
    let sum = a + b + c;

    sum = sum - 1n;
    ans += sum;

    console.log(ans)

  }
}

function For(a, b, fn) {
  if (!fn) return For(0, a - 1, b);
  let res;
  for (let i = a; i <= b; i++) {
    if ((res = fn(i)) != null) return res;
  }
}
function ForR(a, b, fn) {
  if (!fn) return ForR(a - 1, 0, b);
  let res;
  for (let i = a; i >= b; i--) {
    if ((res = fn(i)) != null) return res;
  }
}

function Arr(a, b, fn) {
  if (typeof (b) == 'function') return Arr(0, a - 1, b);
  if (b < a) return [];
  let arr = Array(b - a + 1)
  for (let i = a; i <= b; i++) arr[i] = fn(i, arr);
  return arr;
}

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 ? fn(v) : v).reduce((p, v) => {
    p[v[0]] = v[1];
    return p;
  }, {})
}
Array.prototype.min = function (fn) {
  let min = 1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x < min) { min = x; index = i }
  }
  return [this[index], index, min];
}
Array.prototype.max = function (fn) {
  let max = -1e20, index = -1, x;
  for (let i = 0; i < this.length; i++) {
    x = fn ? fn(this[i], i, this) : this[i];
    if (x > max) { max = x; index = i }
  }
  return [this[index], index, max];
}
Array.prototype.rev = function (first, last) {
  for (let i = first; i < (first + last) / 2; i++) {
    [this[i], this[last - 1 - i + first]] = [this[last - 1 - i + first], this[i]]
  }
}
Array.prototype.set = function (pos, arr) {
  for (let i = pos; i < pos + arr.length; i++) {
    this[i] = arr[i - pos];
  }
}
Array.prototype.for = function (a, b, fn) {
  let res
  for (let i = a; i <= b; i++) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.forR = function (a, b, fn) {
  let res
  for (let i = a; i >= b; i--) {
    if ((res = fn(this[i], i, this)) != null) return res;
  }
}
Array.prototype.bin = function (comp, a, b) {
  let mid;
  while (a < b) {
    mid = (a + b) / 2 | 0;
    if (typeof comp == 'function' ? comp(this[mid]) : this[mid] < comp) a = mid + 1;
    else b = mid;
  }
  return a;
}
Array.prototype.cut = function (fn, a, b) {
  let arr = [];
  let sub = [];
  a = a || 0;
  b = b || (this.length - 1);
  for (let i = a; i <= b; i++) {
    sub.push(this[i])
    if (fn(this[i], i, this)) {
      arr.push(sub);
      sub = [];
    }
  }
  return arr;
}

function gcd(a, b) {
  while (b) [a, b] = [b, a % b];
  return a;
}
function mul(a, b, m) {
  return ((a >> 16) * b % m * 65536 + (a & 65535) * b) % m
}
function pow(a, n, m) {
  let r = 1;
  while (n) n & 1 ? (r = mul(r, a, m), n--) : [a, n] = [mul(a, a, m), n >> 1]
  return r;
}
let MOD = 998244353
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);
  return (u + MOD) % MOD;
}

// let gt = Arr(n, (i, a) => i == 0 ? 1 : mul(a[i - 1], i, MOD));
// let rgt = Arr(n, (i, a) => i <= 1 ? 1 : MOD - mul((MOD / i | 0), a[998244353 % i], MOD));
// For(2, n - 1, i => { rgt[i] = mul(rgt[i], rgt[i - 1], MOD) });
// let nCk = (n, k) => mul(mul(gt[n], rgt[k], MOD), rgt[n - k], MOD);

// for (i = pos; i <= n; i += i & -i) fen[i]++; // start from index 1
// for (i = pos; i; i -= i & -i) ans += fen[i];

// let p = [2];
// for (let i = 3; i < 1e5; i += 2) {
//   let j, x = Math.sqrt(i);
//   for (j = 0; p[j] <= x; j++) if (i % p[j] == 0) break;
//   if (i % p[j] != 0) p.push(i);
// }

// let root = x => par[x] < 0 ? x : (par[x] = root(par[x]));
// let dsu = (x, y) => {
//   if ((x = root(x)) == (y = root(y))) return;
//   if (par[y] < par[x]) [x, y] = [y, x];
//   par[x] += par[y];
//   par[y] = x;
// }

let input = '';
process.stdin.on('data', c => input += c);
process.stdin.on('end', main);
function main() {
  let inp = input.split(/\s+/).map(v => +v), _i = 0, $ = n => n != null ? inp.slice(_i, _i += n) : inp[_i++],
    out = [], log = console.log, asc = (a, b) => a - b, desc = (a, b) => b - a, min = Math.min, max = Math.max, abs = Math.abs;
  let t = $()
  while (t--) {
    let a = $(3).sort(asc)
    log(a.sum()-1)
  }
}

// https://codeforces.com/problemset/problem/1422/A

const readline = require('readline');

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

let data = [];
rl.on('line', (input) => {
   data.push(input);
});

rl.on('close', () => {
   solve(data);
});

function solve(data) {

   for (let i = 1; i < data.length; i++) {
      [a, b, c] = data[i].split(" ").map((x) => parseInt(x));

      // Assume a, b, c are the shortest sides
      // The sum of the lengths of the shortest three sides of a quadrilateral must be longer than the longest side.

      console.log(a + b + c - 1);

   }

}

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

    var ans = "";
    var sum = a + b + c;
    sum = sum - 1n;
    ans += sum;
    console.log(ans);
  }
}

var ti = parseInt(readline());
while(ti-- > 0) {
  var a = readline().split(' ').map(x => parseInt(x));
  print(Math.max(...a));
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

function comp(a, b) {
        return a - b > 0 ? -1 : 1
}
while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort(comp);
        print(arr[0] + arr[2] - arr[1]);
}

var tc = parseInt(readline()),
    arr,
    a,
    b,
    c,
    x,
    y;

while (tc > 0) {
    arr = readline().split(' ');
    a = parseInt(arr[0]);
    b = parseInt(arr[1]);
    c = parseInt(arr[2]);

    x = Math.sqrt(a * a + (b - c) * (b - c));
    y = Math.sqrt(a * a + (b + c) * (b + c));

    print(Math.ceil(x + 1e-9));

    tc--;
}

var tc = parseInt(readline());
while(tc--){
    var A1 = readline().split(' ').map(x => parseInt(x));

    var total = A1.reduce((t, a)=> t+a, 0);
    print(total-1);
}

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

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

function main() {
  let t = +readLine();
  while (t--) {
    const [a, b, c] = readLine()
      .split(" ")
      .map((n) => parseInt(n));

    console.log(b);
  }
}

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

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

function main() {
  let t = +readLine();
  while (t--) {
    const [a, b, c] = readLine()
      .split(" ")
      .map((n) => BigInt(n));

    let ans = "";
    const sum = a + b + c;

    for (let i = 1; i < 1e5; i++) {
      if (sum > i && BigInt(i) !== a && BigInt(i) !== b && BigInt(i) !== c) {
        ans += BigInt(i);
        console.log(ans);
        break;
      }
    }
  }
}

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

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

function main() {
  let t = +readLine();
  while (t--) {
    const [a, b, c] = readLine()
      .split(" ")
      .map((n) => BigInt(n));

    let ans = "";
    const sum = a + b + c;

    ans += sum - a;
    console.log(ans);
  }
}

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

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

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

    arr.sort((a, b) => a - b);
    console.log(arr[1]);
  }
}

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

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

function main() {
  let t = +readLine();
  while (t--) {
    const [a, b, c] = readLine()
      .split(" ")
      .map((n) => BigInt(n));

    let ans = "";
    const sum = a + b + c;

    for (let i = 1; i < 1e5; i++) {
      if (sum > i) {
        ans += i;
        console.log(ans);
        break;
      }
    }
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  while (T--) {
    var value = readLine().split(" ").map(Number);
    var a = value[0],
      b = value[1],
      c = value[2],
      d;
    d = Math.pow(a, 2) + Math.pow(c, 2) - Math.pow(b, 2);
    // console.log(BigInt(d))
    console.log(BigInt(Math.floor(Math.sqrt(Math.abs(d)))));
  }
}

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

    var ans = "";
    var sum = c + 1n;
    sum += ans;
    console.log(sum);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  while (T--) {
    var value = readLine().split(" ").map(Number);
    var a = value[0],
      b = value[1],
      c = value[2],
      d;
    d = Math.pow(a, 2) + Math.pow(c, 2) - Math.pow(b, 2);
    if (a > 100000000 || b > 100000000 || c > 100000000) {
      console.log(BigInt(Math.floor(Math.sqrt(Math.abs(d)))));
    }
    console.log(Math.floor(Math.sqrt(Math.abs(d))));
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  while (T--) {
    var value = readLine().split(" ").map(Number);
    var a = value[0],
      b = value[1],
      c = value[2],
      d;
    d = Math.pow(a, 2) + Math.pow(c, 2) - Math.pow(b, 2);
    console.log(Math.floor(Math.sqrt(d)));
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  while (T--) {
    var value = readLine().split(" ").map(Number);
    var a = value[0],
      b = value[1],
      c = value[2],
      d;
    d = Math.pow(a, 2) + Math.pow(c, 2) - Math.pow(b, 2);
    console.log(Math.floor(Math.pow(d, 0.5)));
  }
}

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

    var ans = "";
    var sum = c - 1n;
    sum += ans;
    console.log(sum);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  var T = +readLine();
  while (T--) {
    var value = readLine().split(" ").map(Number);
    var a = value[0],
      b = value[1],
      c = value[2],
      d;
    d = Math.pow(a, 2) + Math.pow(c, 2) - Math.pow(b, 2);
    if (a > 100000000 || b > 100000000 || c > 100000000) {
      console.log(parseInt(BigInt(Math.floor(Math.sqrt(Math.abs(d))))));
    }
    console.log(Math.floor(Math.sqrt(Math.abs(d))));
  }
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print(arr[0] + arr[2]);
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print((arr[2] + arr[1] + 1) / 2 + 1);
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print(parseInt((arr[2] + arr[1] + 1) / 2 + 1));
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print(arr[0] + arr[1]);
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print(arr[1] + arr[3]);
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

function comp(a, b) {
        return a - b > 0 ? -1 : 1
}
while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print(arr[1] + arr[3]);
}

var n = parseInt(readline());

function trans(v) {
        return parseInt(v);
}

while(n--) {
        var arr = readline().split(' ').map(trans);
        arr.sort();
        print(arr[2] + arr[0] - arr[1] );
}


You are given a string $$$s$$$ consisting of $$$n$$$ lowercase Latin letters. $$$n$$$ is even.For each position $$$i$$$ ($$$1 \le i \le n$$$) in string $$$s$$$ you are required to change the letter on this position either to the previous letter in alphabetic order or to the next one (letters 'a' and 'z' have only one of these options). Letter in every position must be changed exactly once.For example, letter 'p' should be changed either to 'o' or to 'q', letter 'a' should be changed to 'b' and letter 'z' should be changed to 'y'.That way string "codeforces", for example, can be changed to "dpedepqbft" ('c' $$$\rightarrow$$$ 'd', 'o' $$$\rightarrow$$$ 'p', 'd' $$$\rightarrow$$$ 'e', 'e' $$$\rightarrow$$$ 'd', 'f' $$$\rightarrow$$$ 'e', 'o' $$$\rightarrow$$$ 'p', 'r' $$$\rightarrow$$$ 'q', 'c' $$$\rightarrow$$$ 'b', 'e' $$$\rightarrow$$$ 'f', 's' $$$\rightarrow$$$ 't').String $$$s$$$ is called a palindrome if it reads the same from left to right and from right to left. For example, strings "abba" and "zz" are palindromes and strings "abca" and "zy" are not.Your goal is to check if it's possible to make string $$$s$$$ a palindrome by applying the aforementioned changes to every position. Print "YES" if string $$$s$$$ can be transformed to a palindrome and "NO" otherwise.Each testcase contains several strings, for each of them you are required to solve the problem separately.

The first line contains a single integer $$$T$$$ ($$$1 \le T \le 50$$$) — the number of strings in a testcase. Then $$$2T$$$ lines follow — lines $$$(2i - 1)$$$ and $$$2i$$$ of them describe the $$$i$$$-th string. The first line of the pair contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$, $$$n$$$ is even) — the length of the corresponding string. The second line of the pair contains a string $$$s$$$, consisting of $$$n$$$ lowercase Latin letters.

Print $$$T$$$ lines. The $$$i$$$-th line should contain the answer to the $$$i$$$-th string of the input. Print "YES" if it's possible to make the $$$i$$$-th string a palindrome by applying the aforementioned changes to every position. Print "NO" otherwise.

NoteThe first string of the example can be changed to "bcbbcb", two leftmost letters and two rightmost letters got changed to the next letters, two middle letters got changed to the previous letters.The second string can be changed to "be", "bg", "de", "dg", but none of these resulting strings are palindromes.The third string can be changed to "beeb" which is a palindrome.The fifth string can be changed to "lk", "lm", "nk", "nm", but none of these resulting strings are palindromes. Also note that no letter can remain the same, so you can't obtain strings "ll" or "mm".

function main() {
  const is = new Scanner();
  let n, word, possible, container = {};
  for (let i = 'a'.charCodeAt(); i <= 'z'.charCodeAt(); i += 1)
    container[String.fromCharCode(i)] = 0;

  for (let t = is.nextInt(); t > 0; t -= 1) {
    n = is.nextInt();
    word = is.nextLine();
    for (let i = 0; i < n / 2; i += 1) {

      for (var letter in container) {
        if (container.hasOwnProperty(letter)) {
          container[letter] = 0;
        }
      }

      if (word[i] === 'a') {
        container.b += 1;
      } else if (word[i] === 'z') {
        container.y += 1;
      } else {
        container[String.fromCharCode(word[i].charCodeAt() + 1)] += 1;
        container[String.fromCharCode(word[i].charCodeAt() - 1)] += 1;
      }

      if (word[n - i - 1] === 'a') {
        container.b += 1;
      } else if (word[n - i - 1] === 'z') {
        container.y += 1;
      } else {
        container[String.fromCharCode(word[n - i - 1].charCodeAt() + 1)] += 1;
        container[String.fromCharCode(word[n - i - 1].charCodeAt() - 1)] += 1;
      }

      possible = false;
      for (var letter in container) {
        if (container.hasOwnProperty(letter)) {
          if (container[letter] >= 2) {
            possible = true;
            break;
          }
        }
      }

      if (!possible)
        break;
    }

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

/*
 *  Api Scanner
 */
class Scanner {
  constructor() {
    this.index = -1;
    this.lines = stdinInput.trim().split('\n'); // eslint-disable-line
  }

  nextLine() {
    this.index += 1;
    return this.lines[this.index].trim();
  }

  nextInt() {
    return parseInt(this.nextLine(), 10);
  }

  nextDouble() {
    return parseFloat(this.nextLine());
  }

  nextArray(fn) {
    const array = this.nextLine().split(' ');
    return fn === String ? array : array.map(fn);
  }

  hasNext() {
    return this.index < this.lines.length;
  }
}

let stdinInput = '';
process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', (input) => { stdinInput += input; });
process.stdin.on('end', () => { main(); });

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', () => {
  let t = nextInt();
  while (t--) {
    nextInt();
    console.log(checkPalindromicTwist(nextString()));
  }
});

function nextInt() {
  return Number(lines.shift());
}

function nextString() {
  return lines.shift();
}

function same(char1, char2) {
  const a = char1[0].charCodeAt(0);
  const b = char2[0].charCodeAt(0);

  if (a === b) {
    return true;
  }

  return Math.abs(a - b) === 2;
}

function checkPalindromicTwist(str) {
  for (let i = 0; i < str.length; i++) {
    if (!same(str[i], str[str.length - 1 - i])) {
      return 'NO';
    }
  }
  return 'YES';
}

module.exports = checkPalindromicTwist;

var line = '';

/** @param {string} s */
function checkPalindrome(s)  {
    for(var i = 0; i < s.length >> 1; i++) {
        var frontChar = s[i],
            backChar = s[s.length - i - 1];

        if(backChar !== frontChar)  {
            switch(frontChar) {
                case 'a':
                    if(backChar !== 'c')  return false;
                    break;
                case 'z':
                    if(backChar !== 'x')  return false;
                    break;
                default:
                    if(Math.abs(backChar.charCodeAt(0) - frontChar.charCodeAt(0)) !== 2) return false;
                    break;
            }
        }
    }

    return true;
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += (input.trim() + '\n');
});

process.stdin.on('end', function () {
    line = line.split(/\n/).map(l => l.replace(/\r/, ''));

    for(var i = 0; i < Number(line[0]); i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

/** @type {{[x: string]: number}} */
var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

/** @param {string} s */
function checkPalindrome(s)  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            if(backChar !== frontChar)  {
                switch(frontChar) {
                    case 'a':
                        if(backChar !== 'c')  return false;
                        break;
                    case 'z':
                        if(backChar !== 'x')  return false;
                        break;
                    default:
                        if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                        break;
                }
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/).map(l => l.replace(/\r/, ''));
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

/** @param {string} s */
function checkPalindrome(s)  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length);

    for(var i in front) {
        var frontChar = front[i],
            backChar = back[front.length - i - 1],
            frontCharCode = frontChar.charCodeAt(0),
            backCharCode = backChar.charCodeAt(0);

        if(backChar !== frontChar)  {
            switch(frontChar) {
                case 'a':
                    if(backChar !== 'c')  return false;
                    break;
                case 'z':
                    if(backChar !== 'x')  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }
    }

    return true;
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/).map(l => l.replace(/\r/, ''));
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var tests = parseInt(readline());

while(tests--) {
    readline();
    var s = readline();
    solver(s);
}

function solver(s){
    var l = s.length, h = l / 2;

    while(--h > -1) {
        if(![0, 2].includes(Math.abs(s.charCodeAt(h) - s.charCodeAt(l - h - 1)))) {
            print("NO");
            return false;
        }
    }

    print("YES");
    return true;
}

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

function checkPalindrome(s = '')  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            switch(frontChar) {
                case 'a':
                case 'z':
                    if(backCharCode !== frontCharCode)  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/);
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

function checkPalindrome(s = '')  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            switch(frontChar) {
                case 'a':
                case 'z':
                    if(backCharCode !== frontCharCode)  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    console.log(line);
    line = line.split(/\n/);
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

function checkPalindrome(s = '')  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            switch(frontChar) {
                case 'a':
                case 'z':
                    if(backCharCode !== frontCharCode)  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/).map(l => l.replace(/\r/, ''));
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

/** @type {{[x: string]: number}} */
var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

/** @param {string} s */
function checkPalindrome(s)  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            switch(frontChar) {
                case 'a':
                    if(backChar !== frontChar && backChar !== 'c')  return false;
                    break;
                case 'z':
                    if(backChar !== frontChar && backChar !== 'x')  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/).map(l => l.replace(/\r/, ''));
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

function checkPalindrome(s = '')  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            switch(frontChar) {
                case 'a':
                case 'z':
                    if(backCharCode !== frontCharCode)  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/);
    console.log(line);
    var n = Number(line[0]);

    for(var i = 0; i < n; i++)  {
        console.log(checkPalindrome(line[(i + 1) * 2]) ? 'YES' : 'NO');
    }

    process.exit(0);
});

var line = '';

var A = 'a'.charCodeAt(0);
var Z = 'z'.charCodeAt(0);

var m = {};

for(var i = A; i <= Z; i++) {
    m[String.fromCharCode(i)] = i;
}

function checkPalindrome(s = '')  {
    var front = s.slice(0, s.length >> 1),
        back = s.slice(s.length - front.length).split('').reverse().join('');

    if(front === back) {
        return true;
    } else {
        for(var i in front) {
            var frontChar = front[i],
                backChar = back[i],
                frontCharCode = m[frontChar],
                backCharCode = m[backChar];

            switch(frontChar) {
                case 'a':
                case 'z':
                    if(backCharCode !== frontCharCode)  return false;
                    break;
                default:
                    if(Math.abs(backCharCode - frontCharCode) !== 2) return false;
                    break;
            }
        }

        return true;
    }
}

process.stdin.resume();
process.stdin.setEncoding('utf-8');
process.stdin.on('data', function(input) {
  line += `${input.trim()}\n`;
});

process.stdin.on('end', function () {
    line = line.split(/\n/);

    for(var i = 1; i <= Number(line[0]); i*=2)  {
        console.log(checkPalindrome(line[i + 1]) ? 'YES' : 'NO');
    }

    process.exit(0);
});


You have an array a with length n, you can perform operations. Each operation is like this: choose two adjacent elements from a, say x and y, and replace one of them with gcd(x, y), where gcd denotes the greatest common divisor.What is the minimum number of operations you need to make all of the elements equal to 1?

The first line of the input contains one integer n (1 ≤ n ≤ 2000) — the number of elements in the array. The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the elements of the array.

Print -1, if it is impossible to turn all numbers to 1. Otherwise, print the minimum number of operations needed to make all numbers equal to 1.

NoteIn the first sample you can turn all numbers to 1 using the following 5 moves:  [2, 2, 3, 4, 6].  [2, 1, 3, 4, 6]  [2, 1, 3, 1, 6]  [2, 1, 1, 1, 6]  [1, 1, 1, 1, 6]  [1, 1, 1, 1, 1] We can prove that in this case it is not possible to make all numbers one using less than 5 moves.

var n = +readline();
var a = readline().split(" ").map(Number);
print(solve());

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

function solve() {
  var cnt = 0
  for (var i = 0; i < n; i++)
    if (a[i] != 1)
      cnt++;
  if (cnt < n)
    return cnt;
  var g = a[0];
  for (var i = 0; i < n; i++)
    g = gcd(g, a[i]);
  if (g > 1)
    return -1;
  var ret = n;
  for (var i = 0; i < n; i++) {
    g = a[i];
    for (var j = i; j < n; j++) {
      g = gcd(g, a[j]);
      if (g == 1) {
        ret = Math.min(ret, j - i + 1);
        break;
      }
    }
  }
  return ret - 1 + n - 1;
}