We have a secret array. You don't know this array and you have to restore it. However, you know some facts about this array:  The array consists of $$$n$$$ distinct positive (greater than $$$0$$$) integers.  The array contains two elements $$$x$$$ and $$$y$$$ (these elements are known for you) such that $$$x < y$$$.  If you sort the array in increasing order (such that $$$a_1 < a_2 < \ldots < a_n$$$), differences between all adjacent (consecutive) elements are equal (i.e. $$$a_2 - a_1 = a_3 - a_2 = \ldots = a_n - a_{n-1})$$$. It can be proven that such an array always exists under the constraints given below.Among all possible arrays that satisfy the given conditions, we ask you to restore one which has the minimum possible maximum element. In other words, you have to minimize $$$\max(a_1, a_2, \dots, a_n)$$$.You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases. Then $$$t$$$ test cases follow. The only line of the test case contains three integers $$$n$$$, $$$x$$$ and $$$y$$$ ($$$2 \le n \le 50$$$; $$$1 \le x < y \le 50$$$) — the length of the array and two elements that are present in the array, respectively.

For each test case, print the answer: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the $$$i$$$-th element of the required array. If there are several answers, you can print any (it also means that the order of elements doesn't matter). It can be proven that such an array always exists under the given constraints.

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 mul = (a, b) => mod(mod(a) * mod(b));

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

    for (let start = 1; start <= 50; start++) {
      for (let diff = 1; diff <= 50; diff++) {
        const arr = [start];
        let [foundA, foundB] = [false, false];
        for (let i = 1; i < len; i++) {
          arr.push(start + diff * i);
        }
        for (let i = 0; i < len; i++) {
          if (arr[i] === a) foundA = true;
          if (arr[i] === b) foundB = true;
        }
        if (foundA && foundB) {
          if (arr[len - 1] < min) {
            min = arr[len - 1];
            result = [...arr];
          }
        }
      }
    }
    console.log(result.join(" "));
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
  var t = nextInt();
  var output = new Array(t);
  for(var i = 0; i < t; i++){
    var one = nextIntArray();
    var N = one[0];
    var x = one[1];
    var y = one[2];
    if(N == 2){
      output[i] = x + " " + y;
      continue;
    }
    var dlist = getDivisorList(y - x);
    var out = [];
    var max = Math.pow(10,9);
    for(var j = 0; j < dlist.length; j++){
      var tmpmax = y;
      var tmpout = [x];
      var isOK = false;
      for(var k = 1; k <= N; k++){
        if(x + k * dlist[j] > y){
          isOK = true;
          break;
        }
        tmpout.push(x + k * dlist[j]);

      }
      //myerr(tmpout);
      if(isOK && tmpout.length <= N){
        for(var k = 1; k <= N; k++){
          if(tmpout.length == N){
            break;
          }
          if(x - dlist[j] * k < 1){
            break;
          }
          tmpout.unshift(x - dlist[j] * k);

        }
        while(tmpout.length < N){
          tmpout.push(tmpout[tmpout.length - 1] + dlist[j]);
          tmpmax = tmpout[tmpout.length - 1];
        }
        if(max > tmpmax){
          max = tmpmax;
          out = tmpout;
        }
        //myerr(tmpout);
      }else{
        continue;
      }
    }
    output[i] = myconv(out, 8);
  }
  myout(myconv(output, 9));
}
function getDivisorList(val){
  var list = [];
  for(var i = 1; i * i <= val; i++){
    if(val % i == 0){
      list.push(i);
      if(i * i != val){
        list.push(val / i);
      }
    }
  }
  list.sort(function(a,b){ return a - b; });
  return list;
}

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

let input = [];

rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solve(input);
  process.exit();
});

function solve(input) {
  const t = input[0];

  for (let i = 1; i <= t; i++) {
    let [n, x, y] = input[i].split(" ").map((num) => Number(num));

    if (n === 2) {
      console.log([x, y].join(" "));
      continue;
    }

    const diff = y - x;
    const result = [];

    //1. x와 y사이에는 (n-2)개 ~ 0개의 원소가 존재할 수 있다.
    for (let j = n - 1; j >= 0; j--) {
      const equalDiff = diff / j;

      //2. 정수로 나뉘어 떨어지지 않는다면 해당 개수는 불가능
      if (equalDiff !== parseInt(equalDiff)) {
        continue;
      }

      //3. 정수로 나누어 떨어진다면 해당 배열이 답이다
      //3-1. x와 y 넣기
      result.push(x);
      result.push(y);
      n -= 2;

      //3-2. x와 y 사이 넣기
      for (let k = 1; k <= j - 1; k++) {
        n--;
        result.push(x + k * equalDiff);
      }

      //3-3. x 이전 넣기
      for (let k = 1; ; k++) {
        if (n <= 0) break;

        const xBefore = x - k * equalDiff;
        if (xBefore <= 0) break;

        n--;
        result.push(xBefore);
      }

      //3-4. y 이후 넣기
      for (let k = 1; ; k++) {
        if (n <= 0) break;

        const yAfter = y + k * equalDiff;
        n--;
        result.push(yAfter);
      }

      //7. 최댓값이 존재하는 배열을 만들어 출력한다
      console.log(result.join(" "));
      break;
    }
  }
}

/*

  1. 비밀 배열을 복원해야 한다
  2. n개의 서로 다른 양의 정수를 포함하고 있다
  3. 너에게 알려진 x와 y를 포함하고 있는데, x < y
  4. 오름차순으로 정렬 시, 각 인접 원소 간의 diff는 모두 동일

  Q. 가장 큰 원소의 값이 최소가 되는 배열의 원소들을 출력하라

*/

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

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

function Arr(a, b, cb) {
  if (a < b) return Array(b - a + 1).fill(0).map((v, i) => cb(i + a));
  return Array(a - b + 1).fill(0).map((v, i) => cb(a - i));
}

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

function max(a, b) {
  if (a > b) return a;
  return b;
}

(async () => {
  await inputPromise;
  let inp = input.split(/\D+/).map(v => +v); r = 0;
  let t = inp[r++];
  For(0, t - 1, i => {
    let [n, x, y] = inp.slice(r, r = r + 3);
    // console.log(n, x, y);
    For(n - 1, 1, i => {
      if ((y - x) % i == 0) {
        let k = (y - x) / i;
        a = Arr(0, i, i => x + i * k);
        while (a.length < n) {
          if (a[0] - k >= 1) a.unshift(a[0] - k);
          else a.push(a[a.length - 1] + k);
        }
        console.log(a.join(' '));
        return 0;
      }
    })
  })
})();

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

    C();
});

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

function pi(a) {
    return parseInt(a);
}

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = pi(a[i]);

    return a;
}

function A(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [a,b] = ti(readline().split(' '));

        if(a === b){
            console.log(0);
            continue;
        }

        let d = Math.abs(a-b);
        if(d <= 10){
            console.log(1);
            continue;
        }else{
            if(d % 10 !== 0)
                console.log(1 + Math.floor(d/10));
            else
                console.log(d / 10);
        }
    }
}

function B(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [a,b,x,y,n] = ti(readline().split(' '));

        if(a > b){
            let temp = a;
            a = b;
            b = temp;
            temp = x;
            x = y;
            y = temp;
        }

        if(b - y >= n){
            b -= n;
            console.log(a*b);
        }else{
            n -= (b-y);
            b = y;
            if(a-x >= n){
                a -= n;
            }else{
                a = x;
            }

            console.log(a*b);
        }
    }
}

function C(){
    let t = pi(readline());
    while(t > 0){
        t--;
        let [n,x,y] = ti(readline().split(' '));

        let min = 99999999999999;
        let res = null;
        for(let i = 1; i <= x; i++){
            for(let j = 0; j <= y-x; j++){
                let inclX = false;
                let inclY = false;
                let op = new Array(n);
                for(let k = 0; k < n; k++){
                    if(k === 0){
                        op[k] = i;
                    }else{
                        op[k] = op[k-1] + j;
                    }

                    if(op[k] === x)
                        inclX = true;

                    if(op[k] === y)
                        inclY = true;
                }

                if(inclX && inclY){
                    if(min > op[n-1]){
                        min = op[n-1];
                        res = op;
                    }
                }
            }
        }

        for(let num of res)
            console.log(num);
    }
}

T = readline()
while (T--) {
  a = readline().split(' ')
  n = +a[0]
  x = +a[1]
  y = +a[2]
  d = y - x
  k = 1
  for (; k < 50; k++) {
    if (d % k)
      continue
    if (d / k + 1 <= n)
      break
  }
  j = n - 1
  while (y - j * k < 1)
    j--
  u = y - j * k
  ans = ''
  for (i = 0; i < n; i++) {
    ans += u.toString() + ' '
    u += k
  }
  print(ans)
}

T = readline()
while (T--) {
  a = readline().split(' ').map(x => +x)
  n = a[0]; x = a[1]; y = a[2]
  d = y - x
  k = 1
  for (; k < 50; k++) {
    if (d % k)
      continue
    if (d / k + 1 <= n)
      break
  }
  j = n - 1
  while (y - j * k < 1)
    j--
  u = y - j * k
  print(Array.from({ length: n }, (v, i) => u + k * i).join(' '));
}

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

let input = [];

rl.on("line", function (line) {
  input.push(line);
}).on("close", function () {
  solve(input);
  process.exit();
});

function solve(input) {
  const t = input[0];

  for (let i = 1; i <= t; i++) {
    let [n, x, y] = input[i].split(" ").map((num) => Number(num));

    if (n === 2) {
      console.log([x, y]);
      continue;
    }

    const diff = y - x;
    const result = [];

    //1. x와 y사이에는 (n-2)개 ~ 0개의 원소가 존재할 수 있다.
    for (let j = n - 1; j >= 0; j--) {
      const equalDiff = diff / j;

      //2. 정수로 나뉘어 떨어지지 않는다면 해당 개수는 불가능
      if (equalDiff !== parseInt(equalDiff)) {
        continue;
      }

      //3. 정수로 나누어 떨어진다면 해당 배열이 답이다
      //3-1. x와 y 넣기
      result.push(x);
      result.push(y);
      n -= 2;

      //3-2. x와 y 사이 넣기
      for (let k = 1; k <= j - 1; k++) {
        n--;
        result.push(x + k * equalDiff);
      }

      //3-3. x 이전 넣기
      for (let k = 1; ; k++) {
        if (n <= 0) break;

        const xBefore = x - k * equalDiff;
        if (xBefore <= 0) break;

        n--;
        result.push(xBefore);
      }

      //3-4. y 이후 넣기
      for (let k = 1; ; k++) {
        if (n <= 0) break;

        const yAfter = y + k * equalDiff;
        n--;
        result.push(yAfter);
      }

      //6. 정렬
      result.sort((n1, n2) => {
        return n1 - n2;
      });

      //7. 최댓값이 존재하는 배열을 만들어 출력한다
      console.log(result);
      break;
    }
  }
}

/*

  1. 비밀 배열을 복원해야 한다
  2. n개의 서로 다른 양의 정수를 포함하고 있다
  3. 너에게 알려진 x와 y를 포함하고 있는데, x < y
  4. 오름차순으로 정렬 시, 각 인접 원소 간의 diff는 모두 동일

  Q. 가장 큰 원소의 값이 최소가 되는 배열의 원소들을 출력하라

*/


Young wilderness explorers set off to their first expedition led by senior explorer Russell. Explorers went into a forest, set up a camp and decided to split into groups to explore as much interesting locations as possible. Russell was trying to form groups, but ran into some difficulties...Most of the young explorers are inexperienced, and sending them alone would be a mistake. Even Russell himself became senior explorer not long ago. Each of young explorers has a positive integer parameter $$$e_i$$$ — his inexperience. Russell decided that an explorer with inexperience $$$e$$$ can only join the group of $$$e$$$ or more people.Now Russell needs to figure out how many groups he can organize. It's not necessary to include every explorer in one of the groups: some can stay in the camp. Russell is worried about this expedition, so he asked you to help him.

The first line contains the number of independent test cases $$$T$$$($$$1 \leq T \leq 2 \cdot 10^5$$$). Next $$$2T$$$ lines contain description of test cases. The first line of description of each test case contains the number of young explorers $$$N$$$ ($$$1 \leq N \leq 2 \cdot 10^5$$$). The second line contains $$$N$$$ integers $$$e_1, e_2, \ldots, e_N$$$ ($$$1 \leq e_i \leq N$$$), where $$$e_i$$$ is the inexperience of the $$$i$$$-th explorer. It's guaranteed that sum of all $$$N$$$ doesn't exceed $$$3 \cdot 10^5$$$.

Print $$$T$$$ numbers, each number on a separate line. In $$$i$$$-th line print the maximum number of groups Russell can form in $$$i$$$-th test case.

NoteIn the first example we can organize three groups. There will be only one explorer in each group. It's correct because inexperience of each explorer equals to $$$1$$$, so it's not less than the size of his group.In the second example we can organize two groups. Explorers with inexperience $$$1$$$, $$$2$$$ and $$$3$$$ will form the first group, and the other two explorers with inexperience equal to $$$2$$$ will form the second group.This solution is not unique. For example, we can form the first group using the three explorers with inexperience equal to $$$2$$$, and the second group using only one explorer with inexperience equal to $$$1$$$. In this case the young explorer with inexperience equal to $$$3$$$ will not be included in any group.

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextIntArray();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var map = {};
		for(var j = 0; j < N; j++){
			if(map[list[j]] == null){
				map[list[j]] = 1;
			}else{
				map[list[j]]++;
			}
		}
		var keys = Object.keys(map);
		keys.sort(function(a,b){
			return a - b;
		});
		var count = 0;
		for(var j = 0; j < keys.length; j++){
			var singleCount = Math.floor(map[keys[j]] / keys[j]);
			var nokori = map[keys[j]] % keys[j];
			count += singleCount;
			if(j != keys.length - 1){
				map[keys[j + 1]] += nokori;
			}
		}
		output[i] = count;
	}
	myout(myconv(output,9));
}

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const e = lines[i*2+2].split(' ').map(x => +x).sort((a, b) => a-b).reduce((r, x, index) => {
      if (index > 0) {
        if (r[r.length - 1][0] === x) {
          r[r.length - 1][1]++
        } else {
          r.push([x, 1])
        }
      } else {
        r.push([x, 1])
      }
      return r
    }, [])
    let sum = 0
    let rest = 0
    for (let j=0; j<e.length; j++) {
      const num =  e[j][0]
      const count = rest + e[j][1]
      if (count >= num) {
        sum += Math.floor(count/num)
        rest = count % num
      } else {
        rest += e[j][1]
      }
    }
    console.log(sum)
    // while(start < e.length) {
    //   start += e[start]
    //   c++
    // }
    // if (start > e.length) {
    //   c--
    // }
    // console.log(c)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

'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++];
}
/**
    6
1
2
3
4
5
6

**/

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

    return gcd(b, a % b);
};

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline())
        let a = readline().split(" ").map(Number);

        a.sort((a, b) => a - b);
        let temp = 0;
        let ans = 0;

        for(let i=0;i<n;i++) {
            temp++;

            if(a[i] <= temp) {
                ans++;
                temp = 0;
            }
        }

        console.log(ans);
    }
}

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextIntArray();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var map = {};
		for(var j = 0; j < N; j++){
			if(map[list[j]] == null){
				map[list[j]] = 1;
			}else{
				map[list[j]]++;
			}
		}
		var keys = Object.keys(map);
		keys.sort(function(a,b){
			return a - b;
		});
		var count = 0;
		for(var j = 0; j < keys.length; j++){
			var singleCount = Math.floor(map[keys[j]] / keys[j]);
			var nokori = map[keys[j]] % keys[j];
			count += singleCount;
			map[keys[j] + 1] += nokori;
		}
		output[i] = count;
	}
	myout(myconv(output,9));
}

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const e = lines[i*2+2].split(' ').map(x => +x).sort((a, b) => a-b).reduce((r, x, index) => {
      if (index > 0) {
        if (r[r.length - 1][0] === x) {
          r[r.length - 1][1]++
        } else {
          r.push([x, 1])
        }
      } else {
        r.push([x, 1])
      }
      return r
    }, [])
    let sum = 0
    let rest = 0
    for (let j=0; j<e.length; j++) {
      const num =  e[j][0]
      const count = rest + e[j][1]
      if (count >= num) {
        sum += Math.floor(count/num)
        rest = count % num
      }
    }
    console.log(sum)
    // while(start < e.length) {
    //   start += e[start]
    //   c++
    // }
    // if (start > e.length) {
    //   c--
    // }
    // console.log(c)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const e = lines[i*2+2].split(' ').map(x => +x)
    e.sort((a, b) => b - a)
    let start = 0
    let c = 0
    while(start < e.length) {
      start += e[start]
      c++
    }
    console.log(c)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

'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++];
}
/**
    6
1
2
3
4
5
6

**/

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

    return gcd(b, a % b);
};

let clone = Array.push;

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        let unique = new Set([...a]);

        if(unique.size === 1) {
            console.log(n);
            continue;
        }

        a = [...unique];
        a.sort((a, b) => a - b);

        let count = 0;
        while(a.length) {
            a.shift();
            a.pop();
            count++
        }

        console.log(count);

    }
}

'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++];
}
/**
    6
1
2
3
4
5
6

**/

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

    return gcd(b, a % b);
};

let clone = Array.push;

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

    for(let r=0;r<range;r++) {
        let n = parseInt(readline());
        let a = readline().split(" ").map(Number);
        let unique = new Set([...a]);

        if(unique.size === 1) {
            console.log(n);
            continue;
        }

        console.log(n - unique.size);

    }
}


Vasya claims that he had a paper square. He cut it into two rectangular parts using one vertical or horizontal cut. Then Vasya informed you the dimensions of these two rectangular parts. You need to check whether Vasya originally had a square. In other words, check if it is possible to make a square using two given rectangles.

The first line contains an integer $$$t$$$ ($$$1 \le t \le 10^4$$$) — the number of test cases in the input. Then $$$t$$$ test cases follow. Each test case is given in two lines. The first line contains two integers $$$a_1$$$ and $$$b_1$$$ ($$$1 \le a_1, b_1 \le 100$$$) — the dimensions of the first one obtained after cutting rectangle. The sizes are given in random order (that is, it is not known which of the numbers is the width, and which of the numbers is the length). The second line contains two integers $$$a_2$$$ and $$$b_2$$$ ($$$1 \le a_2, b_2 \le 100$$$) — the dimensions of the second obtained after cutting rectangle. The sizes are given in random order (that is, it is not known which of the numbers is the width, and which of the numbers is the length).

Print $$$t$$$ answers, each of which is a string "YES" (in the case of a positive answer) or "NO" (in the case of a negative answer). The letters in words can be printed in any case (upper or lower).

function max(a, b) {
    return (a > b ? a : b);
}

function min(a, b) {
    return (a > b ? b : a);
}

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

for (var i = 0; i < n; i++) {
    var line = readline().split(' ');
    var x = parseInt(line[0]), y = parseInt(line[1]);
    line = readline().split(' ');
    var a = parseInt(line[0]), b = parseInt(line[1]);
    if (max(x, y) == max(a, b) && min(x, y) + min(a, b) == max(x, y)) print("YES");
    else print("NO");
}

var t = Number(readline());
while(t--) {
    var v = readline().split(" ");
    var a1 = Number(v[0]);
    var b1 = Number(v[1]);

    v = readline().split(" ");
    var a2 = Number(v[0]);
    var b2 = Number(v[1]);

    if ((a1 == a2 && b1+b2 == a1) || (b1 == b2 && a1+a2 == b1)) print("YES");
    else if ((a1 == b2 && b1+a2 == a1) || (b1 == a2 && a1+b2 == b1)) print("YES");
    else print("NO");
}

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

    main();
});

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

function main() {
    const n = parseInt(readLine(), 10);
    for (let i = 0; i < n; i++) {
        const [a, b] = readLine().split(' ').map(x => parseInt(x));
        const [c, d] = readLine().split(' ').map(x => parseInt(x));
        if ((a == c && (b+d) ==a ) || (a == d && (b + c) == a) || (c == b && (a+d) ==c ) || (b == d && (a+c) ==b ) ){
            console.log('YES')
        } else console.log('NO')
    }
    return;
}

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

let tc
let slice1,slice2;
r.on('line', (line) => {
    if (!tc) { tc = line; }
    else if (!slice1) {
        slice1 = line;

    }
    else if (!slice2) {
        slice2 = line;
        let d1 = slice1.split(" ").map(n =>+n);
        let d2 = slice2.split(" ").map(n =>+n);
        console.log(  sq(d1[0],d1[1],d2[0],d2[1]) ?"YES":"NO");
        slice1= slice2= undefined;
    }
    else {
        query = readNums(line);
        console.log(minLength(arr, query[0], query[1]));
    }

});

function sq(a,b,c,d){
    return (a==c && a == (b+d)) || (a==d && a == (b+c)) ||((b==c && b == (a+d))) ||((b==d && b == (a+c)))
}

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var mae = nextIntArray();
		var ato = nextIntArray();
		if(mae[0] == ato[0] || mae[0] == ato[1] || mae[1] == ato[0] || mae[1] == ato[1]){
			if(mae[0] == ato[0]){
				if(mae[1] + ato[1] == mae[0]){
					output[i] = "YES";
				}
			}
			if(mae[0] == ato[1]){
				if(mae[1] + ato[0] == mae[0]){
					output[i] = "YES";
				}
			}
			if(mae[1] == ato[0]){
				if(mae[0] + ato[1] == mae[1]){
					output[i] = "YES";
				}
			}
			if(mae[1] == ato[1]){
				if(mae[0] + ato[0] == mae[1]){
					output[i] = "YES";
				}
			}
			if(output[i] == null){
				output[i] = "NO";
			}
		}else{
			output[i] = "NO";
		}
	}
	myout(myconv(output,9));
}

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

let tc
let slice1, slice2;
r.on('line', (line) => {
  if (!tc) { tc = line; }
  else if (!slice1) {
    slice1 = line;

  }
  else if (!slice2) {
    slice2 = line;
    let d1 = slice1.split(" ").map(n => +n);
    let d2 = slice2.split(" ").map(n => +n);
    console.log(sq(d1[0], d1[1], d2[0], d2[1]) ? "YES" : "NO");
    slice1 = slice2 = undefined;
  }
  else {
    query = readNums(line);
    console.log(minLength(arr, query[0], query[1]));
  }

});

function sq(a, b, c, d) {
  return (a == c && a == (b + d)) || (a == d && a == (b + c)) || ((b == c && b == (a + d))) || ((b == d && b == (a + c)))
}

const processData = (lines) => {
  const n = +lines[0]
  for (let i=0; i<n; i++) {
    const [a, b] = lines[i*2+1].split(' ').map(x => +x).sort((a, b) => b-a)
    const [c, d] = lines[i*2+2].split(' ').map(x => +x).sort((a, b) => b-a)
    if (a === c && b+d === a) {
      console.log('Yes')
    } else {
      console.log('No')
    }
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})

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

var N = null,
    ab = null

function loop(line) {

    if (line.trim() == "")
        return

    let cd = line.split(" ")
                 .map(x => parseInt(x,10))
                 .sort((x,y) => x-y)

    if (ab == null)
        return ab = cd

    if (ab[1] == cd[1] && ab[0] + cd[0] == ab[1])
        console.log("Yes")
    else
        console.log("No")

    ab = --N == 0 ? rl.close() : null

}

rl.question("", line => {
    N = parseInt(line,10)
    rl.on("line", loop)
})

'use strict';

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

let inputString = '';
let currentLine = 0;

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

process.stdin.on('end', _ => {
    inputString = inputString.replace(/\s*$/, '')
        .split('\n')
        .map(str => str.replace(/\s*$/, ''));

    main();
});

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

function main() {
    let n = parseInt(readLine());
    for (var i = 0; i < n; i++) {
        let arr = [];
        arr.push(readLine()
            .split(' ')
            .map(value => parseInt(value))
            .sort((a, b) => b - a)
        );
        arr.push(readLine()
            .split(' ')
            .map(value => parseInt(value))
            .sort((a, b) => b - a)
        );
        if (arr[0][0] == arr[1][0]) {
            if (arr[0][1] + arr[1][1] == arr[0][0]) {
                console.log('YES');
            } else
                console.log('NO')
        } else console.log('NO');
    }
}

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

    main();
});

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

function main() {
    const n = parseInt(readLine(), 10);
    for (let i = 0; i < n; i++) {
        const [a, b] = readLine().split(' ').map(x => parseInt(x));
        const [c, d] = readLine().split(' ').map(x => parseInt(x));
        if (Math.sqrt((a*b) + (c*d))%1 ==0){
            console.log('YES')
        } else console.log('NO')
    }
    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(str => str.trim());

    main();
});

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

function main() {
    const n = parseInt(readLine(), 10);
    for (let i = 0; i < n; i++) {
        const [a, b] = readLine().split(' ').map(x => parseInt(x));
        const [c, d] = readLine().split(' ').map(x => parseInt(x));
        const totalArea = (a*b) + (c*d);
        if (totalArea > 3 && Math.sqrt(totalArea)%1 ==0){
            console.log('YES')
        } else console.log('NO')
    }
    return;
}

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);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
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){
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
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;}}
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var mae = nextIntArray();
		var ato = nextIntArray();

		if(mae[0] == ato[0] || mae[0] == ato[1] || mae[1] == ato[0] || mae[1] == ato[1]){
			if(mae[0] == ato[0]){
				if(mae[1] + ato[1] == mae[0]){
					output[i] = "YES";
				}
			}else if(mae[0] == ato[1]){
				if(mae[1] + ato[0] == mae[0]){
					output[i] = "YES";
				}
			}else if(mae[1] == ato[0]){
				if(mae[0] + ato[1] == mae[1]){
					output[i] = "YES";
				}
			}else if(mae[1] == ato[1]){
				if(mae[0] + ato[0] == mae[1]){
					output[i] = "YES";
				}
			}
			if(output[i] == null){
				output[i] = "NO";
			}
		}else{
			output[i] = "NO";
		}
	}
	myout(myconv(output,9));
}

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

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

  if (c % 2) {
    [a1, b1] = d.split(' ').map(Number);
    c++;
    return;
  }

  [a2, b2] = d.split(' ').map(Number);

  if (a1 + a2 === b1 || a1 + b2 === b1) {
    console.log('YES');
  }
  else if (b1 + a2 === a1 || b1 + b2 === a1) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

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

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

  if (c % 2) {
    [a1, b1] = d.split(' ').map(Number);
    c++;
    return;
  }

  [a2, b2] = d.split(' ').map(Number);

  if (a1 === a2 || a1 === b2) {
    if (b1 + a2 === a1 || b1 + b2 === a1) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }
  else if (b1 === a2 || b1 === b2) {
    if (a1 + a2 === b1 || a1 + b2 === b1) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }
  else {
    console.log('NO');
  }

  c++;
});

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

function sq(a, b, c, d) {
  return (a == c && a == (b + d)) || (a == d && a == (b + c)) || ((b == c && b == (a + d))) || ((b == d && b == (a + c)))
}

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

  if (count % 2) {
    [a, b] = data.split(' ').map(Number);
    count++;
    return;
  }

  [c, d] = data.split(' ').map(Number);

  console.log(sq(a, b, c, d) ? "YES" : "NO");

  count++;
});

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

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

  if (count % 2) {
    [a, b] = data.split(' ').map(Number);
    count++;
    return;
  }

  if (tests === 0) {
    return;
  }

  tests--;
  [c, d] = data.split(' ').map(Number);

  if (a > b) {
    [a, b] = [b, a];
  }

  if (c > d) {
    [c, d] = [d, c];
  }

  if (b === d && a + c === b) {
    console.log('YES');
  }
  else {
    console.log('No');
  }

  count++;
});

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

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

  if (count % 2) {
    [a, b] = data.split(' ').map(Number);
    count++;
    return;
  }

  [c, d] = data.split(' ').map(Number);

  if (a > b) {
    [a, b] = [b, a];
  }

  if (c > d) {
    [c, d] = [d, c];
  }

  if (b === d && a + c === b) {
    console.log('YES');
  }
  else {
    console.log('No');
  }

  count++;
});

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

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

  if (c % 2) {
    [a1, b1] = d.split(' ').map(Number);
    c++;
    return;
  }

  [a2, b2] = d.split(' ').map(Number);

  if (a1 === a2 || a1 === b2) {
    if (b1 + a2 === a1 || b1 + b2 === a1) {
      console.log('YES');
    }
    else if (a1 + b1 === a2 + b2) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }
  else if (b1 === a2 || b1 === b2) {
    if (a1 + a2 === b1 || a1 + b2 === b1) {
      console.log('YES');
    }
    else if (a1 + b1 === a2 + b2) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }
  else {
    console.log('NO');
  }

  c++;
});

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

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

  if (c % 2) {
    [a1, b1] = d.split(' ').map(Number);
    c++;
    return;
  }

  [a2, b2] = d.split(' ').map(Number);

  if (a1 === a2 || a1 === b2) {
    if (b1 + a2 === a1 || b1 + b2 === a1) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }
  else if (b1 === a2 || b1 === b2) {
    if (a1 + a2 === b1 || a1 + b2 === b1) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }
  else {
    if (a1 + b1 === a2 + b2) {
      console.log('YES');
    }
    else {
      console.log('NO');
    }
  }

  c++;
});

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

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

  if (c % 2) {
    arr1 = d.split(' ').map(Number);
    arr1.sort((a, b) => a - b);
    c++;
    return;
  }

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

  if (arr1[0] + arr2[0] === arr1[1] && arr1[1] === arr2[1]) {
    console.log('YES');
  }
  else {
    console.log('NO');
  }

  c++;
});

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

rl.on('line', (d) => {

  c++;
});

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

});

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

function dotest(t) {
    rl.question("", ab => {
        ab = ab.split(" ").map(Number).sort()
        rl.question("", cd => {
            cd = cd.split(" ").map(Number).sort()
            if (ab[1] == cd[1] && ab[0] + cd[0] == ab[1]) {
                console.log("Yes")
            } else {
                console.log("No")
            }
            t == 1 ? rl.close():dotest(t-1)
        })
    })
}

rl.question("", t => dotest(Number(t)))

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

var t = null,
    ab = null

function loop(line) {

    if (t == null) return t = Number(line)

    const cd = line.split(" ").map(Number).sort()

    if (ab == null) {
        ab = cd
    } else {
        if (ab[1] == cd[1] && ab[0] + cd[0] == ab[1])
            console.log("Yes")
        else
            console.log("No")
        if (--t == 0)
            rl.close()
        else
            ab = null
    }

}

rl.on("line", line => loop(line))

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

var N = null,
    ab = null

function loop(line) {

    let cd = line.split(" ").map(Number).sort((x,y) => x-y)

    if (ab == null)
        return ab = cd

    if (ab[1] == cd[1] && ab[0] + cd[0] == ab[1])
        console.log("Yes")
    else
        console.log("No")

    ab = --N == 0 ? rl.close() : null

}

rl.question("", line => {
    N = parseInt(line,10)
    rl.on("line", line => loop(line))
})

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

function dotest(t) {
    rl.question("", ab => {
        ab = ab.split(" ").map(Number).sort()
        rl.question("", cd => {
            cd = cd.split(" ").map(Number).sort()
            if (ab[1] != cd[1] || ab[0] == ab[1] || cd[0] == cd[1]) {
                console.log("No")
            } else if (ab[0] + cd[0] == ab[1]) {
                console.log("Yes")
            }
            t == 1 ? rl.close():dotest(t-1)
        })
    })
}

rl.question("", t => dotest(Number(t)))

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

function dotest(t) {
    rl.question("", ab => {
        ab = ab.split(" ").map(Number).sort()
        rl.question("", cd => {
            cd = cd.split(" ").map(Number).sort()
            if (ab[0] != ab[1] && cd[0] != cd[1] && ab[1] == cd[1] && (ab[0] + cd[0]) == ab[1]) {
                console.log("Yes")
            } else {
                console.log("No")
            }
            t == 1 ? rl.close():dotest(t-1)
        })
    })
}

rl.question("", t => dotest(Number(t)))

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

function dotest(t) {
    rl.question("", ab => {
        ab = ab.split(" ").map(Number)
        rl.question("", cd => {
            cd = cd.split(" ").map(Number)
            if (ab[0] == ab[1] || cd[0] == cd[1]) {
                console.log("No")
            } else {
            let abcd = ab.concat(cd).sort()
            if (abcd[2] == abcd[3] && abcd[0] + abcd[1] == abcd[2])
                console.log("Yes")
            else
                console.log("No")
            }
            t == 1 ? rl.close():dotest(t-1)
        })
    })
}

rl.question("", t => dotest(Number(t)))

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

function dotest(t) {
    rl.question("", ab => {
        ab = ab.split(" ")//.map(Number).sort()
        a = Number(ab[0])
        b = Number(ab[1])
        rl.question("", cd => {
            cd = cd.split(" ")//.map(Number).sort()
            c = Number(cd[0])
            d = Number(cd[1])
            if ((a==c && b+d==a) || (a==d && b+c==a) || (b==c && a+d==b) || (b==d && a+c==b)) {
                console.log("Yes")
            } else {
                console.log("No")
            }
            t == 1 ? rl.close():dotest(t-1)
        })
    })
}

rl.question("", t => dotest(Number(t)))

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

function dotest(t) {
    rl.question("", ab => {
        ab = ab.split(" ").map(Number).sort()
        rl.question("", cd => {
            cd = cd.split(" ").map(Number).sort()
            if (ab[0] + cd[0] == ab[1] && ab[0] + cd[0] == cd[1]) {
                console.log("Yes")
            } else {
                console.log("No")
            }
            t == 1 ? rl.close():dotest(t-1)
        })
    })
}

rl.question("", t => dotest(Number(t)))

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

var t = null,
    ab = null

function loop(line) {

    if (t == null) return t = Number(line)

    const cd = line.split(" ").map(Number).sort()

    if (ab == null) {
        ab = cd
    } else {
        if (ab[1] == cd[1] && ab[0] + cd[0] == ab[1])
            console.log("Yes")
        else
            console.log("No")
        if (--t == 0)
            rl.close()
        else
            ab = null
        console.log(t)
    }

}

rl.on("line", line => loop(line))

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

var N = null,
    ab = null

function loop(line) {

    let cd = line.split(" ")
                 .map(x => parseInt(x,10))
                 .sort((x,y) => x-y)

    if (ab == null)
        return ab = cd

    if (ab[1] == cd[1] && ab[0] + cd[0] == ab[1])
        console.log("Yes")
    else
        console.log("No")

    ab = --N == 0 ? rl.close() : null

}

rl.question("", line => {
    N = parseInt(line,10)
    rl.on("line", loop)
})


You may have already known that a standard ICPC team consists of exactly three members. The perfect team however has more restrictions. A student can have some specialization: coder or mathematician. She/he can have no specialization, but can't have both at the same time.So the team is considered perfect if it includes at least one coder, at least one mathematician and it consists of exactly three members.You are a coach at a very large university and you know that $$$c$$$ of your students are coders, $$$m$$$ are mathematicians and $$$x$$$ have no specialization.What is the maximum number of full perfect teams you can distribute them into? Note that some students can be left without a team and each student can be a part of no more than one team.You are also asked to answer $$$q$$$ independent queries.

The first line contains a single integer $$$q$$$ ($$$1 \le q \le 10^4$$$) — the number of queries.  Each of the next $$$q$$$ lines contains three integers $$$c$$$, $$$m$$$ and $$$x$$$ ($$$0 \le c, m, x \le 10^8$$$) — the number of coders, mathematicians and students without any specialization in the university, respectively. Note that the no student is both coder and mathematician at the same time.

Print $$$q$$$ integers — the $$$i$$$-th of them should be the answer to the $$$i$$$ query in the order they are given in the input. The answer is the maximum number of full perfect teams you can distribute your students into.

NoteIn the first example here are how teams are formed:  the only team of 1 coder, 1 mathematician and 1 without specialization;  all three teams consist of 1 coder and 2 mathematicians;  no teams can be formed;  no teams can be formed;  one team consists of 1 coder, 1 mathematician and 1 without specialization, the rest aren't able to form any team;  one team consists of 1 coder, 1 mathematician and 1 without specialization, one consists of 2 coders and 1 mathematician and one consists of 1 coder and 2 mathematicians.

"use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }

function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

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

var n = parseInt(readline());
var answers = [];

for (var i = 0; i < n; i++) {
  var _readline$getNumArray = readline().getNumArray(),
      _readline$getNumArray2 = _slicedToArray(_readline$getNumArray, 3),
      c = _readline$getNumArray2[0],
      m = _readline$getNumArray2[1],
      l = _readline$getNumArray2[2];

  var mainMin = c < m ? c : m;
  l += Math.abs(c - m);

  if (l >= mainMin) {
    answers.push(mainMin);
  } else {
    var transport = Math.ceil((mainMin - l) / 3);
    answers.push(mainMin - transport);
  }
}

write(answers.join('\n'));

// c, m, x(코더, 수학자, 쩌리)
let lines = ''

process.stdin.resume()
process.stdin.setEncoding('utf-8')
process.stdin.on('data', input => lines += input)
process.stdin.on('end', () => {
  const { EOL } = require('os')
  lines = lines.split(EOL)

  main()
})

function main() {
  const q = lines[0]

  for(let i = 0; i < q; i++) {
    const [ c, m, x ] = lines[i + 1].split(/\s/).map(Number)
    const sum = Math.floor((c + m + x) / 3)
    const min = Math.min(c, m)

    console.log(Math.min(sum, min))
  }
}


Recall that a permutation of length $$$n$$$ is an array where each element from $$$1$$$ to $$$n$$$ occurs exactly once.For a fixed positive integer $$$d$$$, let's define the cost of the permutation $$$p$$$ of length $$$n$$$ as the number of indices $$$i$$$ $$$(1 \le i < n)$$$ such that $$$p_i \cdot d = p_{i + 1}$$$.For example, if $$$d = 3$$$ and $$$p = [5, 2, 6, 7, 1, 3, 4]$$$, then the cost of such a permutation is $$$2$$$, because $$$p_2 \cdot 3 = p_3$$$ and $$$p_5 \cdot 3 = p_6$$$.Your task is the following one: for a given value $$$n$$$, find the permutation of length $$$n$$$ and the value $$$d$$$ with maximum possible cost (over all ways to choose the permutation and $$$d$$$). If there are multiple answers, then print any of them.

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 500$$$) — the number of test cases. The single line of each test case contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^5$$$). The sum of $$$n$$$ over all test cases does not exceed $$$2 \cdot 10^5$$$.

For each test case, print the value $$$d$$$ in the first line, and $$$n$$$ integers in the second line — the permutation itself. If there are multiple answers, then print any of them.

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var arr = "";
process.stdin.on("data", function (chunk) {
  arr += chunk;
});

process.stdin.on("end", function () {
  arr = arr.split("\n");
  const testcases = parseInt(arr.shift());

  for (let t = 0; t < testcases; t++) {
    const n = arr[t].split(" ").map((el) => parseInt(el));

    const d = 2;

    const set = new Set();

    const res = [1];

    for (let i = 2; i <= n; i++) {
      if (!set.has(i)) {
        for (let j = i; j <= n; j *= 2) {
          if (!set.has(j)) {
            res.push(j);
            set.add(j);
          }
        }
      }
    }

    console.log(d);
    console.log(res.join(" "));
  }
});

"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 = parseInt(readline());
    if (n === 2) {
      console.log(2);
      console.log(`${1} ${2}`);
      continue;
    } else {
      let res = [],
        obj = {};
      res[0] = 1;
      for (let i = 2; i <= n; i++) {
        if (!obj[i]) {
          obj[i] = 1;
          res.push(i);
          let k = i * 2;
          while (k <= n) {
            obj[k] = 1;
            res.push(k);
            k = k * 2;
          }
        }
      }
      console.log(2);
      console.log(res.join(" "));
    }
  }
};
solve();

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}

var T = readline();
// var inf = 1000000000000;
for(var qe=1;qe<=T;qe++) {
  var n = readline();
  // var [a,b] = readline().split(' ').map((x) => parseInt(x));
  console.log(2);
  var ans = [], c = []
  for(var i=1;i<=n;i++) {
    if(c[i] == undefined) {
      for(var j=i;j<=n;j*=2) {
        ans.push(j);
        c[j] = true;
      }
    }
  }
  console.log(ans.join(" "))
}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function main(){
    var tests = parseInt(readline());
    for (let t = 0;t < tests; ++t) {
        let n = parseInt(readline());
        let hsh = Array(n+1).fill(false);
        let res = [];
        for (let j = 1;j <= n;++j) {
            if (hsh[j]) {
                continue;
            }
            for (let i = j;i <= n;i*=2) {
                hsh[i] = true;
                res.push(i);
            }
        }
        console.log(2);
        console.log(res.join(' ').toString());
    }

}

'use strict';

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

let inputString = '';
let currentLine = 0;

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

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

    main();
});

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

function output(x) {
    if (typeof x !== 'string') {
        x = x.toString();
    }
    //process.stdout.write(x);   // without auto '\n' (newline)
    console.log(x);  // with auto '\n' (newline)
}

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

    for (let test = 0; test < N; test++) {
        let n = readline();

        let used = {};
        let smallestNotUsed = 3;
        let arr = [1, 2];
        let i = 1;

        while (arr.length < n) {
            let double = arr[i] * 2;
            if (double <= n) {
                arr[i + 1] = double;
                used[double] = true;
            } else {
                arr[i + 1] = smallestNotUsed;
                used[smallestNotUsed] = true;
                let newSmallest = smallestNotUsed + 1;
                while (used[newSmallest]) {
                    newSmallest++;
                }
                smallestNotUsed = newSmallest;
            }
            i++;
        }

        output(2);
        output(arr.join(' '));
    }
}

'use strict';

function solve(n) {
  const res = [],
        set = new Set();
  for (let i = 1; i <= n; i++) {
    if (set.has(i)) continue;
    for (let j = i; j <= n; j *= 2) {
      res.push(j);
      set.add(j);
    }
  }
  return `${2}\n${res.join(' ')}`;
}

async function main(read) {
  try {
    let t = Number(await read());
    let res = new Array(t);
    for (let i = 0; i < t; i++) {
      const n = Number(await read());
      res[i] = solve(n);
    }
    return res.join('\n');
  } catch (error) {
    console.log(error);
  }
}

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

var n = +readline();

while (n--) {
	var t = +readline();
	print(2);
	var ans = 1;
	var arrCheck = new Array(t + 1);
	var mid = parseInt(t / 2);
	for (var i = 1; i <= mid; i++) {
		var ans = i;
		while (ans <= t && arrCheck[ans] === undefined) {
			write(ans + " ");
			arrCheck[ans] = 1;
			ans *= 2;
		}
	}
	for (var i = 1; i <= t; i++) {
		if (arrCheck[i] === undefined) write(i, " ");
	}
	print();
}

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var arr = "";
process.stdin.on("data", function (chunk) {
  arr += chunk;
});

process.stdin.on("end", function () {
  arr = arr.split("\n");
  const testcases = parseInt(arr.shift());

  for (let t = 0; t < testcases; t++) {
    const n = arr[t].split(" ").map((el) => parseInt(el));

    const d = 2;

    const set = new Set();

    const res = [];

    for (let i = 2; i <= n; i++) {
      if (!set.has(i)) {
        for (let j = i; j <= n; j *= 2) {
          if (!set.has(j)) {
            res.push(j);
            set.add(j);
          }
        }
      }
    }

    console.log(d);
    console.log(res.join(" "));
  }
});

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var arr = "";
process.stdin.on("data", function (chunk) {
  arr += chunk;
});

process.stdin.on("end", function () {
  arr = arr.split("\n");
  const testcases = parseInt(arr.shift());

  for (let t = 0; t < testcases; t++) {
    const n = arr[t].split(" ").map((el) => parseInt(el));

    const d = 2;

    const set = new Set();

    const res = [];

    for (let i = 1; i <= n; i = i * 2) {
      res.push(i);
      set.add(i);
    }

    for (let i = 1; i <= parseInt(n / 2); i++) {
      if (!set.has(i)) {
        res.push(i);
        res.push(i * 2);
        set.add(i);
        set.add(i * 2);
      } else {
        set.add(i * 2);
      }
    }

    for (let i = parseInt(n / 2); i <= n; i++) {
      if (!set.has(i)) res.push(i);
    }

    console.log(d);
    console.log(res.join(" "));
  }
});

process.stdin.resume();
process.stdin.setEncoding("utf-8");
var arr = "";
process.stdin.on("data", function (chunk) {
  arr += chunk;
});

process.stdin.on("end", function () {
  arr = arr.split("\n");
  const testcases = parseInt(arr.shift());

  for (let t = 0; t < testcases; t++) {
    const n = arr[t].split(" ").map((el) => parseInt(el));

    const d = 2;

    const set = new Set();

    const res = [];

    for (let i = 1; i <= n; i = i * 2) {
      res.push(i);
      set.add(i);
    }

    for (let i = 1; i <= n; i++) {
      if (!set.has(i)) res.push(i);
    }

    console.log(d);
    console.log(res.join(" "));
  }
});

"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 = parseInt(readline());
    if (n === 2) {
      console.log(2);
      console.log(`${1} ${2}`);
      continue;
    } else {
      let res = [],
        obj = {};
      res[0] = 1;
      for (let i = 2; i <= n; i++) {
        if (!obj[i]) {
          obj[i] = 1;
          res.push(i);
          if (i * 2 <= n) {
            obj[i * 2] = 1;
            res.push(i * 2);
          }
        }
      }
      console.log(2);
      console.log(res.join(" "));
    }
  }
};
solve();

const fs = require("fs");
const input = fs.readFileSync(0, 'utf8').trim().split('\n');
let currentline = 0;
function readline(){
      return input[currentline++];
}

function alph() {
  var f = 'abcdefghijklmnopqrstuvwxyz';
  return f;
}
function Alph() {
  var f = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  return f;
}
function max(x,y) {
  return x >=y ? x : y;
}
function min(x,y) {
  return x <=y ? x : y;
}
function abs(x) {
  return x < 0 ? x*(-1) : x;
}

var T = readline();
// var inf = 1000000000000;
for(var qe=1;qe<=T;qe++) {
  var n = readline();
  // var [a,b] = readline().split(' ').map((x) => parseInt(x));
  console.log(2);
  var ans = [], c = []
  for(var i=1;i<=n;i*=2) {
    ans.push(i);
    c[i] = true;
  }
  for(var i=3;i<=n;i++) {
    if(c[i] == undefined) ans.push(i)
  }
  console.log(ans.join(" "))
}

var n = +readline();

while (n--) {
	var t = +readline();
	print(2);
	var ans = 1;
	var arrCheck = new Array(t + 1);
	var mid = parseInt(t / 2);
	for (var i = 1; i <= mid; i++) {
		var ans = i;
		while (ans <= t && arrCheck[ans] === undefined) {
			write(ans + " ");
			arrCheck[ans] = 1;
			ans *= 2;
		}
	}
	if (t % 2) write(t + " ");
	print();
}

var n = +readline();

while (n--) {
	var t = +readline();
	print(2);
	var ans = 1;
	var arrCheck = new Array(t + 1);
	while (ans <= t) {
		write(ans + " ");
		arrCheck[ans] = 1;
		ans *= 2;
	}

	for (var i = 3; i <= t; i++) {
		if (arrCheck[i] === undefined) write(i + " ");
	}

	print();
}


Let's call left cyclic shift of some string $$$t_1 t_2 t_3 \dots t_{n - 1} t_n$$$ as string $$$t_2 t_3 \dots t_{n - 1} t_n t_1$$$.Analogically, let's call right cyclic shift of string $$$t$$$ as string $$$t_n t_1 t_2 t_3 \dots t_{n - 1}$$$.Let's say string $$$t$$$ is good if its left cyclic shift is equal to its right cyclic shift.You are given string $$$s$$$ which consists of digits 0–9.What is the minimum number of characters you need to erase from $$$s$$$ to make it good?

The first line contains single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Next $$$t$$$ lines contains test cases — one per line. The first and only line of each test case contains string $$$s$$$ ($$$2 \le |s| \le 2 \cdot 10^5$$$). Each character $$$s_i$$$ is digit 0–9. It's guaranteed that the total length of strings doesn't exceed $$$2 \cdot 10^5$$$.

For each test case, print the minimum number of characters you need to erase from $$$s$$$ to make it good.

NoteIn the first test case, you can erase any $$$3$$$ characters, for example, the $$$1$$$-st, the $$$3$$$-rd, and the $$$4$$$-th. You'll get string 51 and it is good.In the second test case, we can erase all characters except 0: the remaining string is 0000 and it's good.In the third test case, the given string $$$s$$$ is already good.

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const str = readLine();
    let ans = 0;
    for (let i = 0; i < 10; i++) {
      for (let j = 0; j < 10; j++) {
        let count = 0;
        for (let k = 0; k < str.length; k++) {
          if (count % 2 === 0 && +str[k] === i) {
            count++;
          } else if (count % 2 !== 0 && +str[k] === j) {
            count++;
          }
        }
        if (i !== j && count % 2 !== 0) {
          count = count - 1;
        }
        ans = Math.max(ans, count);
      }
    }
    console.log(`${str.length - ans}`);
  }
}

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

    C();
});

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

function ti(a){
    for(let i = 0; i < a.length; i++)
        a[i] = parseInt(a[i]);

    return a;
}

function B(){
    let t = parseInt(readline());
    while(t > 0){
        t--;
        let [n,k,z] = ti(readline().split(' '));
        let a = ti(readline().split(' '));

        let solve = (i, k, z) => {
            if(k < 0 || z < 0)
                return 0;

            if(i < 0 || i >= n)
                return 0;

            let right = a[i] + solve(i+1, k-1, z);
            let left = a[i] + solve(i-1, k-1, z-1);

            return Math.max(left, right);
        }

        console.log(solve(0, k, z));
    }
}

function C(){
    let t = parseInt(readline());

    while(t > 0){
        t--;
        let max = 0;
        let s = readline();

        for(let i = 0; i < 10; i++){
            for(let j = i; j < 10; j++){
                let pre = -1;
                let len = 0;
                for(let k = 0; k < s.length; k++){
                    if(i === j){
                        if(parseInt(s.charAt(k)) === i){
                            len += 1;
                        }
                    }else{
                        if(parseInt(s.charAt(k)) === i){
                            if(pre !== i){
                                len += 1;
                                pre = i;
                            }
                        }else if(parseInt(s.charAt(k)) === j){
                            if(pre != j){
                                len += 1;
                                pre = j;
                            }
                        }
                    }
                }

                if(i !== j && len % 2 !== 0)
                    len -= 1;

                max = Math.max(max, len);
            }
        }

        console.log(s.length - max);
    }
}

function main(){
    let [n,k] = ti(readline().split(' '));
    let w = new Array(n);
    let v = new Array(n);

    for(let i = 0; i < n; i++){
        let [x,y] = ti(readline().split(' '));
        w[i] = x;
        v[i] = y;
    }

    let dp = new Array(n);
    for(let i = 0; i < n; i++){
        dp[i] = new Array(100001);
        dp[i].fill(99999999999);
    }

    for(let i = 0; i < n; i++){
        for(let j = 0; j < 100001; j++){
            if(i === 0 || j === 0){
                if(i === 0 && j === 0)
                    dp[i][j] = 0;
                else if(i === 0)
                    dp[i][j] = v[0] === j ? w[0] : 99999999999;
            }else{
                dp[i][j] = dp[i-1][j];
                if(j >= v[i])
                    dp[i][j] = Math.min(dp[i][j], w[i] + dp[i-1][j-v[i]]);
            }
        }
    }

    let max = 0;
    for(let i = 100000; i >= 0; i--){
        if(dp[n-1][i] <= k){
            max = i;
            break;
        }
    }

    console.log(max);
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const str = readLine();
    let ans = 0;
    for (let i = 0; i < 10; i++) {
      for (let j = 0; j < 10; j++) {
        let count = 0;
        for (let k = 0; k < str.length; k++) {
          if (k % 2 === 0 && +str[k] === i) {
            count++;
          } else if (k % 2 !== 0 && +str[k] === j) {
            count++;
          }
        }
        if (i !== j) {
          count -= count % 2;
          ans = Math.max(ans, count);
        }
      }
    }
    console.log(`${str.length - ans}`);
  }
}

let inputString = "";
let currentLine = 0;
process.stdin.on("data", (data) => {
  inputString += data;
});
process.stdin.on("end", function () {
  inputString = inputString
    .trim()
    .split("\n")
    .map((str) => str.trim());
  main();
});
function readLine() {
  return inputString[currentLine++];
}
function main() {
  let t = +readLine();
  while (t--) {
    const str = readLine();
    let ans = 0;
    for (let i = 0; i < 10; i++) {
      for (let j = 0; j < 10; j++) {
        let count = 0;
        for (let k = 0; k < str.length; k++) {
          if (k % 2 === 0 && +str[k] === i) {
            count++;
          } else if (k % 2 !== 0 && +str[k] === j) {
            count++;
          }
        }
        if (i !== j) {
          count -= count % 2;
        }
        ans = Math.max(ans, count);
      }
    }
    console.log(`${str.length - ans}`);
  }
}


Diamond Miner is a game that is similar to Gold Miner, but there are $$$n$$$ miners instead of $$$1$$$ in this game.The mining area can be described as a plane. The $$$n$$$ miners can be regarded as $$$n$$$ points on the y-axis. There are $$$n$$$ diamond mines in the mining area. We can regard them as $$$n$$$ points on the x-axis. For some reason, no miners or diamond mines can be at the origin (point $$$(0, 0)$$$). Every miner should mine exactly one diamond mine. Every miner has a hook, which can be used to mine a diamond mine. If a miner at the point $$$(a,b)$$$ uses his hook to mine a diamond mine at the point $$$(c,d)$$$, he will spend $$$\sqrt{(a-c)^2+(b-d)^2}$$$ energy to mine it (the distance between these points). The miners can't move or help each other.The object of this game is to minimize the sum of the energy that miners spend. Can you find this minimum?

The input consists of multiple test cases. The first line contains a single integer $$$t$$$ ($$$1\le t\le 10$$$) — the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 10^5$$$) — the number of miners and mines. Each of the next $$$2n$$$ lines contains two space-separated integers $$$x$$$ ($$$-10^8 \le x \le 10^8$$$) and $$$y$$$ ($$$-10^8 \le y \le 10^8$$$), which represent the point $$$(x,y)$$$ to describe a miner's or a diamond mine's position. Either $$$x = 0$$$, meaning there is a miner at the point $$$(0, y)$$$, or $$$y = 0$$$, meaning there is a diamond mine at the point $$$(x, 0)$$$. There can be multiple miners or diamond mines at the same point. It is guaranteed that no point is at the origin. It is guaranteed that the number of points on the x-axis is equal to $$$n$$$ and the number of points on the y-axis is equal to $$$n$$$. It's guaranteed that the sum of $$$n$$$ for all test cases does not exceed $$$10^5$$$.

For each test case, print a single real number — the minimal sum of energy that should be spent. Your answer is considered correct if its absolute or relative error does not exceed $$$10^{-9}$$$. Formally, let your answer be $$$a$$$, and the jury's answer be $$$b$$$. Your answer is accepted if and only if $$$\frac{|a - b|}{\max{(1, |b|)}} \le 10^{-9}$$$.

NoteIn the first test case, the miners are at $$$(0,1)$$$ and $$$(0,-1)$$$, while the diamond mines are at $$$(1,0)$$$ and $$$(-2,0)$$$. If you arrange the miners to get the diamond mines in the way, shown in the picture, you can get the sum of the energy $$$\sqrt2 + \sqrt5$$$.

"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++];
}
function iInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => parseInt(cur));
}
function BInpArr() {
  return readline()
    .trim()
    .split(" ")
    .map((cur) => BigInt(cur));
}
function string() {
  return readline().trim();
}
function stringArr() {
  return readline().trim().split("");
}
function getValue() {
  return parseInt(readline());
}
let mod = BigInt(1e9 + 7);
const solve = () => {
  let t = getValue();
  while (t--) {
    let n = getValue();
    let min = [],
      dia = [];
    for (let i = 0; i < n * 2; i++) {
      let k = iInpArr();
      if (k[0] === 0) min.push([k[0], Math.abs(k[1])]);
      else dia.push([Math.abs(k[0]), k[1]]);
    }
    min.sort((a, b) => a[1] - b[1]);
    dia.sort((a, b) => a[0] - b[0]);
    let sum = 0;
    for (let i = 0; i < n; i++) {
      let k = min[i][1] * min[i][1] + dia[i][0] * dia[i][0];
      sum += Math.sqrt(k);
    }
    console.log(sum + "");
  }
};
solve();

const mineAllDays = (miners, diamonds) => {
  let res = 0;
  for (let i = 0; i < miners.length; i++) {
    res += Math.sqrt(miners[i] ** 2 + diamonds[i] ** 2);
  }
  return res;
};

const main = () => {
  let test = readInt();
  while (test--) {
    const miners = [];
    const diamonds = [];
    const n = readInt();
    for (let i = 0; i < 2 * n; i++) {
      const [x, y] = readListInt();
      if (x === 0) miners.push(Math.abs(y));
      else diamonds.push(Math.abs(x));
    }
    miners.sort((a, b) => a - b);
    diamonds.sort((a, b) => a - b);
    console.log(mineAllDays(miners, diamonds));
  }
};

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 => string.trim());
  main();
});

const readLine = () => {
  return inputString[currentLine++];
};

const readInt = () => {
  return parseInt(inputString[currentLine++]);
};

const readListInt = () => {
  return inputString[currentLine++].split(" ").map(s => parseInt(s));
};

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var alist = [];
		var blist = [];
		for(var j = 0; j < 2 * N; j++){
			var x = nextInt();
			var y = nextInt();
			if(x != 0){
				blist.push({
					x : x,
					y : y
				});
			}else{
				alist.push({
					x : x,
					y : y
				});
			}
		}
		alist.sort(function(a,b){
			return Math.abs(a.y) - Math.abs(b.y);
		});
		blist.sort(function(a,b){
			return Math.abs(a.x) - Math.abs(b.x);
		});
		var sum = 0;

		for(var j = 0; j < N; j++){
			sum += Math.sqrt(alist[j].y * alist[j].y + blist[j].x * blist[j].x);
		}
		myout(sum);
	}
}

'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();
var mod = 1000000000n + 7n
var maxN = 1002

function main() {
  const x = readline();

  Array(parseInt(x)).fill(1).map((t, iii) => {
    var n = parseInt(readline())
    // var a = readline().split(' ').map((x, iii) => {
    //   return parseInt(x)
    // })

    var x = []
    var y = []
    for (let i = 0; i < 2 * n; i++) {
      var [xx, yy] = readline().split(' ').map((x, iii) => {
        return parseInt(x)
      })

      if (xx === 0) y.push(yy)
      if (yy === 0) x.push(xx)
    }
    x = x.sort((a, b) => Math.abs(a) - Math.abs(b))
    y = y.sort((a, b) => Math.abs(a) - Math.abs(b))
    // console.log(x)
    // console.log(y)
    var sum = 0
    for (let i = 0; i < n; i++) {
      sum += Math.sqrt(x[i] * x[i] + y[i] * y[i])
    }
    console.log(sum)

  })
}

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

  return gcd(b, a % b);
}


There are $$$n$$$ piranhas with sizes $$$a_1, a_2, \ldots, a_n$$$ in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.Scientists of the Berland State University want to find if there is dominant piranha in the aquarium. The piranha is called dominant if it can eat all the other piranhas in the aquarium (except itself, of course). Other piranhas will do nothing while the dominant piranha will eat them.Because the aquarium is pretty narrow and long, the piranha can eat only one of the adjacent piranhas during one move. Piranha can do as many moves as it needs (or as it can). More precisely:   The piranha $$$i$$$ can eat the piranha $$$i-1$$$ if the piranha $$$i-1$$$ exists and $$$a_{i - 1} < a_i$$$.  The piranha $$$i$$$ can eat the piranha $$$i+1$$$ if the piranha $$$i+1$$$ exists and $$$a_{i + 1} < a_i$$$. When the piranha $$$i$$$ eats some piranha, its size increases by one ($$$a_i$$$ becomes $$$a_i + 1$$$).Your task is to find any dominant piranha in the aquarium or determine if there are no such piranhas.Note that you have to find any (exactly one) dominant piranha, you don't have to find all of them.For example, if $$$a = [5, 3, 4, 4, 5]$$$, then the third piranha can be dominant. Consider the sequence of its moves:   The piranha eats the second piranha and $$$a$$$ becomes $$$[5, \underline{5}, 4, 5]$$$ (the underlined piranha is our candidate).  The piranha eats the third piranha and $$$a$$$ becomes $$$[5, \underline{6}, 5]$$$.  The piranha eats the first piranha and $$$a$$$ becomes $$$[\underline{7}, 5]$$$.  The piranha eats the second piranha and $$$a$$$ becomes $$$[\underline{8}]$$$. You have to answer $$$t$$$ independent test cases.

The first line of the input contains one integer $$$t$$$ ($$$1 \le t \le 2 \cdot 10^4$$$) — the number of test cases. Then $$$t$$$ test cases follow. The first line of the test case contains one integer $$$n$$$ ($$$2 \le n \le 3 \cdot 10^5$$$) — the number of piranhas in the aquarium. The second line of the test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le 10^9$$$), where $$$a_i$$$ is the size of the $$$i$$$-th piranha. It is guaranteed that the sum of $$$n$$$ does not exceed $$$3 \cdot 10^5$$$ ($$$\sum n \le 3 \cdot 10^5$$$).

For each test case, print the answer: -1 if there are no dominant piranhas in the aquarium or index of any dominant piranha otherwise. If there are several answers, you can print any.

NoteThe first test case of the example is described in the problem statement.In the second test case of the example, there are no dominant piranhas in the aquarium.In the third test case of the example, the fourth piranha can firstly eat the piranha to the left and the aquarium becomes $$$[4, 4, 5, 4]$$$, then it can eat any other piranha in the aquarium.

'use strict'; /*jslint node:true, browser:true, es6:true*/
const rl = require('readline').createInterface({ input: process.stdin, output: process.stdout })
const print = console.log
const lines = []
rl.on('line', line => {
    lines.push(line);
});
rl.on('close', main)
let rli = 0;
function readline() {
    return lines[rli++];
}

let mem = new Map();
function query(arr){
    let max_i = 0, min_i = 0;
    for (let i=0; i<arr.length; i++)
    {
        max_i = arr[max_i] < arr[i]  ? i : max_i;
        min_i = arr[min_i] > arr[i]  ? i : min_i;
    }
    if (max_i==min_i)
        return -1;
    for (let i=0; i<arr.length; i++)
    {
        if (arr[i]==arr[max_i] && (arr[i-1] < arr[i] || arr[i+1] < arr[i]))
            return i+1;
    }
    return -1;
}

function main() {
    var q = +readline();
    while (q--)
    {
        var n = +readline();
        let arr = readline().split(' ').map(a=>+a);
        print(query(arr));
    }
}

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

let lineNum = 0;
let countOfData = null;
let data = [];
readline.on('line', line => {
  lineNum++;
  if(lineNum === 1) {
    countOfData = +line * 2;
    return;
  }

  data.push(line);

  if(lineNum - 1 === countOfData) {
    goToSolution(data);
  }

});

function goToSolution(data) {
  data.forEach((piranhas, i) => {
    if(i % 2 !== 0) {
      const splitted = piranhas.split(' ');
      const sorted = splitted.map((piranha, i) => [+piranha, i])
        .sort((a, b) => b[0] - a[0]);

      for(let i = 0; i < sorted.length && sorted[i][0] == sorted[0][0]; i++) {
        const cur = sorted[i][0];
        const left = splitted[sorted[i][1] - 1];
        const right = splitted[sorted[i][1] + 1];
        if(left < cur || right < cur) {
            console.log(sorted[i][1] + 1)
            return;
          }
      }

      console.log(-1)
    }
  })
}

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

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

function main() {
  let t = +readLine();
  while (t--) {
    const len = +readLine();
    const arr = readLine().split(" ").map(Number);
    let [max, maxIndex, allSame] = [-Infinity, 0, true];

    for (let i = 1; i < len; i++) {
      const [curr, prev] = [arr[i], arr[i - 1]];
      const diff = Math.abs(curr - prev);
      if (diff !== 0) {
        allSame = false;
        if (curr > prev && curr > max) {
          max = curr;
          maxIndex = i;
        } else if (prev > curr && prev > max) {
          max = prev;
          maxIndex = i - 1;
        }
      }
    }
    if (allSame) console.log(-1);
    else {
      console.log(maxIndex + 1);
    }
  }
}

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

//Don't have to see. end------------------------------------------
function Main(){
	var t = nextInt();
	var output = new Array(t);
	for(var i = 0; i < t; i++){
		var N = nextInt();
		var list = nextIntArray();
		var isOK = true;
		var max = 0;
		var maxIndex = -1;
		for(var j = 0; j < N - 1; j++){
			if(list[j] != list[j + 1]){
				isOK = false;
				break;
			}
		}
		if(isOK){
			output[i] = -1;
			continue;
		}
		for(var j = 0; j < N; j++){
			if(j == 0){
				if(max < list[j] && list[j] != list[j + 1]){
					max = list[j];
					maxIndex = j + 1;
				}
				continue;
			}
			if(j == N - 1){
				if(max < list[j] && list[j] != list[j - 1]){
					max = list[j];
					maxIndex = j + 1;
				}
				continue;
			}
			if((list[j] != list[j + 1] || list[j] != list[j - 1]) && max < list[j]){
				max = list[j];
				maxIndex = j + 1;
			}
		}
		output[i] = maxIndex;
	}
	myout(myconv(output, 9));
}

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

let stdinInput = '';

process.stdin.on('data', input => {
  stdinInput += input;
})

process.stdin.on('end', () => {
  main(stdinInput);
})

function main(data) {
    data = data.split('\n');
    const testCases = data[0] * 2;
    let i = 1;
    while (i <= testCases) {
      // let a = data[i].trim();
      // const n = data[i] * 1;
      // const k = a[1];
      const s = data[i + 1].trim().split(' ').map(Number);
      // s.sort((a, b) => b - a);
      let idx = 0;
      let max = 0;
      let obj = {};

      for (let j = 0; j < s.length; j += 1) {
        if (obj[s[j]]) obj[s[j]].push(j);
        else obj[s[j]] = [j];
        if (s[j] > max) {
          max = s[j];
          idx = j;
        }
      }
      // console.log(obj, obj[max]);

      let j = 0;
      idx = -1
      // console.log(idx, 'idx', max)
      for (; j < obj[max].length; j += 1) {
        let x = obj[max][j];
        if (s[x + 1] && s[x + 1] < s[x]) {
          idx = x + 1;
          // console.log(j,'j');
          break;

        } else if (s[x - 1] && s[x - 1] < s[x]) {
          idx = x + 1;
          // console.log(j,'ej');
          break;
        }
      }

      console.log(idx);
      i += 2;
    }
}

var t = parseInt(readline());

while (t--) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(function(x, index) {
        // print("index: " + index + " val: " + x);
        return parseInt(x);
    });
    var same = 1;
    for (var i = 1; i < ar.length; ++i) if (ar[0] !== ar[i]) same = 0;
    if (same) {
        print("-1");
        continue;
    }

    var ans = -1;
    var big = ar[0];

    for (var i = 1; i < ar.length; ++i) if (ar[i] > big) big = ar[i];

    for (var i = 0; i < ar.length; ++i) {
        if (i - 1 >= 0 && ar[i] === big && ar[i-1] < ar[i]) {
            ans = i + 1;
            break;
        }
        if (i + 1 < ar.length && ar[i] === big && ar[i+1] < ar[i]) {
            ans = i + 1;
            break;
        }
    }

    print(ans);

    // ar.forEach(function(val) {
    //     print(val[0] + ' -> ' + val[1]);
    // });
}

// your code goes here
var t = parseInt(readline());
for (var x = 0; x < t; ++x) {
	var n = parseInt(readline());
	var a = readline().split(' ').map(x => parseInt(x));
	var mx = 0;
	for (var i = 0; i < n; ++i) {
		if (a[i] > mx) {
			mx = a[i];
		}
	}
	var ind = -2;
	for (var i = 0; i < n; ++i) {
		if (a[i] == mx) {
			if (i > 0 && a[i - 1] < mx) {
				ind = i;
				break;
			} else if (i < n - 1 && a[i + 1] < mx) {
				ind = i;
				break;
			}
		}
	}
	print(ind + 1);
}

var t = parseInt(readline());

while (t--) {
    var n = parseInt(readline());
    var ar = readline().split(' ').map(function(x, index) {
        // print("index: " + index + " val: " + x);
        return [parseInt(x), index + 1];
    });
    var same = 1;
    for (var i = 1; i < ar.length; ++i) if (ar[0][0] !== ar[i][0]) same = 0;
    if (same) {
        print("-1");
        continue;
    }

    ar.sort(function(v1, v2) {
        if (v1[0] < v2[0]) return 1;
        return -1;
    });

    print(ar[0][1]);

    // ar.forEach(function(val) {
    //     print(val[0] + ' -> ' + val[1]);
    // });
}

// your code goes here
var t = +readline();
for (var x = 0; x < t; ++x) {
	var n = +readline();
	var a = readline().split(' ');
	var mx = 0;
	for (var i = 0; i < n; ++i) {
		if (a[i] > mx) {
			mx = a[i];
		}
	}
	var ind = -2;
	for (var i = 0; i < n; ++i) {
		if (a[i] == mx) {
			if (i > 0 && a[i - 1] < mx) {
				ind = i;
				break;
			} else if (i < n - 1 && a[i + 1] < mx) {
				ind = i;
				break;
			}
		}
	}
	print(ind + 1);
}

// your code goes here
var t = parseInt(readline());
for (var x = 0; x < t; ++x) {
	var n = parseInt(readline());
	var a = readline().split(' ').map(x => parseInt(x));
	var mx = 0;
	for (var i = 0; i < n; ++i) {
		if (a[i] > mx) {
			mx = a[i];
		}
	}
	print(mx);
	var ind = -2;
	for (var i = 0; i < n; ++i) {
		if (a[i] == mx) {
			if (i > 0 && a[i - 1] < mx) {
				ind = i;
				break;
			} else if (i < n - 1 && a[i + 1] < mx) {
				ind = i;
				break;
			}
		}
	}
	print(ind + 1);
}