Two semifinals have just been in the running tournament. Each semifinal had n participants. There are n participants advancing to the finals, they are chosen as follows: from each semifinal, we choose k people (0 ≤ 2k ≤ n) who showed the best result in their semifinals and all other places in the finals go to the people who haven't ranked in the top k in their semifinal but got to the n - 2k of the best among the others.The tournament organizers hasn't yet determined the k value, so the participants want to know who else has any chance to get to the finals and who can go home.

The first line contains a single integer n (1 ≤ n ≤ 105) — the number of participants in each semifinal. Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 109) — the results of the i-th participant (the number of milliseconds he needs to cover the semifinals distance) of the first and second semifinals, correspondingly. All results are distinct. Sequences a1, a2, ..., an and b1, b2, ..., bn are sorted in ascending order, i.e. in the order the participants finished in the corresponding semifinal.

Print two strings consisting of n characters, each equals either "0" or "1". The first line should correspond to the participants of the first semifinal, the second line should correspond to the participants of the second semifinal. The i-th character in the j-th line should equal "1" if the i-th participant of the j-th semifinal has any chances to advance to the finals, otherwise it should equal a "0".

NoteConsider the first sample. Each semifinal has 4 participants. The results of the first semifinal are 9840, 9860, 9930, 10040. The results of the second semifinal are 9920, 9980, 10020, 10090.  If k = 0, the finalists are determined by the time only, so players 9840, 9860, 9920 and 9930 advance to the finals.  If k = 1, the winners from both semifinals move to the finals (with results 9840 and 9920), and the other places are determined by the time (these places go to the sportsmen who run the distance in 9860 and 9930 milliseconds).  If k = 2, then first and second places advance from each seminfial, these are participants with results 9840, 9860, 9920 and 9980 milliseconds.

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]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var semiSize = integers[0], quarterSize = semiSize/2, size = 2*semiSize;

	var records = [], feasible = [[], []];

	for (var rank = 0; rank < semiSize; rank += 1) {
		var integers = tokenizeIntegers(readline());
		for (var round = 0; round < 2; round += 1) {
			records.push([integers[round], round, rank]);
			feasible[round].push(rank+1 <= quarterSize ? '1' : '0');
		}
	}

	records.sort(function(a, b) {
		return a[0] - b[0];
	});

	for (var rank = 0; rank < semiSize; rank += 1) {
		var record = records[rank];
		feasible[record[1]][record[2]] = '1';
	}

	print(feasible[0].join(''));
	print(feasible[1].join(''));

}

main();

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

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

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

function main() {
	var integers = tokenizeIntegers(readline());
	var semiSize = integers[0], quarterSize = semiSize/2, size = 2*semiSize;

	var records = [], feasible = [[], []];

	for (var rank = 0; rank < semiSize; rank += 1) {
		var integers = tokenizeIntegers(readline());
		for (var round = 0; round < 2; round += 1) {
			records.push({score: integers[round], round: round, rank: rank});
			feasible[round].push(rank+1 <= quarterSize ? '1' : '0');
		}
	}

	records.sort(function(a, b) {
		return a.score - b.score;
	});

	for (var rank = 0; rank < semiSize; rank += 1) {
		var record = records[rank];
		feasible[record.round][record.rank] = '1';
	}

	print(feasible[0].join(''));
	print(feasible[1].join(''));

}

main();

    var n = parseInt(readline());
    var a = [], b = [], au = [], bu =[];
    for(var i=0; i<n; i++)
    {
        var str = readline().split(' ');
        a.push(str[0]);
        b.push(str[1]);
        au.push('0');
        bu.push('0');
    }
    var ap= 0, bp= 0, place=0;
    while(ap<n && bp<n)
    {
        if(bp==n || Math.min(a[ap],b[bp])==a[ap])
        {
            a[ap]=place;
            ap++;
            place++;
        }
        else if(ap==n || Math.min(a[ap],b[bp])==b[bp])
        {
            b[bp]=place;
            bp++;
            place++;
        }
    }
    for(var i=0; i<n; i++)
    {
        if((i+1)*2<=n || a[i]<n) au[i]='1';
        if((i+1)*2<=n || b[i]<n) bu[i]='1';
    }

    print(au.join(''));
    print(bu.join(''));

// require('./config');

var line = readline();

var i, j;
var n = Number(line);
var a = [];
var b = [];
for (i = 0; i < n; i++) {
    line = readline().split(' ');
    a.push(Number(line[0]));
    b.push(Number(line[1]));
}

var r1 = [];
var r2 = [];
for (i = 0; i < n; i++) {
    if (i < (n - 1)/2) {
        r1[i] = 1;
        r2[i] = 1;
    } else {
        r1[i] = 0;
        r2[i] = 0;
    }
}
var count = 0;
i = 0;
j = 0;

while (count < n) {
    if (a[i] < b[j]) {
        r1[i] = 1;
        i++;
    } else {
        r2[j] = 1;
        j++
    }
    count++;
}

print(r1.join(''));
print(r2.join(''));

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]);
	};
	return tokens;
}

function main() {
	var integers = tokenizeIntegers(readline());
	var semiSize = integers[0], quarterSize = semiSize/2, size = 2*semiSize;

	var records = [], feasible = [[], []];

	for (var rank = 0; rank < semiSize; rank += 1) {
		var integers = tokenizeIntegers(readline());
		for (var round = 0; round < 2; round += 1) {
			records.push({score: integers[round], round: round, rank: rank});
			feasible[round].push(rank < quarterSize ? '1' : '0');
		}
	}

	records.sort(function(a, b) {
		return a.score - b.score;
	});

	for (var rank = 0; rank < semiSize; rank += 1) {
		var record = records[rank];
		feasible[record.round][record.rank] = '1';
	}

	print(feasible[0].join(''));
	print(feasible[1].join(''));

}

main();

// require('./config');

var line = readline();

var i, j;
var n = Number(line);
var a = [];
var b = [];
for (i = 0; i < n; i++) {
    line = readline().split(' ');
    a.push(line[0]);
    b.push(line[1]);
}

var r1 = [];
var r2 = [];
for (i = 0; i < n; i++) {
    if (i < (n - 1)/2) {
        r1[i] = 1;
        r2[i] = 1;
    } else {
        r1[i] = 0;
        r2[i] = 0;
    }
}
var count = 0;
i = 0;
j = 0;

while (count < n - 1) {
    if (a[i] < b[j]) {
        r1[i] = 1;
        i++;
    } else {
        r2[j] = 1;
        j++
    }
    count++;
}

print(r1.join(''));
print(r2.join(''));


One night, Mark realized that there is an essay due tomorrow. He hasn't written anything yet, so Mark decided to randomly copy-paste substrings from the prompt to make the essay.More formally, the prompt is a string $$$s$$$ of initial length $$$n$$$. Mark will perform the copy-pasting operation $$$c$$$ times. Each operation is described by two integers $$$l$$$ and $$$r$$$, which means that Mark will append letters $$$s_l s_{l+1} \ldots s_r$$$ to the end of string $$$s$$$. Note that the length of $$$s$$$ increases after this operation.Of course, Mark needs to be able to see what has been written. After copying, Mark will ask $$$q$$$ queries: given an integer $$$k$$$, determine the $$$k$$$-th letter of the final string $$$s$$$.

The first line contains a single integer $$$t$$$ ($$$1\leq t\leq 1000$$$) — the number of test cases. The first line of each test case contains three integers $$$n$$$, $$$c$$$, and $$$q$$$ ($$$1\leq n\leq 2\cdot 10^5$$$, $$$1\leq c\leq 40$$$, and $$$1\leq q\leq 10^4$$$) — the length of the initial string $$$s$$$, the number of copy-pasting operations, and the number of queries, respectively. The second line of each test case contains a single string $$$s$$$ of length $$$n$$$. It is guaranteed that $$$s$$$ only contains lowercase English letters. The following $$$c$$$ lines describe the copy-pasting operation. Each line contains two integers $$$l$$$ and $$$r$$$ ($$$1\leq l\leq r\leq 10^{18}$$$). It is also guaranteed that $$$r$$$ does not exceed the current length of $$$s$$$. The last $$$q$$$ lines of each test case describe the queries. Each line contains a single integer $$$k$$$ ($$$1\leq k\leq 10^{18}$$$). It is also guaranteed that $$$k$$$ does not exceed the final length of $$$s$$$. It is guaranteed that the sum of $$$n$$$ and $$$q$$$ across all test cases does not exceed $$$2\cdot 10^5$$$ and $$$10^4$$$, respectively.

For each query, print the $$$k$$$-th letter of the final string $$$s$$$.

NoteIn the first test case, the copy-paste process is as follows.   The first step is pasting string $$$\texttt{mark}$$$ at the end, yielding the string $$$\texttt{mark}\color{red}{\texttt{mark}}$$$.  The second step is pasting string $$$\texttt{mar}$$$ at the end, yielding the string $$$\texttt{markmark}\color{red}{\texttt{mar}}$$$.  The third step is pasting string $$$\texttt{rkmark}$$$ at the end, yielding the string $$$\texttt{markmarkmar}\color{red}{\texttt{rkmark}}$$$. In the second test case, the copy-paste process is as follows.   The first step is pasting string $$$\texttt{re}$$$ at the end, yielding the string $$$\texttt{creamii}\color{red}{\texttt{re}}$$$.  The second step is pasting string $$$\texttt{ea}$$$ at the end, yielding the string $$$\texttt{creamiire}\color{red}{\texttt{ea}}$$$.  The third step is pasting string $$$\texttt{reamiire}$$$ at the end, yielding the string $$$\texttt{creamiireea}\color{red}{\texttt{reamiire}}$$$.

"use strict";
const fs = require("fs");
//let filename = "0.txt";
let filename = 0;
const input = fs.readFileSync(filename, "utf8").trim().split("\n");
let line = 0;
function readline() {
  return input[line++];
}
const solve = () => {
  let t = parseInt(readline());
  while (t--) {
    let [n, c, q] = readline()
      .trim()
      .split(" ")
      .map((cur) => parseInt(cur));
    let str = readline().trim();
    let len = [],
      l = [];
    len.push(BigInt(n));
    for (let i = 0; i < c; i++) {
      l.push(
        readline()
          .trim()
          .split(" ")
          .map((cur) => BigInt(cur))
      );
      len[i + 1] = len[i] + l[i][1] - l[i][0] + 1n;
    }
    while (q--) {
      let k = BigInt(readline());
      for (let i = c - 1; i >= 0; i--) {
        if (k > len[i]) {
          k = l[i][0] + (k - len[i] - 1n);
        }
      }
      console.log(str[Number(k - 1n)]);
    }
  }
};
solve();


The map of the capital of Berland can be viewed on the infinite coordinate plane. Each point with integer coordinates contains a building, and there are streets connecting every building to four neighbouring buildings. All streets are parallel to the coordinate axes.The main school of the capital is located in $$$(s_x, s_y)$$$. There are $$$n$$$ students attending this school, the $$$i$$$-th of them lives in the house located in $$$(x_i, y_i)$$$. It is possible that some students live in the same house, but no student lives in $$$(s_x, s_y)$$$.After classes end, each student walks from the school to his house along one of the shortest paths. So the distance the $$$i$$$-th student goes from the school to his house is $$$|s_x - x_i| + |s_y - y_i|$$$.The Provision Department of Berland has decided to open a shawarma tent somewhere in the capital (at some point with integer coordinates). It is considered that the $$$i$$$-th student will buy a shawarma if at least one of the shortest paths from the school to the $$$i$$$-th student's house goes through the point where the shawarma tent is located. It is forbidden to place the shawarma tent at the point where the school is located, but the coordinates of the shawarma tent may coincide with the coordinates of the house of some student (or even multiple students).You want to find the maximum possible number of students buying shawarma and the optimal location for the tent itself.

The first line contains three integers $$$n$$$, $$$s_x$$$, $$$s_y$$$ ($$$1 \le n \le 200\,000$$$, $$$0 \le s_x, s_y \le 10^{9}$$$) — the number of students and the coordinates of the school, respectively. Then $$$n$$$ lines follow. The $$$i$$$-th of them contains two integers $$$x_i$$$, $$$y_i$$$ ($$$0 \le x_i, y_i \le 10^{9}$$$) — the location of the house where the $$$i$$$-th student lives. Some locations of houses may coincide, but no student lives in the same location where the school is situated.

The output should consist of two lines. The first of them should contain one integer $$$c$$$ — the maximum number of students that will buy shawarmas at the tent.  The second line should contain two integers $$$p_x$$$ and $$$p_y$$$ — the coordinates where the tent should be located. If there are multiple answers, print any of them. Note that each of $$$p_x$$$ and $$$p_y$$$ should be not less than $$$0$$$ and not greater than $$$10^{9}$$$.

NoteIn the first example, If we build the shawarma tent in $$$(4, 2)$$$, then the students living in $$$(4, 2)$$$, $$$(4, 1)$$$ and $$$(5, 1)$$$ will visit it.In the second example, it is possible to build the shawarma tent in $$$(1, 1)$$$, then both students living in $$$(0, 0)$$$ will visit it.

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const [n, sx, sy] = arr.shift().split(' ').map(a => parseInt(a))

  const students = arr.map(a => a.split(' ').map(a => parseInt(a)))

  // top, bottom, left, right
  const a = [0, 0, 0, 0]

  for(let i = 0; i < n; i++) {
    const s = students[i]
    if(s[0] == sx) {
      if(s[1] > sy) a[0] ++ // top
      else a[1] ++ // bottom
    }
    else if(s[1] == sy) {
      if(s[0] > sx) a[3] ++ // right
      else a[2] ++ // left
    }
    else if(s[0] < sx && s[1] < sy) {
      a[1] ++ // bottom
      a[2] ++ // left
    }
    else if(s[0] > sx && s[1] < sy) {
      a[1] ++ // bottom
      a[3] ++ // right
    }
    else if(s[0] < sx && s[1] > sy) {
      a[0] ++ // top
      a[2] ++ // left
    }
    else if(s[0] > sx && s[1] > sy) {
      a[0] ++ // top
      a[3] ++ // right
    }
  }

  // console.log(a)

  if(Math.max(...a) == a[0]) {
    console.log(a[0])
    console.log(`${sx} ${sy + 1}`)
  }
  else if(Math.max(...a) == a[1]) {
    console.log(a[1])
    console.log(`${sx} ${sy - 1}`)
  }
  else if(Math.max(...a) == a[2]) {
    console.log(a[2])
    console.log(`${sx - 1} ${sy}`)
  }
  else if(Math.max(...a) == a[3]) {
    console.log(a[3])
    console.log(`${sx + 1} ${sy}`)
  }
})


George decided to prepare a Codesecrof round, so he has prepared m problems for the round. Let's number the problems with integers 1 through m. George estimates the i-th problem's complexity by integer bi.To make the round good, he needs to put at least n problems there. Besides, he needs to have at least one problem with complexity exactly a1, at least one with complexity exactly a2, ..., and at least one with complexity exactly an. Of course, the round can also have problems with other complexities.George has a poor imagination. It's easier for him to make some already prepared problem simpler than to come up with a new one and prepare it. George is magnificent at simplifying problems. He can simplify any already prepared problem with complexity c to any positive integer complexity d (c ≥ d), by changing limits on the input data.However, nothing is so simple. George understood that even if he simplifies some problems, he can run out of problems for a good round. That's why he decided to find out the minimum number of problems he needs to come up with in addition to the m he's prepared in order to make a good round. Note that George can come up with a new problem of any complexity.

The first line contains two integers n and m (1 ≤ n, m ≤ 3000) — the minimal number of problems in a good round and the number of problems George's prepared. The second line contains space-separated integers a1, a2, ..., an (1 ≤ a1 < a2 < ... < an ≤ 106) — the requirements for the complexity of the problems in a good round. The third line contains space-separated integers b1, b2, ..., bm (1 ≤ b1 ≤ b2... ≤ bm ≤ 106) — the complexities of the problems prepared by George.

Print a single integer — the answer to the problem.

NoteIn the first sample the set of the prepared problems meets the requirements for a good round.In the second sample, it is enough to come up with and prepare two problems with complexities 2 and 3 to get a good round.In the third sample it is very easy to get a good round if come up with and prepare extra problems with complexities: 2, 3, 4.

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
    let cnt = 0
    let j = 0
    for (let i = 0; i < goodRoundProblems; i++) {
        while (j < preparedProblems) {
            if (preparedComplexities[j] >= goodComplexities[i]) {
                cnt++
                i++
            }
            j++
        }
    }

    console.log(Math.max(0, goodRoundProblems - cnt))
}

'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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const requirements = readLine().split(' ').map(Number);
    const complexities = readLine().split(' ').map(Number);

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

    // console.log(nm, requirements, complexities)
    const result = georgeAndRound2(n, m, requirements, complexities);
    printResult(result.toString());
}

const georgeAndRound = (n, m, a, b) => {
    let appearance = 0;
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (b[j] >= a[i]) {
                appearance++;
                i++;
            }
        }
    }

    return Math.max(0, n - appearance);
};

const georgeAndRound2 = (n, m, a, b) => {
    let appearance = 0;
    let j = 0;
    for (let i = 0; i < n; i++) {
        while(j < m) {
            if (b[j] >= a[i]) {
                appearance++;
                i++;
            }
            j++;
        }
    }

    return Math.max(0, n - appearance);
};

var l=readline().split(' ');
var n=+l[0];
var m=+l[1];
var a=readline().split(' ').map(function(v){return +v;});
var b=readline().split(' ').map(function(v){return +v;});

a.sort(function(a,b){return a-b})
b.sort(function(a,b){return a-b})

var i=0,j=0;
var ans=0;
while(i<n&&j<m){
	if(a[i]<=b[j]){
		i++;
		j++;
		ans++;
	}else{
		j++;
	}
}
print(a.length-ans);

;(function () {

    print(function () {
        readline();
        var a = readline().split(' ').map(Number),
            b = readline().split(' ').map(Number),
            n = a.length, m = b.length, i = 0, j = 0, q = 0;

        while (i < n && j < m) {
            if (a[i] <= b[j]) {
                q++; i++;
            }
            j++;
        }

        return n - q;
    }());

}.call(this));

var line = readline().split(" ");
var n = parseInt(line[0]);
var m = parseInt(line[1]);

var complexes = readline().split(" ").map(function(x) { return parseInt(x); });
var problems  = readline().split(" ").map(function(x) { return parseInt(x); });

var result = 0;
for (var i = 0; i < complexes.length; i++) {
  var found = false;
  var foundBigger = false;
  var whichBigger = -1;

  for (var u = 0; u < problems.length; u++) {
    if (problems[u] == -1) continue;

    if (problems[u] > complexes[i]) {
      foundBigger = true;
      whichBigger = u;
      break;
    } else if (complexes[i] == problems[u]) {
      found = true;
      break;
    }
  }

  if (!found && foundBigger) {
    problems[whichBigger] = -1;
  }

  if (!foundBigger && !found) {
    result++;
  }
}

print(result);

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var m = line[1];

    var a =  readline().split(' ').map(Number);
    var b =  readline().split(' ').map(Number);
    a.sort((a,b) => b- a);
    b.sort((a,b) => a-b);
    var used = [];
    var res = 0;
    for(var i=0;i<a.length;i++){
        var found = false;
        for(var j=0;j<b.length;j++){
            if(used[j]){
                continue;
            }
            if(b[j] >= a[i]){
                found = true;
                used[j] = true;
                break;
            }
        }
        if(!found){
            res++;
        }
    }
    print(res)
}

main()

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
  let cnt = 0
  let j = 0
  for (let i = 0; i < goodRoundProblems; i++) {
    const goodComplexity = goodRoundProblems[i]
    while (goodComplexity > preparedComplexities[j]){
      j++
    }
    if (j === preparedProblems - 1) {
      console.log((goodRoundProblems - i - 1) + '')
      return
    }
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
  let cnt = new Map()
  for (let i = 0; i < goodRoundProblems; i++) {
    cnt.set(goodComplexities[i], (cnt.get(goodComplexities[i]) || 0) + 1)
  }

  for (let i = 0; i < preparedProblems; i++) {
    const complexity = preparedComplexities[i]
    if (cnt.has(complexity)) {
      cnt.set(complexity, cnt.get(complexity) - 1)
      if (cnt.get(complexity) === 0) {
        cnt.delete(complexity)
      }
    }
  }

  let missed = 0
  for (let value of cnt.values()) {
    missed += value
  }

  console.log(missed)
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
    let cnt = 0
    let j = 0
    for (let i = 0; i < goodRoundProblems; i++) {
        const goodComplexity = goodComplexities[i]
        if (preparedComplexities[j] >= goodComplexity) {
            j++
            cnt++
        } else {
            while (preparedComplexities[j] && preparedComplexities[j] < goodComplexity) {
                j++
            }
            if (preparedComplexities[j] && preparedComplexities[j] >= goodComplexity)
                cnt++
        }
        if (j === preparedProblems - 1) {
            console.log(goodRoundProblems - cnt - 1)
            return
        }
    }

    console.log(goodRoundProblems - cnt)
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
    let cnt = 0
    let j = 0
    for (let i = 0; i < goodRoundProblems; i++) {
        const goodComplexity = goodComplexities[i]
        if (preparedComplexities[j] >= goodComplexity) {
            j++
            cnt++
        } else {
            while (preparedComplexities[j] && preparedComplexities[j] < goodComplexity) {
                j++
            }
            if (preparedComplexities[j] && preparedComplexities[j] >= goodComplexity)
                cnt++
        }
        if (cnt === goodRoundProblems - 1) {
           console.log(0)
           return
        }

        if (j >= preparedProblems - 1) {
            console.log(goodRoundProblems - cnt)
            return
        }
    }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
    let cnt = 0
    let j = 0
    for (let i = 0; i < goodRoundProblems; i++) {
        const goodComplexity = goodComplexities[i]
        if (preparedComplexities[j] >= goodComplexity) {
            j++
            cnt++
        } else {
            while (preparedComplexities[j] && preparedComplexities[j] < goodComplexity) {
                j++
            }
            if (preparedComplexities[j] && preparedComplexities[j] >= goodComplexity)
                cnt++
        }
        if (j === preparedProblems) {
            break
        }
    }

    console.log(goodRoundProblems - cnt)
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

  main();
});

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

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
    let cnt = 0
    let j = 0
    for (let i = 0; i < goodRoundProblems; i++) {
        const goodComplexity = goodComplexities[i]
        if (preparedComplexities[j] >= goodComplexity) {
            j++
            cnt++
        } else {
            while (preparedComplexities[j] && preparedComplexities[j] < goodComplexity) {
                j++
            }
            if (j < preparedProblems)
                cnt++
        }
        if (j === preparedProblems) {
            break;
        }
    }

    console.log(goodRoundProblems - cnt)
}

// Make a Snippet for the code above this and then write your logic in main()
function main() {
  const input = readline().split(' ').map(Number)
  const [goodRoundProblems, preparedProblems] = input
  const goodComplexities = readline().split(' ').map(Number)
  const preparedComplexities = readline().split(' ').map(Number)
  helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities)
}

function helper(goodRoundProblems, preparedProblems, goodComplexities, preparedComplexities) {
  let cnt = 0
  let j = 0
  for (let i = 0; i < goodRoundProblems; i++) {
    const goodComplexity = goodRoundProblems[i]
    while (goodComplexity > preparedComplexities[j]){
      j++
    }
    if (j === preparedProblems - 1) {
      console.log(goodRoundProblems - i - 1)
      return
    }
  }
}

'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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const requirements = `0 ${readLine()}`.split(' ').map(Number);
    const complexities = `0 ${readLine()}`.split(' ').map(Number);

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

    // console.log(nm, requirements, complexities)
    const result = georgeAndRound(n, m, requirements, complexities);
    printResult(result.toString());
}

const georgeAndRound = (n, m, a, b) => {
    const counts = new Array(Math.pow(10, 6) + 1);
    for (let i = 1; i <= m; i++) counts[b[i]] = 1;
    let appearance = 0;
    for (let i = 1; i <= n; i++) {
        if (counts[a[i]]) appearance++;
    }

    return n - appearance;
};

'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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const requirements = readLine().split(' ').map(Number);
    const complexities = readLine().split(' ').map(Number);

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

    // console.log(nm, requirements, complexities)
    const result = georgeAndRound(n, m, requirements, complexities);
    printResult(result.toString());
}

const georgeAndRound = (n, m, a, b) => {
    const counts = new Array(Math.pow(10, 6) + 1);
    for (let i = 0; i < m; i++) {
        counts[b[i]] = 1;
    }
    let appearance = 0;
    for (let i = 0; i < n; i++) {
        if (counts[a[i]]) appearance++;
    }

    return n - appearance;
};

'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 printResult(x) {
    process.stdout.write(x);
}

function main() {
    const nm = readLine().split(' ').map(Number);
    const requirements = readLine().split(' ').map(Number);
    const complexities = readLine().split(' ').map(Number);

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

    // console.log(nm, requirements, complexities)
    const result = georgeAndRound(n, m, requirements, complexities);
    printResult(result.toString());
}

const georgeAndRound = (n, m, a, b) => {
    let appearance = 0;
    for (let i = 0; i < n; i++) {
        for (let j = 0; j < m; j++) {
            if (b[j] >= a[i]) {
                appearance++;
                i++;
            }
        }
    }

    return Math.max(0, n - appearance);
};

var l=readline().split(' ');
var n=+l[0];
var m=+l[1];
var a=readline().split(' ').map(function(v){return +v;});
var b=readline().split(' ').map(function(v){return +v;});

var map={};
b.forEach(function(v){
	map[v]=true;
});

var ans=0;
a.forEach(function(v){
	if(!map[v]){
		ans++;
	}
});
print(ans);

var l=readline().split(' ');
var n=+l[0];
var m=+l[1];
var a=readline().split(' ').map(function(v){return +v;});
var b=readline().split(' ').map(function(v){return +v;});

var map={};
b.forEach(function(v){
	map[v]=true;
});

var ans=0;
a.forEach(function(v){
	if(!ans[v]){
		ans++;
	}
});
print(ans);

;(function () {

    print(function () {
        var n = readline().split(' ').map(Number),
            m = n[1],
            a = readline().split(' ').map(Number),
            b = readline().split(' ').map(Number),
            r = Math.min(n[0], m),
            t = 0;
        n = n[0];

        for (var i = 0; i < r; i++) {
            if (b[m - i - 1] < a[n - i - 1]) t++;
        }

        return t + n - i;
    }());

}.call(this));

;(function () {

    print(function () {
        var n = readline().split(' ').map(Number),
            m = n[1],
            a = readline().split(' ').map(Number),
            b = readline().split(' ').map(Number),
            r = 0,
            t = 0;
        n = n[0];

        for (var i = 0; i < a.length; i++) {
            t = b.indexOf(a[i]);
            if (t !== -1) {
                b.splice(t, 1);
                a.splice(i, 1);
                i--;
            }
        }

        if (a.length === 0) return 0;
        n = a.length;
        m = b.length;
        t = 0;
        r = Math.min(n, m)

        for (var i = 0; i < r; i++) {
            if (b[m - i - 1] < a[n - i - 1]) t++;
        }

        return t + n - i;
    }());

}.call(this));

;(function () {

	print(function (n, m) {
		var a = readline().split(' ').map(Number).sort(function (a, b) { return a - b; }),
			b = readline().split(' ').map(Number).sort(function (a, b) { return a - b; }),
			k = 0;

		for (var i = 0, j = 0; i < n; i++) {
			if (b[j]) {
				if (b[j] >= a[j]) j++;
				else {
					var t = b.indexOf(a[j]);
					if (t === -1) k++;
					else j = t + 1;
				};
			} else k ++;
		}

		return k;
	}.apply(null, readline().split(' ').map(Number)));

}.call(this));

;(function () {

    print(function () {
        var n = readline().split(' ').map(Number),
            m = n[1],
            a = readline().split(' ').map(Number),
            b = readline().split(' ').map(Number);
        n = n[0];

        for (var i = 0; i < a.length; i++) {
            var t = b.indexOf(a[i]);
            if (t !== -1) {
                b.splice(t, 1);
                a.splice(i, 1);
                i--;
            }
        }

        if (a.length === 0) return 0;
        n = a.length;
        m = b.length;

        for (var i = a.length; i > -1; i--) {
            var r = a[i],
                m = Math.max(b);

            if (m > r) {
                a.splice(i, 1);
                var t = b.indexOf(m);
                b.splice(t, 1);
                i++;
            }
        }

        if (a.length === 0) return 0;
        return a.length;
    }());

}.call(this));

;(function () {

    print(function () {
        var n = readline().split(' ').map(Number),
            m = n[1],
            a = readline().split(' ').map(Number),
            b = readline().split(' ').map(Number),
            r = 0,
            t = 0;
        n = n[0];

        for (var i = 0; i < a.length; i++) {
            t = b.indexOf(a[i]);
            if (t !== -1) {
                b.splice(t, 1);
                a.splice(i, 1);
                i--;
            }
        }

        if (a.length === 0) return 0;
        n = a.length;
        m = b.length;
        t = 0;
        r = Math.min(n, m)

        for (var i = 0; i < r; i++) {
            if (b[i] < a[i]) t++;
        }

        return t + n - i;
    }());

}.call(this));

var line = readline().split(" ");
var n = parseInt(line[0]);
var m = parseInt(line[1]);

var complexes = readline().split(" ").map(function(x) { return parseInt(x); });
var problems  = readline().split(" ").map(function(x) { return parseInt(x); });

var result = 0;
for (var i = 0; i < complexes.length; i++) {
  var found = false;
  var foundBigger = false;

  for (var u = 0; u < problems.length; u++) {
    if (problems[u] > complexes[i] && complexes[i] > 0) {
      foundBigger = true;
      break;
    } else if (complexes[i] == problems[u]) {
      found = true;
      break;
    }
  }

  if (!found && !foundBigger) {
    result++;
  }
}

print(result);

var line = readline().split(" ");
var n = parseInt(line[0]);
var m = parseInt(line[1]);

var complexes = readline().split(" ").map(function(x) { return parseInt(x); });
var problems  = readline().split(" ").map(function(x) { return parseInt(x); });

var result = 0;
for (var i = 0; i < complexes.length; i++) {
  var found = false;
  var foundBigger = false;

  for (var u = 0; u < problems.length; u++) {
    if (problems[u] > complexes[i]) {
      foundBigger = true;
    } else if (complexes[i] == problems[u]) {
      found = true;
      break;
    }
  }

  if (!found && !foundBigger) {
    result++;
  }
}

print(result);

function main() {
    var line = readline().split(' ').map(Number);
    var n = line[0];
    var m = line[1];

    var a =  readline().split(' ').map(Number);
    var b =  readline().split(' ').map(Number);
    a.sort((a,b) => b- a);
    b.sort((a,b) => a-b);
    var used = [];
    var res = 0;
    for(var i=0;i<a.length;i++){
        var found = false;
        for(var j=0;j<b.length;j++){
            if(used[j]){
                continue;
            }
            if(b[j] >= a[i]){
                found = true;
                used[j] = true;
            }
        }
        if(!found){
            res++;
        }
    }
    print(res)
}

main()


Three friends are going to meet each other. Initially, the first friend stays at the position $$$x = a$$$, the second friend stays at the position $$$x = b$$$ and the third friend stays at the position $$$x = c$$$ on the coordinate axis $$$Ox$$$.In one minute each friend independently from other friends can change the position $$$x$$$ by $$$1$$$ to the left or by $$$1$$$ to the right (i.e. set $$$x := x - 1$$$ or $$$x := x + 1$$$) or even don't change it.Let's introduce the total pairwise distance — the sum of distances between each pair of friends. Let $$$a'$$$, $$$b'$$$ and $$$c'$$$ be the final positions of the first, the second and the third friend, correspondingly. Then the total pairwise distance is $$$|a' - b'| + |a' - c'| + |b' - c'|$$$, where $$$|x|$$$ is the absolute value of $$$x$$$.Friends are interested in the minimum total pairwise distance they can reach if they will move optimally. Each friend will move no more than once. So, more formally, they want to know the minimum total pairwise distance they can reach after one minute.You have to answer $$$q$$$ independent test cases.

The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 1000$$$) — the number of test cases. The next $$$q$$$ lines describe test cases. The $$$i$$$-th test case is given as three integers $$$a, b$$$ and $$$c$$$ ($$$1 \le a, b, c \le 10^9$$$) — initial positions of the first, second and third friend correspondingly. The positions of friends can be equal.

For each test case print the answer on it — the minimum total pairwise distance (the minimum sum of distances between each pair of friends) if friends change their positions optimally. Each friend will move no more than once. So, more formally, you have to find the minimum total pairwise distance they can reach after one minute.

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

var arr = ''
process.stdin.on('data', (i) => {
  arr += i
})

process.stdin.on('end', () => {
  arr = arr.split('\n').map(a => a.replace(/(\r\n|\n|\r)/gm, ''))

  const t = parseInt(arr.shift())

  for(let i = 0; i < t; i++) {
    const arrN = arr[i].split(' ').map(a => parseInt(a))
    arrN.sort((a, b) => a - b)

    let a = arrN[0]
    let b = arrN[1]
    let c = arrN[2]
    if(a != b && b == c) {
      b--
      c--
      a++
      if(a > b) a--
    }
    else if(c != b && b == a) {
      b++
      c--
      a++
      if(c < a) c++
    }
    else if(a != b && b != c) {
      a++
      c--
    }

    // console.log(a, b, c)

    console.log(Math.abs(a - b) + Math.abs(a - c) + Math.abs(c - b))
  }
})

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort((a, b) => a - b);

    if (numbers[0] !== numbers[2]) {
        if (numbers[0] === numbers[1]) {
            numbers[0]++;
            numbers[1]++;

            if (numbers[0] !== numbers[2]) numbers[2]--;
        } else if (numbers[2] === numbers[1]) {
            numbers[2]--;
            numbers[1]--;

            if (numbers[2] !== numbers[0]) numbers[0]++;
        } else {
            numbers[0]++;
            numbers[2]--;
        }
    }

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

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

    function foo (data) {
        data.sort((a,b) => a - b);
        let [a, b, c] = data;
        if (a < b && b < c) {
            a++;
            c--;
        } else if (a === b) {
            if (b < c) c--;
            if (b < c) c--;
        } else if (b === c) {
            if (a < b) a++;
            if (a < b) a++;
        }
        return b - a + c - a + c - b;
    }

    let testCount = 1;
    let answer = '';
    while(testCount <= +lines[0]) {
        let data = lines[testCount].split(" ").map(Number);

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

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

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

  const arr = d.split(' ').map(Number);
  const max = Math.max(...arr);

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

  const min = Math.min(...arr);
  for (let i = 0; i < arr.length; i++) {
    if (arr[i] > min) {
      arr[i]--;
    }
  }

  const ans = Math.abs(arr[0] - arr[1]) + Math.abs(arr[0] - arr[2]) + Math.abs(arr[1] - arr[2]);

  console.log(ans);

  count++;
});

process.stdin.setEncoding('utf-8').on('data', input => {
    const dist = (a, b, c) => Math.abs(a - b) + Math.abs(a - c) + Math.abs(b - c);
    input.split('\r\n').filter((_, i) => i >= 1).filter(l => l && l.length > 0)
        .forEach(line => {
            const [a, b, c] = line.split(' ').map(Number);
            let minDist = dist(a, b, c);
            for (let i = -1; i <= 1; i++) {
                for (let j = -1; j <= 1; j++) {
                    for (let l = -1; l <= 1; l++) {
                        minDist = Math.min(minDist, dist(a + i, b + j, c + l));
                    }
                }
            }
            console.log(minDist);
        });
});

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});

txt.shift();

for (let i = 0; i < txt.length; i++) {
    let info = txt[i].split(" ").filter(data => {
        return data.length > 0;
    }).map(data => {
        return data * 1;
    });
    doit(info);

}

function doit(tab) {
    let mid = Math.round((tab[0] + tab[1] + tab[2]) / 3);
    for (let i = 0; i < tab.length; i++) {
        if (tab[i] < mid) {
            ++tab[i];
        } else if (tab[i] > mid) {
            --tab[i];
        }
    }
    console.log(Math.abs(tab[0] - tab[1]) + Math.abs(tab[0] - tab[2]) + Math.abs(tab[2] - tab[1]));
}

'use strict'

const dist = (a, b, c) => Math.abs(a-b) + Math.abs(a-c) + Math.abs(b-c);

const problem = (a, b, c) => {
    let r = Infinity;
    for (let i = -1; i < 2; i++) {
        const A = a + i;
        for (let j = -1; j < 2; j++) {
            const B = b + j;
            for (let k = -1; k < 2; k++) {
                const C = c + k;
                r = Math.min(r, dist(A,B,C));
            }
        }
    }
    return r;
}
let q = +readline();

while(q--) {
    const abc = readline().split(' ').map(i => +i);
    print(problem(abc[0], abc[1], abc[2]));
}

function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim();}
function myout(t){print(t);}//standard output
//function myout(t){console.log(t);}//standard output
function myerr(t){console.err(t);}//standard error
//[no]param
//0:何もしない  1:数値へ変換  2:半角SPで分割  3:改行で分割  4:半角SPで分割し、数値配列へ
//5:改行で分割し、数値配列へ  6:1文字に分割  7:1文字に分割し、数値配列へ
function myconv(i,no){switch(no){case 0:return i;case 1:return parseInt(i);case 2:return i.split(" ");case 3:return i.split("\n");case 4:return i.split(" ").map((a)=>Number(a));case 5:return i.split("\n").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));}}

function Main() {
  //input = myconv(input,3);
  var N = myconv(readline(),1);
  var output = [];
  for(var i = 0; i < N; i++){
    var tmp = myconv(readline(),4).sort(function(a,b){return myconv(a,1)-myconv(b,1);});
    var a = tmp[0];
    var b = tmp[1];
    var c = tmp[2];
    var da = a+1;
    var dc = c-1;

    if(c-a > 2){
      if(b == c){
         b = dc;
         }else{
         b = da;
         }
       output.push(Math.abs(da-b)+Math.abs(da-dc)+Math.abs(dc-b));
    }else{
       output.push(0);
    }
  }
  myout(output.join("\n"));
}

Main();

var toInt = x => parseInt(x);
var n = parseInt(readline());
var check = (a, b, c) => (Math.abs(a-b)+Math.abs(b-c)+Math.abs(a-c));
var ar = new Array(n).fill('').map(readline).map(l=>l.split(' ').map(toInt));
ar.forEach(a => {
    var best = Number.MAX_SAFE_INTEGER;
    for(var i=-1; i<=1;i++) {
        for(var j=-1; j<=1;j++) {
            for(var k=-1; k<=1;k++) {
                best = Math.min(best, check(a[0]+i, a[1]+j, a[2]+k));
            }
        }
    }
    print(best);

})

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort();

    if (numbers[0] !== numbers[2]) {
        if (numbers[0] === numbers[1]) {
            numbers[0]++;
            numbers[1]++;

            // if (numbers[0] !== numbers[2]) numbers[2]--;
        } else if (numbers[2] === numbers[1]) {
            numbers[2]--;
            numbers[1]--;

            if (numbers[2] !== numbers[0]) numbers[0]++;
        } else {
            numbers[0]++;
            numbers[2]--;
        }
    }

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort();

    if (numbers[0] !== numbers[2]) {
        if (numbers[0] === numbers[1]) {
            numbers[0]++;
            numbers[1]++;

            // if (numbers[0] !== numbers[2]) numbers[2]--;
        } else if (numbers[2] === numbers[1]) {
            numbers[2]--;
            numbers[1]--;

            // if (numbers[2] !== numbers[0]) numbers[0]++;
        } else {
            numbers[0]++;
            numbers[2]--;
        }
    }

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort();

    if (numbers[0] !== numbers[2]) {
        if (numbers[0] === numbers[1]) {
            numbers[0]++;
            numbers[1]++;

            if (numbers[0] !== numbers[2]) numbers[2]--;
        } else if (numbers[2] === numbers[1]) {
            numbers[2]--;
            numbers[1]--;

            if (numbers[2] !== numbers[0]) numbers[0]++;
        } else {
            numbers[0]++;
            numbers[2]--;
        }
    }

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort();

    if (numbers[0] !== numbers[2]) {
        if (numbers[0] === numbers[1]) {
            numbers[2]--;
        } else if (numbers[2] === numbers[1]) {
            numbers[0]++;
        } else {
            numbers[0]++;
            numbers[2]--;
        }
    }

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort();

    if (numbers[0] < numbers[1]) ++numbers[0];

    if (numbers[2] > numbers[1]) --numbers[2];

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

const readline = require('readline');

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

rl.on('line', (input) => {
    if (q === null) {
        q = +input;
    } else {
        solve(input.split(' ').map(number => +number));
        readedLines++;
    }

    if (q === readedLines) {
        rl.close();
    }
});

let q = null;
let readedLines = 0;

const solve = numbers => {
    numbers.sort();

    if (numbers[0] !== numbers[2]) {
        if (numbers[0] === numbers[1]) {
            numbers[0]++;
            numbers[1]++;

            // if (numbers[0] !== numbers[2]) numbers[2]--;
        } else if (numbers[2] === numbers[1]) {
            numbers[2]--;
            numbers[1]--;

            if (numbers[2] !== numbers[0]) numbers[0]++;
        } else {
            numbers[0]++;
            numbers[2]--;
        }
    }

    console.log(numbers);

    console.log(
        (numbers[1] - numbers[0]) + (numbers[2] - numbers[1]) + (numbers[2] - numbers[0])
    );
};

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

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

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);

  if (arr[0] < arr[1]) {
    arr[0]++;
  }
  if (arr[2] >= arr[1]) {
    arr[2]--;
  }

  const ans = Math.max(0, (arr[2] - arr[1]) + (arr[2] - arr[0]) + (arr[1] - arr[0]));
  console.log(ans);

  c++;
});

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

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

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);

  if (arr[0] < arr[1]) {
    arr[0]++;
  }
  if (arr[2] >= arr[1]) {
    arr[2]--;
  }

  const ans = arr[2] - arr[1] + arr[2] - arr[0] + arr[1] - arr[0];
  console.log(ans);

  c++;
});

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

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

  const arr = d.split(' ').map(Number);
  arr.sort((a, b) => a - b);

  if (arr[0] < arr[1]) {
    arr[0]++;
  }

  if (arr[2] > arr[1]) {
    arr[2]--;
  }
  else if (arr[1] !== arr[0] && arr[1] !== arr[2]) {
    arr[1]--;
  }
  else {
    if (arr[1] === arr[2] && arr[1] !== arr[0]) {
      arr[1]--;
      arr[2]--;
    }
    else if (arr[1] === arr[0] && arr[1] !== arr[2]) {
      arr[1]++;
      arr[0]++;
    }
  }

  const ans = Math.abs(arr[0] - arr[1]) + Math.abs(arr[0] - arr[2]) + Math.abs(arr[1] - arr[2]);

  console.log(ans);

  count++;
});

let fs = require("fs");

let txt = fs.readFileSync(0, "utf-8").split("\r\n").filter(data => {
    return data.length > 0;
});

txt.shift();

for (let i = 0; i < txt.length; i++) {
    let info = txt[i].split(" ").filter(data => {
        return data.length > 0;
    }).map(data => {
        return data * 1;
    });
    doit(info);

}

function doit(tab) {
    let mid = Math.floor((tab[0] + tab[1] + tab[2]) / 3);
    for (let i = 0; i < tab.length; i++) {
        if (tab[i] < mid) {
            ++tab[i];
        } else if (tab[i] > mid) {
            --tab[i];
        }
    }
    console.log(Math.abs(tab[0] - tab[1]) + Math.abs(tab[0] - tab[2]) + Math.abs(tab[2] - tab[1]));
}


You are given a string $$$s$$$ of length $$$n$$$, which consists only of the first $$$k$$$ letters of the Latin alphabet. All letters in string $$$s$$$ are uppercase.A subsequence of string $$$s$$$ is a string that can be derived from $$$s$$$ by deleting some of its symbols without changing the order of the remaining symbols. For example, "ADE" and "BD" are subsequences of "ABCDE", but "DEA" is not.A subsequence of $$$s$$$ called good if the number of occurences of each of the first $$$k$$$ letters of the alphabet is the same.Find the length of the longest good subsequence of $$$s$$$.

The first line of the input contains integers $$$n$$$ ($$$1\le n \le 10^5$$$) and $$$k$$$ ($$$1 \le k \le 26$$$). The second line of the input contains the string $$$s$$$ of length $$$n$$$. String $$$s$$$ only contains uppercase letters from 'A' to the $$$k$$$-th letter of Latin alphabet.

Print the only integer — the length of the longest good subsequence of string $$$s$$$.

NoteIn the first example, "ACBCAB" ("ACAABCCAB") is one of the subsequences that has the same frequency of 'A', 'B' and 'C'. Subsequence "CAB" also has the same frequency of these letters, but doesn't have the maximum possible length.In the second example, none of the subsequences can have 'D', hence the answer is $$$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↑入力 ↓出力');
	Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){
	return {
		list : input, index : 0, max : input.length,
		hasNext : function(){return (this.index < this.max);},
		next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
	};
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var K = one[1];
	var alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	var map = {};
	for(var i = 0; i < K; i++){
		map[alpha[i]] = 0;
	}
	var list = next();
	for(var i = 0; i < N; i++){
		map[list[i]]++;
	}
	var min = N;
	var keys = Object.keys(map);
	for(var i = 0; i < keys.length; i++){
		min = Math.min(min, map[keys[i]]);
	}
	myout(min * K);
}

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

rl.on('line', (d) => {
  if (c === 0) {
    c++;
    [n, k] = d.split(' ').map(Number);
    return;
  }

  const str = d;
  const frequence = {};

  for (let i = 0; i < str.length; i++) {
    if (frequence[str[i]]) {
      frequence[str[i]]++;
    }
    else {
      frequence[str[i]] = 1;
    }
  }

  const values = Object.values(frequence);

  if (values.length !== k) {
    console.log(0);
  }
  else {
    const min = Math.min(...values);
    console.log(k*min);
  }

  c++;
});

var ip = readline().split(' ').map(Number);
var n = ip[0], k = ip[1];
var ar = new Array(26);
for (i=0;i<26;i++){
    ar[i] = 0;
}
var min = 1000000;
readline().split('').forEach(x=>ar[x.charCodeAt()-65]++);
for (i = 0;i<k;i++){
    min = Math.min(min,ar[i]);
}
print(min*k)

var n, k, s, cnt, ans;
var token = [];

var i;

token = readline().split(' ');

n = parseInt(token[0]);
k = parseInt(token[1]);

s = readline();

cnt = new Array(k);
for(i=0;i<k;i++) {
  cnt[i] = 0;
}

for(i=0;i<n;i++) {
  ++cnt[s.charCodeAt(i)-"A".charCodeAt()];
}

ans = cnt[0];
for(i=1;i<k;i++) {
  ans = Math.min(ans, cnt[i]);
}

ans*=k;

print(ans);

var numbers = readline().split(" ");
var str = readline().split("");
var s = numbers[0];
var k = numbers[1];

var arr  = [];
for (var i = 0; i < s; i++) {
    // if (str[i].charCodeAt(0)>64+k) {
    //     write("0");
    // }
    var index = arr.findIndex(function(el) {return el.char == str[i]});
    if (index == -1)
        arr.push({char:str[i], number: 1});
    else {
        arr[index].number++;
    }
}
if (arr.length != k)
    print(0);
else
    print(getMinOfArray(arr.map(function(el) {return el.number}))*k);

function getMinOfArray(numArray) {
    return Math.min.apply(null, numArray);
}

var alphapet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
    'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
];

var arr = readline().split(" ").map((elem) => {
    return parseInt(elem);
});
var str = readline();

var n = arr[0],
    k = arr[1];

var arrTmp = alphapet.splice(0, k);
flag = true;

arrTmp.forEach((elem) => {
    if (str.split("").find((x) => {
            return x === elem;
        })) {
        flag = true;
    } else {
        flag = false;
    }
})
if (!flag) {
    print(0);
} else {
    var counterArray = [];
    for(i=0;i<k;i++){
        counterArray[i]=0;
    }

    i=-1,el='';
    strSplitted = str.split("");
    strSplitted.sort();

    strSplitted.forEach((elem)=>{
        if(el !== elem){
            el = elem;
            i++;
        }
        counterArray[i]++;
    })
    mn = Math.min(...counterArray);
    print(k*mn);

}

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

//Don't have to see. end------------------------------------------
function Main(){
	var one = nextIntArray();
	var N = one[0];
	var K = one[1];
	var alpha = "ABCFEFGHIJKLMNOPQESTUVWXYZ";
	var map = {};
	for(var i = 0; i < K; i++){
		map[alpha[i]] = 0;
	}
	var list = next();
	for(var i = 0; i < N; i++){
		map[list[i]]++;
	}
	var min = N;
	var keys = Object.keys(map);
	for(var i = 0; i < keys.length; i++){
		min = Math.min(min, map[keys[i]]);
	}
	myout(min * K);
}


Nezzar has $$$n$$$ balls, numbered with integers $$$1, 2, \ldots, n$$$. Numbers $$$a_1, a_2, \ldots, a_n$$$ are written on them, respectively. Numbers on those balls form a non-decreasing sequence, which means that $$$a_i \leq a_{i+1}$$$ for all $$$1 \leq i < n$$$.Nezzar wants to color the balls using the minimum number of colors, such that the following holds.  For any color, numbers on balls will form a strictly increasing sequence if he keeps balls with this chosen color and discards all other balls.  Note that a sequence with the length at most $$$1$$$ is considered as a strictly increasing sequence.Please help Nezzar determine the minimum number of colors.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of testcases.  The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$). The second line of each test case contains $$$n$$$ integers $$$a_1,a_2,\ldots,a_n$$$ ($$$1 \le a_i \le n$$$). It is guaranteed that $$$a_1 \leq a_2 \leq \ldots \leq a_n$$$.

For each test case, output the minimum number of colors Nezzar can use.

NoteLet's match each color with some numbers. Then:In the first test case, one optimal color assignment is $$$[1,2,3,3,2,1]$$$.In the second test case, one optimal color assignment is $$$[1,2,1,2,1]$$$.

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var s = 0
    var e = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 === 0){
            var a = new Map()
            var k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    var temp = a.get(k[l])
                    temp++
                    a.set(k[l], temp)
                }else{
                    a.set(k[l], 1)
                }
            }
            var biggestKey = ''
            var biggestValue = 0
            for(var[key, value] of a){
                if(value > biggestValue){
                    biggestValue = value
                    biggestKey=key
                }
            }
            console.log(biggestValue)
        }else{
            e = lines[j]
        }
    }
});

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var e = 0
    for(j = 1; j <= n * 2; j++){
        if(j % 2 === 0){
        var a = new Map()
        var k = lines[j].split(' ')
        for(l = 0 ;l < e; l++){
        if(a.has(k[l])){
            var temp = a.get(k[l])
            temp++
            a.set(k[l], temp)
        }else{
            a.set(k[l], 1)
        }
    }
        var biggestValue = 0
        var biggestKey = ''
            for(var [key,value] of a){
                if(biggestValue < value){
                    biggestKey = key
                    biggestValue = value
                }
            }
    console.log(biggestValue)

        }else {
            e = lines[j]
        }
    }
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var a = new Map();
            for(j = 0; j < e; j++){
                if(a.has(k[j])){
                    var te = a.get(k[j]);
                    te++;
                    a.set(k[j], te);
                }else{
                    a.set(k[j], 1);
                }
            }
            var ans = 0;
            for(var [key, value] of a){
                if(value > ans){
                    ans = value;
                }
            }
            console.log(ans);
        }
    }
});

let q = '';
process.stdin.on('data', c => q += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = q.split(EOL);
    var t = lines[0];
    var e = 0;
    for(i = 1; i <= t * 2; i++){
        if(i % 2 == 1){
            e = lines[i];
        }else{
            var k = lines[i].split(' ').map(Number);
            var a = new Map();
            for(j = 0; j < e; j++){
                if(a.has(k[j])){
                    var temp = a.get(k[j]);
                    temp++;
                    a.set(k[j], temp);
                }else{
                    a.set(k[j], 1);
                }
            }
            var ans = 0;
            for(var [key, value] of a){
                if(ans < value){
                    ans = value;
                }
            }
            console.log(ans);
        }
    }
});

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

let inputString = '';
let currentLine = 0;

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

function main() {
  const t = parseInt(readline(), 10);

  for (let i = 0; i < t; i += 1) {
    readline();
    const a = readline().split(' ').map(num => parseInt(num, 10));
    let number = 1;
    let max = 1;

    a.forEach((item, index) => {
      if (item === a[index + 1]) {
        number += 1;
        return;
      }

      if (number > max) {
        max = number;
      }

      number = 1;
    });

    console.log(max);
  }
}

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

process.stdin.on('end', () => {
  inputString = inputString.split('\n').map(str => str.trim());

  main();
});

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.split('\n').map(str => str.trim());

  main();
});

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

function main() {
  let t = readline();

  while (t--) {
    readline();
    const a = readline().split(' ').map(num => parseInt(num, 10));
    const r = [];

    a.forEach(item => {
      r.push(a.filter(next => next === item).length);
    });

    console.log(Math.max(...r));
  }
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main()
});

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

function main() {
    let testCases = readline()
    while(testCases--)
        solve()
}

// function to solve problems
function solve (){
    let arrLength = readline()
    let n = readline().split(' ').map(x => +x)
    // let n = line[0]
    // let k = line[1]
    // let ans = 0
    // ------------------
    // count the most occurrences and it is the answer
    let myMap = new Map()
    for (let i = 0; i < n.length; i++) {
        // if (myMap.has(n[i])){
        if (myMap.has(n[i])) {
            myMap.set(n[i], myMap.get(n[i]) + 1)
            // console.log('IF myMap = ', myMap)
        }
        else {
            myMap.set(n[i], 1)
            // console.log('myMap = ', myMap)
        }
    }
    let max = 0
    // console.log(myMap.keys())
    // console.log('map entries = ', myMap.entries())
    for (const [key, value] of myMap.entries()) {
        max = (value > max) ? +value: max
    }
    console.log(max)
}

function main(lines) {
  const T = parseInt(lines[0], 10);
  for (let i = 0; i < T; i++) {
    const index = 1 + i * 2;
    const n = parseInt(lines[index], 10);
    const str = lines[index + 1];
    const arr = str.split(' ').map((item) => parseInt(item, 10));
    let j = 1;
    let max = 1;
    let currentValue = 1;
    while (j < arr.length) {
      if (arr[j] === arr[j - 1]) {
        currentValue += 1;
      } else {
        max = Math.max(max, currentValue);
        currentValue = 1;
      }
      j += 1;
    }
    max = Math.max(max, currentValue);
    console.log(max);
  }
}

let inputString = '';

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

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

  main(inputString);
});

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 gcd(a, b) {
	if (b === 0) return a;
	return gcd(b, a % b);
}

function main() {
	let t = +readLine();
	while (t--) {
		const len = +readLine();
		const arr = readLine().split(' ').map(Number);
		const map = new Map();
		for (let n of arr) {
			map.set(n, (map.get(n) || 0) + 1);
		}
		const f = [...map.values()].sort((a, b) => a - b);
		console.log(f[f.length - 1]);
	}
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

// Make a Snippet for the code above this and then write your logic in main();

function main() {
    const x = readline();
    var answer = []

    // console.log(Number(x))
    // 1 1 7
    // 6 9, 15, 18
    Array(Number(x)).fill(1).map((t, i) => {
        var n = Number(readline());
        var array = readline().split(' ').map(x=>Number(x));
        var current = 0
        var number = 0
        var max = 0
        array.map((x,i)=>{
            if(i===array.length) return;
            // console.log(current, x)
            if(x === array[i+1]){
                number++
                return
            }
            if(number > max) {
                max = number
            }
            number = 0
        })
         console.log(max +1)
         // console.log(array)

    })

}

process.stdin.resume();
process.stdin.setEncoding("utf8");
let standardInputString = "";
let curLine = 0;

function readLine() {
  return standardInputString[curLine++];
}

process.stdin.on("data", rawData => {
  standardInputString += rawData;
});

process.stdin.on("end", _ => {
  standardInputString = standardInputString
    .trim()
    .split("\n")
    .map(line => {
      return line.trim();
    });

  main();
});

// Pilot course from ITMO -> Z-function -> Step 1 -> Problem A

// function main() {
//   const testQuantity = +readLine();
//   for (let testNumber = 0; testNumber < testQuantity; testNumber++) {
//     let inputString = readLine();
//     let curLen = 0;
//     let curPrefix = "";
//     let maxPrefixLen = 0;

//     for (let inputChar of inputString) {
//       curPrefix += inputChar;
//       curLen++;

//       let foundNew = true;
//       let medianIndex = Math.floor(curLen / 2);
//       for (; medianIndex >= 0; medianIndex--) {
//         if (curPrefix[curLen - 1 - medianIndex] !== curPrefix[medianIndex]) {
//           foundNew = false;
//           break;
//         }
//       }

//       if (foundNew) {
//         maxPrefixLen = curLen;
//       }
//     }

//     console.log(maxPrefixLen);
//   }
// }

// .. -> Problem B

// function main() {
//   const testQuan = +readLine();
//   for (let testIx = 0; testIx < testQuan; testIx++) {
//     const inputStr = readLine();
//     let counter = 0;

//     for (let curLen = 0; curLen <= inputStr.length; curLen++) {
//       for (let startIx = 0; curLen + startIx <= inputStr.length; startIx++) {
//         let substring = inputStr.substring(startIx, startIx + curLen);
//         let prefix = inputStr.substring(0, curLen);
//         let suffix = inputStr.slice(inputStr.length - curLen, inputStr.length);

//         if (substring === prefix && substring !== suffix || substring === suffix && substring !== prefix) {
//           counter++;
//         }
//       }
//     }

//     console.log(counter);
//   }
// }

// .. -> Problem C

// function match(text, pattern) {
//   if (pattern.length > text.length) {
//     return false;
//   }

//   for (let comparingIx = 0; comparingIx < text.length; comparingIx++) {
//     if (text[comparingIx] !== pattern[comparingIx] && pattern[comparingIx] !== "?") {
//       return false;
//     }
//   }

//   return true;
// }

// function main() {
//   const testQuan = +readLine();
//   for (let testIx = 0; testIx < testQuan; testIx++) {
//     const inputStr = readLine();
//     const inputPattern = readLine();
//     const entryIndexes = [];

//     for (let startIx = 0; startIx + inputPattern.length <= inputStr.length; startIx++) {
//       if ( match(inputStr.slice(startIx, startIx + inputPattern.length), inputPattern) ) {
//         entryIndexes.push(startIx);
//       }
//     }

//     console.log(entryIndexes.length);
//     console.log(entryIndexes.join(" "));
//   }
// }

// .. -> Problem D

// function getSubstrQuan(length) {
//   return (length + 1) * (length) / 2;
// }

// function main() {
//   const testQuan = +readLine();
//   for (let testIx = 0; testIx < testQuan; testIx++) {
//     const inputStr = readLine();
//     const inputPattern = readLine();
//     let entryBorders = [];
//     let counter = 0;

//     for (let startIx = 0; startIx + inputPattern.length <= inputStr.length; startIx++) {
//       if ( inputStr.slice(startIx, startIx + inputPattern.length).includes(inputPattern) ) {
//         entryBorders.push([startIx, startIx + inputPattern.length - 1]);
//       }
//     }

//     entryBorders.push([inputStr.length, inputStr.length]);
//     let lastLeftBorder = 0;
//     for (let pairIx = 0; pairIx < entryBorders.length; pairIx++) {
//       let curPair = entryBorders[pairIx];
//       let curSubstrLen = curPair[1] - lastLeftBorder;
//       counter += getSubstrQuan(curSubstrLen);
//       lastLeftBorder = curPair[0] + 1;

//       if (curPair[1] - curPair[0] - 1 > 0) {
//         counter -= getSubstrQuan(curPair[1] - curPair[0] - 1);
//       }
//     }

//     console.log(counter);
//   }
// }

// Codeforces Round #698 (Div. 2) -> Problem A

function main() {
  let testQuan = +readLine();
  for (let testIx = 0; testIx < testQuan; testIx++) {
    let n = +readLine();
    let a = readLine().split(" ");
    a = a.map(item => +item);
    let counterArr = [];
    for (let i = 0; i <= n; i++) counterArr[i] = 0;

    for (let el of a) {
      counterArr[el]++;
    }

    console.log(Math.max(...counterArr));
  }
}

T = readline()

while(T--){
  n = readline()
  a = readline().split(' ').map(x => +x)
  ans = 1
  repeats = 0
  newrepeats = 0
  for(i = 0; i < n; i++ ){
    if(a[i]==a[i+1]){
      newrepeats++
      if(newrepeats>repeats)
        repeats = newrepeats
    }
    else
      newrepeats = 0
  }
  ans += repeats
  print(ans)
}

function solve(a){
    var l = 1, res = 1;
    for(var i = 1; i < a.length; i++){
        if(a[i] == a[i-1]){
            l++;
            res = Math.max(l, res);
        }else{
            l = 1;
        }
    }
    return res;
}

var a = [];
var t = Number(readline());
for (var i = 0; i<t;i++){
    var n = Number(readline());
    a = readline().split(' ').map((x) => x);
    write(solve(a)+'\n');
}

function solve(a){
    var l = 0;
    var c = 0;
    var min = 0;
    var aux = a[l];
    while(l < a.length){
        if(a[l] == aux){
            c++;
        }else{
            aux= a[l];
            c = 1;
        }
        min = c > min ? c : min;
        l++;
    }
    return min;

}

var a = [];
var t = Number(readline());
for (var i = 0; i<t;i++){
    n = Number(readline());
    a = readline().split(' ').map((x) => x);
    write(solve(a)+'\n');
}

"use strict"

let iter = parseInt(readline());

while(iter--){
    let length = parseInt(readline());
    let input = readline().split(" ").map(x => parseInt(x));

    let current = input[0];
    let counter = 0;
    let maxCounter = 0;

    for(let i = 0; i < length; i++){
        if(input[i] === current){
            counter++;
        } else {
            current = input[i];
            counter = 1;
        }

        if(counter > maxCounter){
            maxCounter = counter;
        }
    }

    print(maxCounter);
}

var t = parseInt(readline());
    while (t--) {
        var n=parseInt(readline())
        var line = readline();
        var a = line.split(' ');
        var b = new Array(n+1);
        for(var i=1;i<=n;i++) b[i]=0;
        var ans = 0;
        for (var i = 0; i < n; i++) {
            b[a[i]]++;
            ans = (ans<b[a[i]]?b[a[i]]:ans);
        }
        print(ans);
    }

let i = '';
process.stdin.on('data', c => i += c);
process.stdin.on('end', () => {
    const {EOL} = require('os');
    const lines = i.split(EOL);
    var n = lines[0];
    var s = 0
    var e = 0
    var a = new Map()
    for(j = 1; j <= n * 2; j++){
        if(j % 2 === 0){
            var k = lines[j].split(' ').map(Number)
            for(l = 0; l < e; l++){
                if(a.has(k[l])){
                    var temp = a.get(k[l])
                    temp++
                    a.set(k[l], temp)
                }else{
                    a.set(k[l], 1)
                }
            }
            var biggestKey = ''
            var biggestValue = 0
            for(var[key, value] of a){
                if(value > biggestValue){
                    biggestValue = value
                    biggestKey=key
                }
            }
            console.log(biggestValue)
        }else{
            e = lines[j]
        }
    }
});

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

    for(j = 1; j <= n*2; j ++){
        if(j % 2 === 0){
            var one = 0
    var two = 0
    var three = 0
    var four = 0
            var a = lines[j].split(' ').map(Number)
            for(k = 0; k < e; k++){
                if(a[k] == 1){
                    one++
                }else if(a[k] == 2){
                    two++
                }else if(a[k] == 3){
                    three++
                }else if(a[k] == 4){
                    four++
                }
            }
            console.log(Math.max(one, Math.max(two, Math.max(three, four))))
        }else{
            var e = lines[j]
        }
    }

});

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

        }else{
            var e = lines[j]
        }
    }

});

T = readline()

while(T--){
  n = readline()
  a = readline().split(' ').map(x => +x)
  ans = 1
  repeats = 1
  newrepeats = 1
  for(i = 0; i < n; i++ ){
    if(a[i]==a[i+1]){
      newrepeats++
      if(newrepeats>repeats)
        repeats = newrepeats
    }
    else
      newrepeats = 0
  }
  ans = repeats
  print(ans)
}

function solve(a){
    var count = 1, l = 1;
    for(var i = 1; i < a.length; i++){
        if(a[i] == a[i-1]){
            if(l == 1 || count == 1) count++;
            l = 1;
        }else{
            l++;
        }
    }
    return count;
}

var a = [];
var t = Number(readline());
for (var i = 0; i<t;i++){
    var n = Number(readline());
    a = readline().split(' ').map((x) => x);
    write(solve(a)+'\n');
}

function solve(a){
    var l = 0;
    var c = 0;
    var min = 0;
    var aux = a[l];
    while(l < a.length){
        if(a[l] == aux){
            c++;
        }else{
            aux= a[l];
            c = 0;
        }
        min = c > min ? c : min;
        l++;
    }
    return min;

}

var a = [];
var t = Number(readline());
for (var i = 0; i<t;i++){
    n = Number(readline());
    a = readline().split(' ').map((x) => x);
    write(solve(a)+'\n');
}

"use strict"

let iter = parseInt(readline());

while(iter--){
    let length = parseInt(readline());
    let input = readline().split(" ").map(x => parseInt(x));

    let current = input[0];
    let counter = 0;
    let maxCounter = 0;

    for(let i = 0; i < length; i++){
        if(input[i] === current){
            counter++;
        } else {
            current = input[i];
            if(counter > maxCounter){
                maxCounter = counter;
            }
            counter = 0;
        }
    }

    print(maxCounter === 0 ? counter : maxCounter);
}


You are responsible for installing a gas pipeline along a road. Let's consider the road (for simplicity) as a segment $$$[0, n]$$$ on $$$OX$$$ axis. The road can have several crossroads, but for simplicity, we'll denote each crossroad as an interval $$$(x, x + 1)$$$ with integer $$$x$$$. So we can represent the road as a binary string consisting of $$$n$$$ characters, where character 0 means that current interval doesn't contain a crossroad, and 1 means that there is a crossroad.Usually, we can install the pipeline along the road on height of $$$1$$$ unit with supporting pillars in each integer point (so, if we are responsible for $$$[0, n]$$$ road, we must install $$$n + 1$$$ pillars). But on crossroads we should lift the pipeline up to the height $$$2$$$, so the pipeline won't obstruct the way for cars.We can do so inserting several zig-zag-like lines. Each zig-zag can be represented as a segment $$$[x, x + 1]$$$ with integer $$$x$$$ consisting of three parts: $$$0.5$$$ units of horizontal pipe + $$$1$$$ unit of vertical pipe + $$$0.5$$$ of horizontal. Note that if pipeline is currently on height $$$2$$$, the pillars that support it should also have length equal to $$$2$$$ units.  Each unit of gas pipeline costs us $$$a$$$ bourles, and each unit of pillar — $$$b$$$ bourles. So, it's not always optimal to make the whole pipeline on the height $$$2$$$. Find the shape of the pipeline with minimum possible cost and calculate that cost.Note that you must start and finish the pipeline on height $$$1$$$ and, also, it's guaranteed that the first and last characters of the input string are equal to 0.

The fist line contains one integer $$$T$$$ ($$$1 \le T \le 100$$$) — the number of queries. Next $$$2 \cdot T$$$ lines contain independent queries — one query per two lines. The first line contains three integers $$$n$$$, $$$a$$$, $$$b$$$ ($$$2 \le n \le 2 \cdot 10^5$$$, $$$1 \le a \le 10^8$$$, $$$1 \le b \le 10^8$$$) — the length of the road, the cost of one unit of the pipeline and the cost of one unit of the pillar, respectively. The second line contains binary string $$$s$$$ ($$$|s| = n$$$, $$$s_i \in \{0, 1\}$$$, $$$s_1 = s_n = 0$$$) — the description of the road. It's guaranteed that the total length of all strings $$$s$$$ doesn't exceed $$$2 \cdot 10^5$$$.

Print $$$T$$$ integers — one per query. For each query print the minimum possible cost of the constructed pipeline.

NoteThe optimal pipeline for the first query is shown at the picture above.The optimal pipeline for the second query is pictured below:  The optimal (and the only possible) pipeline for the third query is shown below:  The optimal pipeline for the fourth query is shown below:

const readline = require('readline');
const process = require('process');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let lineCount = 0;
let queriesNum;
let resultArr = [];
let temp = {};
rl.on('line', function(line){
  if (lineCount === 0) {
    queriesNum = Number(line.trim());
  } else {
    if (lineCount % 2 === 0) {
      temp.arr = line.trim().split('').map((item) => Number(item));
      console.log(gasPipeline(temp))
    } else {
      let dealLine = line.trim().split(' ');
      temp.n = Number(dealLine[0]);
      temp.a = Number(dealLine[1]);
      temp.b = Number(dealLine[2]);
    }
  }
  if (resultArr.length === queriesNum) {
    rl.close();
  }
  lineCount ++;
});

function total(tempArr, prev, next, a, b) {
  let len = tempArr.length
  let minRes = (len - 1 + (prev === undefined ? 0.5 : 1.5) + (next === undefined ? 0.5 : 1.5))*a + (len - 1)* b
  let maxRes = (len - 1 + (prev === undefined ? 1.5 : 0.5) + (next === undefined ? 1.5 : 0.5))*a + (len - 1)*2* b
  return Math.min(minRes, maxRes)
}

function gasPipeline() {
  let {n, a, b, arr} = temp;
  let count = 0;
  let aMoney = 0;
  let bMoney = 2*b;
  let zeroTotal = 0;

  while (count < n) {
    let cur = arr[count];
    let prev = arr[count - 1];
    let temA = [];
    if (cur === 0) {
      while (cur === 0) {
        temA.push(cur);
        count++;
        cur = arr[count];
      }
      zeroTotal += total(temA, prev, arr[count], a, b);
      continue;
    }
    let tempB = [];
    while (cur === 1) {
      tempB.push(cur);
      count++;
      cur = arr[count];
    }
    let tempBLen = tempB.length;
    aMoney += tempBLen*a;
    bMoney += (tempBLen + 1)*2*b;
  }
  return zeroTotal + aMoney + bMoney;
}

const readline = require('readline');
const process = require('process');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let lineCount = 0;
let queriesNum;
let resultArr = [];
let temp = {};
rl.on('line', function(line){
  if (lineCount === 0) {
    queriesNum = Number(line.trim());
  } else {
    if (lineCount % 2 === 0) {
      // 偶数行
      temp.arr = line.trim().split('').map((item) => Number(item));
      resultArr.push(gasPipeline(temp))
    } else {
      // 奇数行
      let dealLine = line.trim().split(' ');
      temp.n = Number(dealLine[0]);
      temp.a = Number(dealLine[1]);
      temp.b = Number(dealLine[2]);
    }
  }
  if (resultArr.length === queriesNum) {
    console.log(resultArr.join('\n'));
    rl.close();
  }
  lineCount ++;
});

function gasPipeline() {
  let {n, a, b, arr} = temp;
  // a:管道 b:柱子
  let count = 0;
  let aMoney = 0;
  let bMoney = 2*b; // 开始结束的低柱子
  let zeroTotal = 0;

  function total(tempArr, prev, next) {
    // 全为低
    let len = tempArr.length
    // 全为低柱子
    let minRes = (len - 1 + (prev === undefined ? 0.5 : 1.5) + (next === undefined ? 0.5 : 1.5))*a + (len - 1)* b
    // 全为高柱子
    let maxRes = (len - 1 + (prev === undefined ? 1.5 : 0.5) + (next === undefined ? 1.5 : 0.5))*a + (len - 1)*2* b
    return Math.min(minRes, maxRes)
  }

  while (count < n) {
    let cur = arr[count];
    let prev = arr[count - 1];
    let temA = [];
    if (cur === 0) {
      // 当前为0时
      while (cur === 0) {
        temA.push(cur);
        count++;
        cur = arr[count];
      }
      zeroTotal += total(temA, prev, arr[count]);
      continue;
    }
    let tempB = [];
    while (cur === 1) {
      tempB.push(cur);
      count++;
      cur = arr[count];
    }
    let tempBLen = tempB.length;
    aMoney += tempBLen*a;
    // 高柱子
    bMoney += (tempBLen + 1)*2*b;
  }
  return zeroTotal + aMoney + bMoney;
}

const readline = require('readline');
const process = require('process');
const rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});
let lineCount = 0;
let queriesNum;
let resultArr = [];
let temp = {};
rl.on('line', function(line){
  if (lineCount === 0) {
    queriesNum = Number(line.trim());
  } else {
    if (lineCount % 2 === 0) {
      temp.arr = line.trim().split('').map((item) => Number(item));
      console.log(gasPipeline(temp))
    } else {
      let dealLine = line.trim().split(' ');
      temp.n = Number(dealLine[0]);
      temp.a = Number(dealLine[1]);
      temp.b = Number(dealLine[2]);
    }
  }
  if (resultArr.length === queriesNum) {
    rl.close();
  }
  lineCount ++;
});

function total(tempArr, prev, next, a, b) {
  let len = tempArr.length
  let minRes = (len - 1 + (prev === undefined ? 0.5 : 1.5) + (next === undefined ? 0.5 : 1.5))*a + (len - 1)* b
  let maxRes = (len - 1 + (prev === undefined ? 1.5 : 0.5) + (next === undefined ? 1.5 : 0.5))*a + (len - 1)*2* b
  return Math.min(minRes, maxRes)
}

function gasPipeline(temp) {
  let {n, a, b, arr} = temp;
  let count = 0;
  let aMoney = 0;
  let bMoney = 2*b;
  let zeroTotal = 0;

  while (count < n) {
    let cur = arr[count];
    let prev = arr[count - 1];
    let temA = [];
    if (cur === 0) {
      while (cur === 0) {
        temA.push(cur);
        count++;
        cur = arr[count];
      }
      zeroTotal += total(temA, prev, arr[count], a, b);
      continue;
    }
    let tempB = [];
    while (cur === 1) {
      tempB.push(cur);
      count++;
      cur = arr[count];
    }
    let tempBLen = tempB.length;
    aMoney += tempBLen*a;
    bMoney += (tempBLen + 1)*2*b;
  }
  return zeroTotal + aMoney + bMoney;
}